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

Method constantOfShape_test

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

Source from the content-addressed store, hash-verified

2693 self.globalaveragepool_channel_last(gpu_dev)
2694
2695 def constantOfShape_test(self, dev):
2696 # float_ones
2697 X = np.array([4, 3, 2]).astype(np.int64)
2698 x = tensor.from_numpy(X)
2699 x.to_device(dev)
2700
2701 y = np.ones(X, dtype=np.float32)
2702 result = autograd.constant_of_shape(x, 1.0)
2703
2704 np.testing.assert_array_almost_equal(tensor.to_numpy(result),
2705 y,
2706 decimal=5)
2707 # int32_zeros
2708 X = np.array([10, 6]).astype(np.int64)
2709 x = tensor.from_numpy(X)
2710 x.to_device(dev)
2711
2712 y = np.ones(X, dtype=np.int32)
2713 result = autograd.constant_of_shape(x, 1)
2714 np.testing.assert_array_almost_equal(tensor.to_numpy(result),
2715 y,
2716 decimal=5)
2717
2718 def test_constantOfShape_cpu(self):
2719 self.constantOfShape_test(cpu_dev)

Callers 2

Calls 1

to_deviceMethod · 0.45

Tested by

no test coverage detected