MCPcopy Create free account
hub / github.com/apache/singa / upsample_helper

Method upsample_helper

test/python/test_operation.py:3352–3374  ·  view source on GitHub ↗
(self, dev)

Source from the content-addressed store, hash-verified

3350 self.pad_helper(gpu_dev)
3351
3352 def upsample_helper(self, dev):
3353 X = np.array([[[
3354 [1, 2],
3355 [3, 4],
3356 ]]], dtype=np.float32)
3357 x = tensor.from_numpy(X)
3358 x.to_device(dev)
3359
3360 scales = np.array([1.0, 1.0, 2.0, 3.0], dtype=np.float32)
3361 y_t = np.array([[[
3362 [1, 1, 1, 2, 2, 2],
3363 [1, 1, 1, 2, 2, 2],
3364 [3, 3, 3, 4, 4, 4],
3365 [3, 3, 3, 4, 4, 4],
3366 ]]],
3367 dtype=np.float32)
3368 dy = tensor.from_numpy(y_t)
3369 dy.to_device(dev)
3370
3371 y = autograd.upsample(x, "nearest", scales)
3372 dx = y.creator.backward(dy.data)
3373 np.testing.assert_array_almost_equal(tensor.to_numpy(y), y_t)
3374 self.check_shape(dx.shape(), tuple(X.shape))
3375
3376 def test_upsample_cpu(self):
3377 self.upsample_helper(cpu_dev)

Callers 2

test_upsample_cpuMethod · 0.95
test_upsample_gpuMethod · 0.95

Calls 5

check_shapeMethod · 0.95
shapeMethod · 0.80
tupleFunction · 0.50
to_deviceMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected