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

Method test_tensor_inplace_api

test/python/test_tensor.py:191–208  ·  view source on GitHub ↗

tensor inplace methods alter internal state and also return self

(self)

Source from the content-addressed store, hash-verified

189 self.matmul_high_dim_helper(gpu_dev)
190
191 def test_tensor_inplace_api(self):
192 """ tensor inplace methods alter internal state and also return self
193 """
194 x = tensor.Tensor((3,))
195 y = x.set_value(1)
196 self.assertTrue(y is x)
197
198 x = tensor.Tensor((3,))
199 y = x.uniform(1, 2)
200 self.assertTrue(y is x)
201
202 x = tensor.Tensor((3,))
203 y = x.bernoulli(1)
204 self.assertTrue(y is x)
205
206 x = tensor.Tensor((3,))
207 y = x.gaussian(1, 2)
208 self.assertTrue(y is x)
209
210 def test_numpy_convert(self):
211 a = np.asarray([[1, 0, 0], [0, 1, 0]], dtype=np.int)

Callers

nothing calls this directly

Calls 5

set_valueMethod · 0.95
uniformMethod · 0.95
bernoulliMethod · 0.95
gaussianMethod · 0.95
TensorMethod · 0.80

Tested by

no test coverage detected