Skip to content

Commit 1aa2093

Browse files
author
Valery Chernov
committed
fix int16 overflow
1 parent e43242e commit 1aa2093

File tree

1 file changed

+1
-72
lines changed

1 file changed

+1
-72
lines changed

tests/python/relay/test_op_level2.py

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,73 +2159,7 @@ def get_conv2d_nchw(
21592159
out_dtype=out_dtype,
21602160
)
21612161

2162-
# def verify_by_ort(x_data, w_data, b_data, data_dtype, out):
2163-
# from onnx import helper, mapping, TensorProto
2164-
# from onnxruntime import backend as ort_bk
2165-
2166-
# def get_onnx_model(data_dtype, x_shape, w_shape, b_shape, out_shape):
2167-
# x_dtype = data_dtype
2168-
# w_dtype = "int8"
2169-
# b_dtype = "int32"
2170-
# x_proto_type = mapping.NP_TYPE_TO_TENSOR_TYPE[np.dtype(x_dtype)]
2171-
# w_proto_type = mapping.NP_TYPE_TO_TENSOR_TYPE[np.dtype(w_dtype)]
2172-
# b_proto_type = mapping.NP_TYPE_TO_TENSOR_TYPE[np.dtype(b_dtype)]
2173-
2174-
# y_dtype = "int32"
2175-
# y_proto_type = mapping.NP_TYPE_TO_TENSOR_TYPE[np.dtype(y_dtype)]
2176-
2177-
# input_nodes = [
2178-
# helper.make_tensor_value_info("x", x_proto_type, list(x_shape)),
2179-
# helper.make_tensor_value_info("w", w_proto_type, list(w_shape)),
2180-
# helper.make_tensor_value_info("B", b_proto_type, list(b_shape)),
2181-
# ]
2182-
# initializer = [
2183-
# helper.make_tensor("x_scale", TensorProto.FLOAT, [], [1.]),
2184-
# helper.make_tensor("x_zero_point", x_proto_type, [], [0]),
2185-
# helper.make_tensor("w_scale", TensorProto.FLOAT, [], [1.]),
2186-
# helper.make_tensor("w_zero_point", w_proto_type, [], [0]),
2187-
# helper.make_tensor("y_scale", TensorProto.FLOAT, [], [1.]),
2188-
# helper.make_tensor("y_zero_point", y_proto_type, [], [0]),
2189-
# ]
2190-
# input_names = [
2191-
# "x",
2192-
# "x_scale",
2193-
# "x_zero_point",
2194-
# "w",
2195-
# "w_scale",
2196-
# "w_zero_point",
2197-
# "y_scale",
2198-
# "y_zero_point",
2199-
# "B"
2200-
# ]
2201-
2202-
# node_conv = helper.make_node(
2203-
# "QLinearConv",
2204-
# inputs=input_names,
2205-
# outputs=["y"],
2206-
# )
2207-
2208-
# graph = helper.make_graph(
2209-
# [node_conv],
2210-
# "ort_conv2d_int8_test",
2211-
# inputs=input_nodes,
2212-
# initializer=initializer,
2213-
# outputs=[helper.make_tensor_value_info("y", y_proto_type, list(out_shape))],
2214-
# )
2215-
# model = helper.make_model(graph, producer_name="ort_conv2d_int8_test")
2216-
# return model
2217-
2218-
# onnx_model = get_onnx_model(data_dtype, x_data.shape, w_data.shape, b_data.shape, out.shape)
2219-
# ort_exec = ort_bk.prepare(onnx_model.SerializeToString(), "CPU")
2220-
# ort_out = ort_exec.run([x_data, w_data, b_data])
2221-
# # Unpack output if there's only a single value.
2222-
# if len(ort_out) == 1:
2223-
# ort_out = ort_out[0]
2224-
# if len(out) == 1:
2225-
# out = out[0]
2226-
# np.testing.assert_equal(out, ort_out)
2227-
2228-
I, O, H, W = 64, 64, 56, 56
2162+
I, O, H, W = 1, 1, 56, 56
22292163
kH = kW = 3
22302164

22312165
data_shape = (1, I, H, W)
@@ -2271,11 +2205,6 @@ def get_conv2d_nchw(
22712205

22722206
out = rt_mod.get_output(0).numpy()
22732207

2274-
# print("COMPARE ORT and OUT")
2275-
# verify_by_ort(data_np, weight_np, bias_np, data_dtype, out)
2276-
# print("COMPARE ORT and REF")
2277-
# verify_by_ort(data_np, weight_np, bias_np, data_dtype, ref)
2278-
22792208
np.testing.assert_equal(out, ref)
22802209

22812210

0 commit comments

Comments
 (0)