Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xiaofeng sun #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
export TVM_HOME=/home/huawei/sxf_workdir/tvm
export PYTHONPATH=$TVM_HOME/python:${PYTHONPATH}
26 changes: 26 additions & 0 deletions python/tvm/relay/frontend/paddlepaddle.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,30 @@ def convert_concat(g, op, block):
out = _op.concatenate(inputs, axis=axis)
g.add_node(op.output("Out")[0], out)

def convert_mish(g,op,block):
"""Operator convert for mish."""
# print(f"!!!{op}")
x = g.get_node(op.input("X")[0])
dtype = infer_type(x).checked_type.dtype
threshold = op.attr("threshold")
threshold = _op.const(threshold,dtype)
lhs = x * _op.cast((x>threshold),dtype)
one = _expr.const(1.0,dtype=dtype)
rhs = _op.log(one+_op.exp(x))* _op.cast((x<=threshold),dtype)
softplus = lhs + rhs
out = x*_op.tanh(softplus)
g.add_node(op.output("Out")[0],out)

def convert_eye(g,op,block):
"""Operator convert for eye"""
num_rows = op.attr("num_rows")

num_columns = op.attr("num_columns")
dtype = op.attr("dtype")
dtype = _convert_dtype_value(dtype)
out = np.eye(num_rows,num_columns).astype(dtype)
out = _op.const(out,dtype=dtype)
g.add_node(op.output("Out")[0],out)

def convert_conv2d(g, op, block):
"""Operator converter for conv2d."""
Expand Down Expand Up @@ -2220,6 +2244,8 @@ def convert_where_index(g, op, block):
"transpose2": convert_transpose,
"unsqueeze2": convert_unsqueeze,
"where_index": convert_where_index,
"mish": convert_mish,
"eye": convert_eye,
}


Expand Down
Loading