Skip to content

Commit

Permalink
padsの仕様をまだ勘違いしてた
Browse files Browse the repository at this point in the history
  • Loading branch information
Masato Hori committed Apr 24, 2018
1 parent 2f5a87c commit 6ca06d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions python/src/nnabla/utils/converter/onnx/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def merge_broadcast(node, func, target_name, broadcast_target):
# multipler operators.
del broadcast_target[target_name]


def convert_to_nodes(func, variables, input_types, output_types, broadcast_target):
"""Convert a function to a node or a group of nodes"""
op_type = nnabla_function_type_to_onnx_optype.get(func.type)
Expand Down Expand Up @@ -110,7 +109,7 @@ def convert_to_nodes(func, variables, input_types, output_types, broadcast_targe
# Copy kernel, stride, and pads values
k = onnx.helper.make_attribute("kernel_shape", mpp.kernel.dim)
s = onnx.helper.make_attribute("strides", mpp.stride.dim)
p = onnx.helper.make_attribute("pads", np.repeat(mpp.pad.dim, 2))
p = onnx.helper.make_attribute("pads", mpp.pad.dim*2)
n.attribute.extend([k, s, p])
nl.append(n)
elif func.type == "Convolution":
Expand All @@ -134,7 +133,7 @@ def convert_to_nodes(func, variables, input_types, output_types, broadcast_targe
k = onnx.helper.make_attribute("kernel_shape", weight_shape.dim[weight_base:])
d = onnx.helper.make_attribute("dilations", cp.dilation.dim)
s = onnx.helper.make_attribute("strides", cp.stride.dim)
p = onnx.helper.make_attribute("pads", np.repeat(cp.pad.dim, 2))
p = onnx.helper.make_attribute("pads", cp.pad.dim*2)
g = onnx.helper.make_attribute("group", cp.group)
n.attribute.extend([k, d, s, p, g])
nl.append(n)
Expand Down Expand Up @@ -166,7 +165,7 @@ def convert_to_nodes(func, variables, input_types, output_types, broadcast_targe
# Copy kernel, stride, and pads values
k = onnx.helper.make_attribute("kernel_shape", app.kernel.dim)
s = onnx.helper.make_attribute("strides", app.stride.dim)
p = onnx.helper.make_attribute("pads", np.repeat(app.pad.dim, 2))
p = onnx.helper.make_attribute("pads", app.pad.dim*2)
n.attribute.extend([k, s, p])
nl.append(n)
elif func.type == "BatchNormalization":
Expand Down
5 changes: 2 additions & 3 deletions python/src/nnabla/utils/converter/onnx/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,8 @@ def check_padding(pads, dim):
different values for start/end per axis."""
padval = []
for i in range(dim):
ofs = i*2 # start and end for each axis
s = pads[ofs]
e = pads[ofs+1]
s = pads[i]
e = pads[i+dim]
if s != e:
raise ValueError("NNabla does not support different padding"
" for start and end of each axis")
Expand Down

0 comments on commit 6ca06d8

Please sign in to comment.