| 107 | } |
| 108 | |
| 109 | void PaddingBase::check_exec(const TensorLayout& src, const TensorLayout& dst) { |
| 110 | SmallVector<size_t> offsets(get_offsets()); |
| 111 | // make sure the src and dst tensor not empty |
| 112 | megdnn_assert(src.ndim != 0 && dst.ndim != 0); |
| 113 | // make sure src and dst is same dtype |
| 114 | megdnn_assert_eq_dtype(src, dst); |
| 115 | // make sure src and dst is same ndim |
| 116 | megdnn_assert( |
| 117 | src.ndim == dst.ndim, "the src.ndim = %zu the dst.ndim = %zu", src.ndim, |
| 118 | dst.ndim); |
| 119 | // make sure in every dimension dst is equal or greater than src |
| 120 | for (size_t i = 0; i < src.ndim; ++i) { |
| 121 | megdnn_assert( |
| 122 | dst.shape[i] == src.shape[i] + offsets[i * 2] + offsets[i * 2 + 1]); |
| 123 | } |
| 124 | // check the padding mode is valid |
| 125 | megdnn_assert( |
| 126 | static_cast<uint32_t>(param().padding_mode) == |
| 127 | padding_param::PaddingMode::REFLECT || |
| 128 | static_cast<uint32_t>(param().padding_mode) == |
| 129 | padding_param::PaddingMode::REPLICATE || |
| 130 | static_cast<uint32_t>(param().padding_mode) == |
| 131 | padding_param::PaddingMode::CONSTANT, |
| 132 | "unsupported padding mode"); |
| 133 | // addition check for reflect padding, make sure the reflected index is |
| 134 | // valid |
| 135 | if (static_cast<uint32_t>(param().padding_mode) == |
| 136 | padding_param::PaddingMode::REFLECT) { |
| 137 | for (size_t i = 0; i < src.ndim; ++i) { |
| 138 | megdnn_assert( |
| 139 | offsets[i * 2] < src.shape[i] && |
| 140 | dst.shape[i] - offsets[i * 2] - src.shape[i] < src.shape[i]); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | } // namespace megdnn |
nothing calls this directly
no test coverage detected