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
7 changes: 5 additions & 2 deletions python/tvm/relay/frontend/oneflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(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)


class Softsign(OneFlowOpConverter):
Expand Down
2 changes: 1 addition & 1 deletion tests/python/frontend/oneflow/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down