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

Method testTensorFunc

java/src/test/java/org/apache/singa/TestTensor.java:33–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31 }
32
33 public void testTensorFunc() {
34 Shape s = new Shape(2);
35 s.set(0, 2);
36 s.set(1, 3);
37
38 Tensor t1 = new Tensor(s);
39 t1.SetFloatValue(0.1f);
40 Tensor t2 = singa_wrap.Square(t1);
41 float[] data = new float[6];
42
43 t2.GetFloatValue(data, 6);
44 for (int i = 0; i < 6; i++)
45 assertEquals(data[i], 0.01, 1e-4);
46
47 for (int i = 0; i < 6; i++)
48 data[i] = i * 1.0f;
49 Tensor t3 = new Tensor(s);
50 t3.CopyFloatDataFromHostPtr(data, 6);
51
52 t3.GetFloatValue(data, 6);
53 for (int i = 0; i < 6; i++)
54 assertEquals(data[i], i * 1.0f, 1e-4);
55 }
56}

Callers

nothing calls this directly

Calls 1

setMethod · 0.45

Tested by

no test coverage detected