(self, dev)
| 288 | self._sum_helper(gpu_dev) |
| 289 | |
| 290 | def _SeparableConv2d_helper(self, dev): |
| 291 | # SeparableConv2d(in_channels, out_channels, kernel_size) |
| 292 | if dev == cpu_dev: |
| 293 | in_channels = 1 |
| 294 | else: |
| 295 | in_channels = 8 |
| 296 | separ_conv = layer.SeparableConv2d(16, 3, padding=1) |
| 297 | |
| 298 | x = np.random.random((10, in_channels, 28, 28)).astype(np.float32) |
| 299 | x = tensor.Tensor(device=dev, data=x) |
| 300 | |
| 301 | y = separ_conv(x) |
| 302 | self.check_shape(y.shape, (10, 16, 28, 28)) |
| 303 | |
| 304 | y1 = separ_conv.depthwise_conv(x) |
| 305 | y2 = separ_conv.point_conv(y1) |
| 306 | |
| 307 | dy1, dW_depth = y2.creator.backward(y2.data) |
| 308 | dx, dW_spacial = y1.creator.backward(dy1) |
| 309 | |
| 310 | self.check_shape(y2.shape, (10, 16, 28, 28)) |
| 311 | |
| 312 | self.check_shape(dy1.shape(), (10, in_channels, 28, 28)) |
| 313 | self.check_shape(dW_depth.shape(), (16, in_channels, 1, 1)) |
| 314 | |
| 315 | self.check_shape(dx.shape(), (10, in_channels, 28, 28)) |
| 316 | self.check_shape(dW_spacial.shape(), (in_channels, 1, 3, 3)) |
| 317 | |
| 318 | def test_SeparableConv2d_cpu(self): |
| 319 | self._SeparableConv2d_helper(cpu_dev) |
no test coverage detected