| 1 | /******************************************************************************* |
|---|---|
| 2 | * Copyright 2016-2018 Intel Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | *******************************************************************************/ |
| 16 | |
| 17 | #ifndef CPU_CONVOLUTION_PD_HPP |
| 18 | #define CPU_CONVOLUTION_PD_HPP |
| 19 | |
| 20 | #include <assert.h> |
| 21 | |
| 22 | #include "c_types_map.hpp" |
| 23 | #include "convolution_pd.hpp" |
| 24 | #include "type_helpers.hpp" |
| 25 | #include "utils.hpp" |
| 26 | |
| 27 | namespace mkldnn { |
| 28 | namespace impl { |
| 29 | namespace cpu { |
| 30 | |
| 31 | struct cpu_convolution_fwd_pd_t: public convolution_fwd_pd_t { |
| 32 | using convolution_fwd_pd_t::convolution_fwd_pd_t; |
| 33 | |
| 34 | bool has_padded_dst() const { |
| 35 | memory_desc_wrapper dst_d(&dst_md_); |
| 36 | return OC() != dst_d.padded_dims()[1]; |
| 37 | } |
| 38 | |
| 39 | bool wants_padded_bias() const { |
| 40 | if (!with_bias()) return false; |
| 41 | return has_padded_dst(); |
| 42 | } |
| 43 | |
| 44 | bool wants_zero_pad_dst(bool jit_impl = true) const { |
| 45 | if (!has_padded_dst()) return false; |
| 46 | const auto &po = attr()->post_ops_; |
| 47 | int idx; |
| 48 | if ((idx = po.find(primitive_kind::eltwise)) == -1) return false; |
| 49 | return !math::eltwise_fwd_preserves_zero(po.entry_[idx].eltwise.alg, |
| 50 | jit_impl); |
| 51 | } |
| 52 | }; |
| 53 | |
| 54 | struct cpu_convolution_bwd_data_pd_t: public convolution_bwd_data_pd_t { |
| 55 | using convolution_bwd_data_pd_t::convolution_bwd_data_pd_t; |
| 56 | }; |
| 57 | |
| 58 | struct cpu_convolution_bwd_weights_pd_t: public convolution_bwd_weights_pd_t { |
| 59 | using convolution_bwd_weights_pd_t::convolution_bwd_weights_pd_t; |
| 60 | |
| 61 | bool wants_padded_bias() const { |
| 62 | if (!with_bias()) return false; |
| 63 | memory_desc_wrapper diff_dst_d(&diff_dst_md_); |
| 64 | return OC() != diff_dst_d.padded_dims()[1]; |
| 65 | } |
| 66 | }; |
| 67 | |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | #endif |
| 73 | |
| 74 | // vim: et ts=4 sw=4 cindent cino^=l0,\:0,N-s |
| 75 |