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: 9 additions & 1 deletion python/tvm/relay/frontend/onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,13 @@ def _impl_v1(cls, inputs, attr, params):
reps = attr.pop('repeats') # The number of times repeating the tensor data.
return _op.tile(inputs[0], reps)

class Erf(OnnxOpConverter):
"""Operator converter for Erf
"""
@classmethod
def _impl_v1(cls, inputs, attr, params):
return _op.erf(inputs[0])


# compatible operators that do NOT require any conversion.
_identity_list = []
Expand Down Expand Up @@ -1015,7 +1022,8 @@ def _get_convert_map(opset):
'Equal': Equal.get_converter(opset),
'Not': Not.get_converter(opset),
'And': And.get_converter(opset),
'Tile': Tile.get_converter(opset)
'Tile': Tile.get_converter(opset),
'Erf': Erf.get_converter(opset)
}


Expand Down
19 changes: 19 additions & 0 deletions tests/python/frontend/onnx/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import onnx
from onnx import helper, TensorProto
import unittest
import scipy

def get_tvm_output(graph_def, input_data, target, ctx, output_shape=None, output_dtype='float32'):
""" Generic function to execute and get tvm output"""
Expand Down Expand Up @@ -1225,6 +1226,23 @@ def test_tile():
z = np.tile(x, repeats)
verify_tile(x, z, repeats=repeats)

def verify_erf(indata, outdata):
node = helper.make_node('Erf', inputs=['in'], outputs=['out'])
graph = helper.make_graph([node],
'erf_test',
inputs=[helper.make_tensor_value_info('in', TensorProto.FLOAT, list(indata.shape))],
outputs=[helper.make_tensor_value_info('out', TensorProto.FLOAT, list(outdata.shape))])
model = helper.make_model(graph, producer_name='erf_test')

for target, ctx in ctx_list():
tvm_out = get_tvm_output(model, [indata], target, ctx, outdata.shape)
tvm.testing.assert_allclose(outdata, tvm_out)

def test_erf():
x = np.random.rand(2, 3, 4, 6).astype(np.float32)
z = scipy.special.erf(x)
verify_erf(x, z)


if __name__ == '__main__':
test_flatten()
Expand Down Expand Up @@ -1272,3 +1290,4 @@ def test_tile():
test_not()
test_and()
test_tile()
test_erf()