MCPcopy Create free account
hub / github.com/pytorch/pytorch / test_relu_graph

Method test_relu_graph

caffe2/python/onnx/tests/c2_ref_test.py:89–106  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

87 self.assertSameOutputs(output[0], np.array(x)[1:5, 0:4])
88
89 def test_relu_graph(self):
90 X = np.random.randn(3, 2).astype(np.float32)
91 Y_ref = np.clip(X, 0, np.inf)
92
93 node_def = make_node(
94 "Relu", ["X"], ["Y"])
95 output = c2.run_node(
96 node_def, {"X": X})
97 np.testing.assert_almost_equal(output.Y, Y_ref)
98
99 graph_def = make_graph(
100 [node_def],
101 name="test",
102 inputs=[make_tensor_value_info("X", onnx.TensorProto.FLOAT, [3, 2])],
103 outputs=[make_tensor_value_info("Y", onnx.TensorProto.FLOAT, [3, 2])])
104 c2_rep = c2.prepare(make_model(graph_def, producer_name='caffe2-ref-test'))
105 output = c2_rep.run(X)
106 np.testing.assert_almost_equal(output.Y, Y_ref)
107
108 def test_elementwiselinear(self):
109 X = np.random.randn(4, 2, 5, 7, 3).astype(np.float32)

Callers

nothing calls this directly

Calls 7

make_modelFunction · 0.85
astypeMethod · 0.80
clipMethod · 0.80
randnMethod · 0.45
run_nodeMethod · 0.45
prepareMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected