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

Method _softsign_helper

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

Source from the content-addressed store, hash-verified

1128 self._softplus_helper(gpu_dev)
1129
1130 def _softsign_helper(self, dev):
1131 x = np.array([-0.9, -0.3, -0.1, 0.1, 0.5,
1132 0.9]).reshape(3, 2).astype(np.float32)
1133 x = tensor.from_numpy(x)
1134 x.to_device(dev)
1135
1136 y = autograd.softsign(x)
1137
1138 # frontend
1139 model = sonnx.to_onnx([x], [y])
1140 # print('The model is:\n{}'.format(model))
1141
1142 # backend
1143 sg_ir = sonnx.prepare(model, device=dev)
1144 sg_ir.is_graph = True
1145 y_t = sg_ir.run([x])
1146
1147 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
1148 tensor.to_numpy(y_t[0]),
1149 decimal=5)
1150
1151 def test_softsign_cpu(self):
1152 self._softsign_helper(cpu_dev)

Callers 2

test_softsign_cpuMethod · 0.95
test_softsign_gpuMethod · 0.95

Calls 4

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

Tested by

no test coverage detected