Skip to content
Closed
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
89 changes: 89 additions & 0 deletions test/onnx/expect/TestOperators.test_prelu.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
ir_version: 4
producer_name: "pytorch"
producer_version: "1.1"
graph {
node {
input: "weight"
output: "2"
op_type: "Unsqueeze"
attribute {
name: "axes"
ints: 1
ints: 2
type: INTS
}
}
node {
input: "input"
input: "2"
output: "3"
op_type: "PRelu"
}
name: "torch-jit-export"
initializer {
dims: 2
data_type: 1
name: "weight"
raw_data: "\000\000\200>\000\000\200>"
}
input {
name: "input"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 3
}
dim {
dim_value: 4
}
}
}
}
}
input {
name: "weight"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 2
}
}
}
}
}
output {
name: "3"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 3
}
dim {
dim_value: 4
}
}
}
}
}
}
opset_import {
version: 9
}
4 changes: 4 additions & 0 deletions test/onnx/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ def test_rrelu(self):
x = torch.randn(1, 2, 3, 4)
self.assertONNX(torch.nn.RReLU(), x)

def test_prelu(self):
x = torch.randn(1, 2, 3, 4)
self.assertONNX(torch.nn.PReLU(2), x)

def test_log_sigmoid(self):
x = torch.randn(1, 2, 3, 4)
self.assertONNX(torch.nn.LogSigmoid(), x)
Expand Down
4 changes: 4 additions & 0 deletions torch/onnx/symbolic_opset9.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ def squeeze(g, self, dim=None):


def prelu(g, self, weight):
if self.isCompleteTensor():
self_sizes = self.type().sizes()
if self_sizes and len(self_sizes) > 2:
weight = g.op("Unsqueeze", weight, axes_i=list(range(1, len(self_sizes) - 1)))
return g.op("PRelu", self, weight)


Expand Down