jwfromm commented on a change in pull request #7519:
URL: https://github.com/apache/tvm/pull/7519#discussion_r583264216
##########
File path: tests/python/frontend/onnx/test_forward.py
##########
@@ -1867,6 +1867,23 @@ def verify_unary_ops(op, x, rtol=1e-5, atol=1e-5):
verify_unary_ops("Sigmoid", x)
verify_unary_ops("Softsign", x)
+ def verify_unary_ops_fp16(op, x, rtol=1e-5, atol=1e-5):
+ z = helper.make_node(op, ["in1"], ["out"])
+ graph = helper.make_graph(
+ [z],
+ "_test",
+ inputs=[
+ helper.make_tensor_value_info("in1", TensorProto.FLOAT16,
list(in_shape)),
+ ],
+ outputs=[helper.make_tensor_value_info("out", TensorProto.FLOAT16,
list(out_shape))],
+ )
+ model = helper.make_model(graph, producer_name="_test")
+ verify_with_ort_with_inputs(model, [x], rtol=rtol, atol=atol)
+
+ dtype = "float16"
+ x = np.random.uniform(size=in_shape).astype(dtype)
+ verify_unary_ops_fp16("Reciprocal", x)
+
Review comment:
I think you could pretty cleanly fuse this into `verify_unary_ops` by
adding an optional `dtype` argument. You can use
`mapping.NP_TYPE_TO_TENSOR_TYPE[np.dtype(dtype)]` to convert that dtype string
into the proper ONNX proto type.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]