def forward_cpu(self, x: tensor) -> tensor: x.reshape([x.shape[0], x.shape[1], 1, x.shape[2], x.shape[3]]) y = super(MaxPool2d, self).forward_cpu(x) x.reset_shape() y.reshape([x.shape[0], y.shape[1], y.shape[3], y.shape[4]]) y.init_shape = y.shape return y
def _backward_gpu(self, dx: tensor) -> tensor: dx.reshape(self.old_shape) return dx
def _forward_gpu(self, x: tensor) -> tensor: x.reshape([x.shape[0], -1]) return x
def forward_cpu(self, x: tensor) -> tensor: x.reshape([x.shape[0], x.shape[1], 1, 1, x.shape[2]]) y = super(MaxPool1d, self).forward_cpu(x) x.reset_shape() y.reshape([x.shape[0], y.shape[1], y.shape[-1]]) return y