From f943db15b640fd8d97bd6baaa7910c5a3d030fe0 Mon Sep 17 00:00:00 2001 From: jikechao Date: Sat, 9 Sep 2023 12:50:36 +0800 Subject: [PATCH 1/4] Update test_forward.py --- tests/python/frontend/oneflow/test_forward.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/frontend/oneflow/test_forward.py b/tests/python/frontend/oneflow/test_forward.py index cc9333cd03bd..17583b3c25d4 100644 --- a/tests/python/frontend/oneflow/test_forward.py +++ b/tests/python/frontend/oneflow/test_forward.py @@ -721,7 +721,7 @@ def forward(self, x): for device in ["llvm"]: verify_activation(model1, device=device) - # verify_activation(model2, device=device) # NO PASS + verify_activation(model2, device=device) verify_activation(model3, device=device) verify_activation(model4, device=device) verify_activation(model5, device=device) From afafd10e6dbf8068b44fff6ebc44b5e1032adc7d Mon Sep 17 00:00:00 2001 From: jikechao Date: Sat, 9 Sep 2023 12:52:32 +0800 Subject: [PATCH 2/4] fix a bug in softplus --- python/tvm/relay/frontend/oneflow.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/tvm/relay/frontend/oneflow.py b/python/tvm/relay/frontend/oneflow.py index 4f278d8249e8..ceb5da573999 100644 --- a/python/tvm/relay/frontend/oneflow.py +++ b/python/tvm/relay/frontend/oneflow.py @@ -1119,8 +1119,11 @@ class Softplus(OneFlowOpConverter): def _impl_v1(cls, inputs, attrs, params): data = inputs[0] data_dtype = infer_type(data).checked_type.dtype - data = _op.exp(data) + _expr.const(1, dtype=data_dtype) - return _op.log(data) + beta = _expr.const(int(inputs[1]), dtype=data_dtype) + threshold = int(inputs[2]) if inputs[2] else 20 + threshold_ = _op.full_like(data, fill_value=_expr.const(threshold)) + softplus_value = _op.log(_op.exp(data * beta) + _expr.const(1.0, dtype=data_dtype)) / beta + return _op.where(_op.greater(data * beta, threshold_), data, softplus_value) class Softsign(OneFlowOpConverter): From ce6bf304be2c53e74d0cf9886687386d5e38e9c5 Mon Sep 17 00:00:00 2001 From: jikechao Date: Sat, 9 Sep 2023 13:15:49 +0800 Subject: [PATCH 3/4] Update oneflow.py --- python/tvm/relay/frontend/oneflow.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/tvm/relay/frontend/oneflow.py b/python/tvm/relay/frontend/oneflow.py index ceb5da573999..7a713e5e15ee 100644 --- a/python/tvm/relay/frontend/oneflow.py +++ b/python/tvm/relay/frontend/oneflow.py @@ -1119,8 +1119,8 @@ class Softplus(OneFlowOpConverter): def _impl_v1(cls, inputs, attrs, params): data = inputs[0] data_dtype = infer_type(data).checked_type.dtype - beta = _expr.const(int(inputs[1]), dtype=data_dtype) - threshold = int(inputs[2]) if inputs[2] else 20 + beta = _expr.const(float(attrs.get("beta", 1.0))) + threshold = float(attrs.get("threshold", 20.0)) threshold_ = _op.full_like(data, fill_value=_expr.const(threshold)) softplus_value = _op.log(_op.exp(data * beta) + _expr.const(1.0, dtype=data_dtype)) / beta return _op.where(_op.greater(data * beta, threshold_), data, softplus_value) From 297329ab2367e034153c8f5be8bd016149828409 Mon Sep 17 00:00:00 2001 From: Qingchao Shen Date: Wed, 30 Oct 2024 10:14:32 +0800 Subject: [PATCH 4/4] Update entry.py --- python/tvm/script/parser/relax/entry.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/tvm/script/parser/relax/entry.py b/python/tvm/script/parser/relax/entry.py index 04a5f985643e..d36e802d06c9 100644 --- a/python/tvm/script/parser/relax/entry.py +++ b/python/tvm/script/parser/relax/entry.py @@ -262,6 +262,8 @@ def Tensor( vdevice: Optional[str] = None, ndim: int = -1, ) -> TensorProxy: + if shape is not None and isinstance(shape, int): + shape = [shape,] # scalar tensor case if shape is not None and not isinstance(shape, Var) and len(shape) == 0: shape = []