(self, inp)
| 218 | super().__init__(**kwargs) |
| 219 | |
| 220 | def forward(self, inp): |
| 221 | assert isinstance( |
| 222 | inp, Tensor |
| 223 | ), "expected input is megengine.Tensor, but got {}".format(type(inp)) |
| 224 | if inp.format == "nchw" or inp.format == "default": |
| 225 | _norm_inp = inp |
| 226 | N, C, H, W = inp.shape |
| 227 | else: |
| 228 | raise RuntimeError( |
| 229 | "expect you create Tensor with format NCHW, got format is {}".format( |
| 230 | inp.format |
| 231 | ) |
| 232 | ) |
| 233 | kernel = self.get_kernel(_norm_inp, C) |
| 234 | pad_inp = pad( |
| 235 | _norm_inp, pad_width=((0, 0), (0, 0), (1, 1), (1, 1)), mode="reflect" |
| 236 | ) |
| 237 | result = conv2d(pad_inp, kernel, groups=C) |
| 238 | result = _check_out_dtype(result, inp.dtype) |
| 239 | return result |
| 240 | |
| 241 | def _get_parameter(self, param): |
| 242 | if isinstance(param, bool): |
nothing calls this directly
no test coverage detected