Skip to content

Commit

Permalink
Support Silu Operator for ONNX
Browse files Browse the repository at this point in the history
  • Loading branch information
hwangdeyu committed Jan 29, 2021
1 parent 35b8f35 commit b18ea98
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/onnx/test_pytorch_onnx_onnxruntime.py
Original file line number Diff line number Diff line change
Expand Up @@ -4346,6 +4346,18 @@ def forward(self, x):
dynamic_axes={'x': [1, 2]},
test_with_inputs=[y])

def test_silu(self):
class SiLUModel(torch.nn.Module):
def __init__(self):
super(SiLUModel, self).__init__()
self.silu = torch.nn.SiLU()

def forward(self, x):
return self.silu(x)

x = torch.randn(2, 3, 4)
self.run_test(SiLUModel(), (x))

def test_remainder(self):
class RemainderModel(torch.nn.Module):
def forward(self, input, other):
Expand Down
2 changes: 2 additions & 0 deletions torch/onnx/symbolic_opset9.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,8 @@ def prelu(g, self, weight):
weight = sym_help._unsqueeze_helper(g, weight, list(range(1, self_rank - 1)))
return g.op("PRelu", self, weight)

def silu(g, input):
return g.op('Mul', input, g.op('Sigmoid', input))

def relu(g, input):
return g.op("Relu", input)
Expand Down

0 comments on commit b18ea98

Please sign in to comment.