Skip to content
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
5 changes: 4 additions & 1 deletion onnx2pytorch/convert/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ def extract_attributes(node):
elif attr.name == "transA":
kwargs["transpose_activation"] = bool(extract_attr_values(attr))
elif attr.name == "value":
kwargs["constant"] = extract_attr_values(attr)
if node.op_type == "Pad":
kwargs["value"] = extract_attr_values(attr)
else:
kwargs["constant"] = extract_attr_values(attr)
elif attr.name == "value_float":
kwargs["constant"] = extract_attr_values(attr)
elif attr.name == "value_floats":
Expand Down
4 changes: 4 additions & 0 deletions onnx2pytorch/convert/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from torch import nn
from torch.jit import TracerWarning
from torch.nn.modules.linear import Identity
from torch.nn import Dropout

from onnx2pytorch.constants import (
COMPOSITE_LAYERS,
Expand Down Expand Up @@ -221,6 +222,9 @@ def forward(self, *input_list, **input_dict):
for out_op_id, output in zip(node.output, op(*in_activations)):
activations[out_op_id] = output
else:
if 'dropout' in out_op_id:
op = Dropout()

activations[out_op_id] = op(*in_activations)

# Remove activations that are no longer needed
Expand Down
7 changes: 5 additions & 2 deletions onnx2pytorch/operations/pad.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@


class Pad(Operator):
def __init__(self, mode="constant", padding=None):
def __init__(self, mode="constant", padding=None, value=0):
self.mode = mode
self.padding = padding
self.value = value
super().__init__()

def forward(self, input, pads=None, value=0):
def forward(self, input, pads=None, value=None):
if value is None:
value = self.value
if self.padding is not None:
pads = self.padding
elif pads is None:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ torchvision>=0.9.0
onnx>=1.6.0
onnxruntime>=1.5.0
numpy>=1.18.1
protobuf==3.20.0