Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions python/tvm/relax/frontend/onnx/onnx_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,18 +374,18 @@ def _impl_v13(cls, bb, inputs, attr, params):

# Compute Y = alpha * A X B + beta * C

if alpha is not None:
A = bb.normalize(relax.op.multiply(A, relax.const(alpha, dtype=dtype)))
if alpha is not None and alpha != 1.0:
A = relax.op.multiply(A, relax.const(alpha, dtype=dtype))

if transA:
A = relax.op.permute_dims(A, [1, 0])
if transB:
B = relax.op.permute_dims(B, [1, 0])
Y = bb.normalize(relax.op.matmul(A, B))
Y = relax.op.matmul(A, B)

if C is not None:
if beta is not None:
C = bb.normalize(relax.op.multiply(C, relax.const(beta, dtype=dtype)))
if beta is not None and beta != 1.0:
C = relax.op.multiply(C, relax.const(beta, dtype=dtype))
Y = relax.op.add(Y, C)

return Y
Expand Down
4 changes: 2 additions & 2 deletions tests/python/relax/test_frontend_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ def _verify_gather(data_shape, indices, out_shape, axis=0):
_verify_gather([3, 3], [[0, 2]], [3, 1, 2], 1)


@pytest.mark.parametrize("alpha", [None, 0.25])
@pytest.mark.parametrize("beta", [None, 0.35])
@pytest.mark.parametrize("alpha", [None, 0.25, 1.0])
@pytest.mark.parametrize("beta", [None, 0.35, 1.0])
@pytest.mark.parametrize("useC", [False, True])
def test_gemm(alpha, beta, useC):
if useC:
Expand Down