Add Upsample example for torch onnx exporting

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/10550

Reviewed By: orionr

Differential Revision: D9541932

Pulled By: houseroad

fbshipit-source-id: 4d179d189c176482ae919e5cc74607b9d315ed26
This commit is contained in:
Lu Fang
2018-08-28 11:35:33 -07:00
committed by Facebook Github Bot
parent 22c9bc3117
commit 5ed62ea6fa
2 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,71 @@
ir_version: 3
producer_name: "pytorch"
producer_version: "0.4"
graph {
node {
input: "0"
output: "1"
op_type: "Upsample"
attribute {
name: "mode"
s: "bilinear"
type: STRING
}
attribute {
name: "scales"
floats: 1
floats: 1
floats: 2
floats: 2
type: FLOATS
}
}
name: "torch-jit-export"
input {
name: "0"
type {
tensor_type {
elem_type: FLOAT
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 3
}
dim {
dim_value: 4
}
}
}
}
}
output {
name: "1"
type {
tensor_type {
elem_type: FLOAT
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 6
}
dim {
dim_value: 8
}
}
}
}
}
}
opset_import {
version: 7
}

View File

@ -416,6 +416,10 @@ class TestOperators(TestCase):
x = Variable(torch.randn(1, 2, 3, 4), requires_grad=True)
self.assertONNX(lambda x: x.norm(dim=2), (x))
def test_upsample(self):
x = Variable(torch.randn(1, 2, 3, 4), requires_grad=True)
self.assertONNX(lambda x: nn.functional.interpolate(x, scale_factor=2., mode='bilinear'), x)
def test_symbolic_override(self):
"""Lifted from fast-neural-style: custom implementation of instance norm
to be mapped to ONNX operator"""