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

Add padding mode support for conv/pool2d #3

Merged
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
Prev Previous commit
Next Next commit
support 4 two-tuples
wjj19950828 committed Aug 5, 2021
commit 1967d461ddf82d7b12854cf33e3fb1d075ab532b
10 changes: 10 additions & 0 deletions python/tvm/relay/frontend/paddlepaddle.py
Original file line number Diff line number Diff line change
@@ -138,6 +138,11 @@ def convert_conv2d(g, op, block):
pad_h = _get_pad_size(in_h, (k_h - 1) * dilations[0] + 1, strides[0])
pad_w = _get_pad_size(in_w, (k_w - 1) * dilations[1] + 1, strides[1])
paddings = [pad_h[0], pad_w[0], pad_h[1], pad_w[1]]
elif padding_algorithm == "EXPLICIT":
if len(paddings) == 2:
paddings = [paddings[0],paddings[1],paddings[0],paddings[1]]
if len(paddings) == 4:
paddings = [paddings[0],paddings[2],paddings[1],paddings[3]]
else:
msg = 'Value {} in attribute "padding" of operator Conv is not ' "valid."
raise tvm.error.OpAttributeInvalid(msg.format(padding_algorithm))
@@ -499,6 +504,11 @@ def convert_pool2d(g, op, block):
pad_h = _get_pad_size(in_h, ksize[0], strides[0])
pad_w = _get_pad_size(in_w, ksize[1], strides[1])
paddings = [pad_h[0], pad_w[0], pad_h[1], pad_w[1]]
elif padding_algorithm == "EXPLICIT":
if len(paddings) == 2:
paddings = [paddings[0],paddings[1],paddings[0],paddings[1]]
if len(paddings) == 4:
paddings = [paddings[0],paddings[2],paddings[1],paddings[3]]
else:
msg = 'Value {} in attribute "padding" of operator Pool2d is not ' "valid."
raise tvm.error.OpAttributeInvalid(msg.format(padding_algorithm))