mbrookhart commented on a change in pull request #8305:
URL: https://github.com/apache/tvm/pull/8305#discussion_r660676638
##########
File path: tests/python/frontend/onnx/test_forward.py
##########
@@ -4640,6 +4641,63 @@ def repeat(N, D):
)
+def verify_qlinearadd(a_shape, b_shape, c_shape):
+
+ a_array = np.random.random(a_shape).astype("float32")
+ b_array = np.random.random(b_shape).astype("float32")
+
+ input_nodes = [
+ helper.make_tensor_value_info("a", TensorProto.FLOAT, list(a_shape)),
+ helper.make_tensor_value_info("b", TensorProto.FLOAT, list(b_shape)),
+ ]
+ input_names = [
+ "a",
+ "b",
+ ]
+ input_values = [a_array, b_array]
+
+ node = helper.make_node("QLinearAdd", inputs=input_names, outputs=["C"])
+
+ node = helper.make_node("Add", ["a", "b"], ["C"])
+ graph = helper.make_graph(
+ [node],
+ "qlinearadd_test",
+ inputs=input_nodes,
+ outputs=[helper.make_tensor_value_info("C", TensorProto.FLOAT,
list(c_shape))],
+ )
+ model = helper.make_model(graph, producer_name="qlinearconv_test")
+ from onnxruntime.quantization import quantize_static,
CalibrationDataReader, QuantType
+
+ class RandomDataReader(CalibrationDataReader):
+ def __init__(self, n=10):
+ self.data = iter(
+ [
+ {
+ "a": np.random.random(a_shape).astype("float32"),
+ "b": np.random.random(b_shape).astype("float32"),
+ }
+ for _ in range(n)
+ ]
+ )
+
+ def get_next(self):
+ return next(self.data, None)
+
+ model_fp32 = "/tmp/model.onnx"
Review comment:
I couldn't figure out a way to create the op in memory. :( ONNX's python
helper throws a fit since it isn't a standard op, and onnx runtime's
quantization API demands files on disk. I wrote it to /tmp so it wouldn't stick
around.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]