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

Fix onnx import bugs #4750

Merged
merged 2 commits into from
Feb 11, 2020
Merged
Changes from 1 commit
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
14 changes: 11 additions & 3 deletions python/tvm/relay/frontend/onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ def _impl_v1(cls, inputs, attr, params):
msg = 'Value {} in attribute "auto_pad" of operator Conv is invalid.'
raise tvm.error.OpAttributeInvalid(msg.format(attr['auto_pad']))
attr.pop('auto_pad')
else:
sym_pad = True
padding = attr['pads']
for i in range(0, len(padding), 2):
sym_pad = sym_pad and padding[i] == padding[i + 1]

if sym_pad:
attr['pads'] = padding[0::2]

out = AttrCvt(
op_name=dimension_picker('conv'),
Expand Down Expand Up @@ -455,7 +463,7 @@ def _impl_v1(cls, inputs, attr, params):
for i in range(dims):
pad_width.append((pads[i], pads[i+dims]))
attr['pad_width'] = pad_width
pad_mode = attr.get('mode', 'constant').decode('utf-8')
pad_mode = attr.get('mode', b'constant').decode('utf-8')
if pad_mode in ['constant', 'edge', 'reflect']:
attr['pad_mode'] = pad_mode
attr.pop('mode', None)
Expand All @@ -478,7 +486,7 @@ def _impl_v2(cls, inputs, attr, params):
for i in range(dims):
pad_width.append((pads[i], pads[i+dims]))
attr['pad_width'] = pad_width
pad_mode = attr.get('mode', 'constant').decode('utf-8')
pad_mode = attr.get('mode', b'constant').decode('utf-8')
if pad_mode in ['constant', 'edge', 'reflect']:
attr['pad_mode'] = pad_mode
attr.pop('mode', None)
Expand Down Expand Up @@ -570,7 +578,7 @@ class DepthToSpace(OnnxOpConverter):
def _impl_v11(cls, inputs, attr, params):

block_size = int(attr['blocksize'])
mode = attr.get("mode", "DCR")
mode = attr.get('mode', b'DCR').decode('utf-8')
return _op.nn.depth_to_space(inputs[0], block_size, mode=mode)


Expand Down