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

Method _softplus_helper

test/python/test_onnx.py:1102–1121  ·  view source on GitHub ↗
(self, dev)

Source from the content-addressed store, hash-verified

1100 self._identity_helper(gpu_dev)
1101
1102 def _softplus_helper(self, dev):
1103 x = np.array([-0.9, -0.3, -0.1, 0.1, 0.5,
1104 0.9]).reshape(3, 2).astype(np.float32)
1105 x = tensor.from_numpy(x)
1106 x.to_device(dev)
1107
1108 y = autograd.softplus(x)
1109
1110 # frontend
1111 model = sonnx.to_onnx([x], [y])
1112 # print('The model is:\n{}'.format(model))
1113
1114 # backend
1115 sg_ir = sonnx.prepare(model, device=dev)
1116 sg_ir.is_graph = True
1117 y_t = sg_ir.run([x])
1118
1119 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
1120 tensor.to_numpy(y_t[0]),
1121 decimal=5)
1122
1123 def test_softplus_cpu(self):
1124 self._softplus_helper(cpu_dev)

Callers 2

test_softplus_cpuMethod · 0.95
test_softplus_gpuMethod · 0.95

Calls 4

prepareMethod · 0.80
reshapeMethod · 0.45
to_deviceMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected