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

Method _avg_pool_helper

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

Source from the content-addressed store, hash-verified

103 self._relu_helper(gpu_dev)
104
105 def _avg_pool_helper(self, dev):
106 x = tensor.Tensor(shape=(2, 3, 3, 3), device=dev)
107 x.gaussian(0.0, 1.0)
108 y = layer.AvgPool2d(3, 1, 2)(x)
109
110 # frontend
111 model = sonnx.to_onnx([x], [y])
112
113 # backend
114 sg_ir = sonnx.prepare(model, device=dev)
115 sg_ir.is_graph = True
116 y_t = sg_ir.run([x])
117
118 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
119 tensor.to_numpy(y_t[0]),
120 decimal=5)
121
122 def test_avg_pool_cpu(self):
123 self._avg_pool_helper(cpu_dev)

Callers 2

test_avg_pool_cpuMethod · 0.95
test_avg_pool_gpuMethod · 0.95

Calls 4

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

Tested by

no test coverage detected