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

Method _max_pool_helper

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

Source from the content-addressed store, hash-verified

267 self._matmul_helper(gpu_dev)
268
269 def _max_pool_helper(self, dev):
270 x = tensor.Tensor(shape=(2, 3, 4, 4), device=dev)
271 x.gaussian(0.0, 1.0)
272 y = layer.MaxPool2d(2, 2, 0)(x)
273
274 # frontend
275 model = sonnx.to_onnx([x], [y])
276 # print('The model is:\n{}'.format(model))
277
278 # backend
279 sg_ir = sonnx.prepare(model, device=dev)
280 sg_ir.is_graph = True
281 y_t = sg_ir.run([x])
282
283 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
284 tensor.to_numpy(y_t[0]),
285 decimal=5)
286
287 def test_max_pool_cpu(self):
288 self._max_pool_helper(cpu_dev)

Callers 2

test_max_pool_cpuMethod · 0.95
test_max_pool_gpuMethod · 0.95

Calls 4

gaussianMethod · 0.95
TensorMethod · 0.80
prepareMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected