(self, dev)
| 117 | self._greater_helper(gpu_dev) |
| 118 | |
| 119 | def _conv2d_helper(self, dev): |
| 120 | # (out_channels, kernel_size) |
| 121 | conv_0 = layer.Conv2d(1, 2) |
| 122 | conv_without_bias_0 = layer.Conv2d(1, 2, bias=False) |
| 123 | |
| 124 | cpu_input_tensor = tensor.Tensor(shape=(2, 3, 3, 3), device=dev) |
| 125 | cpu_input_tensor.gaussian(0.0, 1.0) |
| 126 | |
| 127 | dy = tensor.Tensor(shape=(2, 1, 2, 2), device=dev) |
| 128 | dy.gaussian(0.0, 1.0) |
| 129 | |
| 130 | y = conv_0(cpu_input_tensor) # PyTensor |
| 131 | dx, dW, db = y.creator.backward(dy.data) # CTensor |
| 132 | |
| 133 | self.check_shape(y.shape, (2, 1, 2, 2)) |
| 134 | self.check_shape(dx.shape(), (2, 3, 3, 3)) |
| 135 | self.check_shape(dW.shape(), (1, 3, 2, 2)) |
| 136 | self.check_shape(db.shape(), (1,)) |
| 137 | |
| 138 | # forward without bias |
| 139 | y_without_bias = conv_without_bias_0(cpu_input_tensor) |
| 140 | self.check_shape(y_without_bias.shape, (2, 1, 2, 2)) |
| 141 | |
| 142 | def test_conv2d_cpu(self): |
| 143 | self._conv2d_helper(cpu_dev) |
no test coverage detected