Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix clip unsqueeze opset implement
Browse files Browse the repository at this point in the history
cheng wen committed Feb 18, 2024
1 parent 94e83f2 commit b020fbd
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion python/tvm/relax/frontend/onnx/onnx_frontend.py
Original file line number Diff line number Diff line change
@@ -293,7 +293,7 @@ class Unsqueeze(OnnxOpConverter):
"""Converts an onnx Unsqueeze node into an equivalent Relax expression."""

@classmethod
def _impl_v11(cls, bb, inputs, attr, params):
def _impl_v1(cls, bb, inputs, attr, params):
axes = list(attr.get("axes"))
inputs = inputs + [relax.const(axes, "int64")]
return cls._impl_v13(bb, inputs, attr, params)
@@ -570,6 +570,15 @@ def _impl_v16(cls, bb, inputs, attr, params):
class Clip(OnnxOpConverter):
"""Converts an onnx Clip node into an equivalent Relax expression."""

@classmethod
def _impl_v1(cls, bb, inputs, attr, params):
min = float(attr.get("min", -_np.inf))
max = float(attr.get("max", _np.inf))
results = inputs[0]
results = bb.emit_te(topi.maximum, results, min)
results = bb.emit_te(topi.minimum, results, max)
return results

@classmethod
def _impl_v13(cls, bb, inputs, attr, params):
results = inputs[0]
2 changes: 2 additions & 0 deletions tests/python/relax/test_frontend_onnx.py
Original file line number Diff line number Diff line change
@@ -433,6 +433,7 @@ def test_unsqueeze():

model = helper.make_model(graph, producer_name="unsqueeze_test")
check_correctness(model)
check_correctness(model, opset=10)


def test_gelu():
@@ -488,6 +489,7 @@ def test_clip(min, max):

model = helper.make_model(graph, producer_name="clip_test")
check_correctness(model)
check_correctness(model, opset=10)


def test_equal():

0 comments on commit b020fbd

Please sign in to comment.