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

Method _softmax_helper

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

Source from the content-addressed store, hash-verified

127 self._avg_pool_helper(gpu_dev)
128
129 def _softmax_helper(self, dev):
130 X = np.array([[-1, 0, 1]]).astype(np.float32)
131 x = tensor.from_numpy(X)
132 x.to_device(dev)
133 y = autograd.SoftMax()(x)[0]
134
135 # frontend
136 model = sonnx.to_onnx([x], [y])
137 # print('The model is:\n{}'.format(model))
138
139 # backend
140 sg_ir = sonnx.prepare(model, device=dev)
141 sg_ir.is_graph = True
142 y_t = sg_ir.run([x])
143 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
144 tensor.to_numpy(y_t[0]),
145 decimal=5)
146
147 def test_softmax_cpu(self):
148 self._softmax_helper(cpu_dev)

Callers 2

test_softmax_cpuMethod · 0.95
test_softmax_gpuMethod · 0.95

Calls 3

prepareMethod · 0.80
to_deviceMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected