Skip to content

Commit

Permalink
unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bfineran committed Jun 13, 2023
1 parent 177a4b3 commit 92b25ff
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,22 @@ def test_without_transpose(onnx_model: onnx.ModelProto):
]


def test_no_bias_changes_nothing(onnx_model: onnx.ModelProto):
def test_matmul_no_bias_converts(onnx_model: onnx.ModelProto):
# remove "bias" initializer and "add" node
assert onnx_model.graph.initializer.pop().name == "bias"
assert onnx_model.graph.node.pop().name == "add"
validate_onnx(onnx_model)

onnx_model = MatMulAddToMatMulIntegerAddCastMul().apply(onnx_model)
validate_onnx(onnx_model)
# NOTE: nothing changes
# converted model should have matmulinteger + rescale mul without bias add
assert [i.name for i in onnx_model.graph.initializer] == [
"x_scale",
"y_scale",
"zero_point",
"weight",
"matmul.weight_quantized",
"matmul_quant.rescale.scale",
]
assert [n.name for n in onnx_model.graph.node] == [
"input_dequant",
"weight_quant",
"weight_dequant",
"transpose",
"matmul",
"matmul_quant",
"matmul_bias_add_quant_cast",
"matmul_quant_rescale_mul",
]

0 comments on commit 92b25ff

Please sign in to comment.