Skip to content

Commit

Permalink
Back out "[ONNX] Process const folding progressively when converts to…
Browse files Browse the repository at this point in the history
… ONNX (pytorch#54569)"

Summary: Original commit changeset: 833dac7c71f2

Test Plan:
```
buck test mode/dev //pytext/fb/assistant/lite/test:test -- --exact
'pytext/fb/assistant/lite/test:test - test_export_bytes_model_to_caffe2
(pytext.fb.assistant.lite.test.test.TestExport)'
```

Reviewed By: jeanm

Differential Revision: D28431840

fbshipit-source-id: 0f1d530034404421a5d51691173e1cc0ee16fdd6
  • Loading branch information
Meghan Lele authored and Kushashwa Shrimali committed May 18, 2021
1 parent dc37cd8 commit 3450669
Show file tree
Hide file tree
Showing 23 changed files with 781 additions and 671 deletions.
132 changes: 127 additions & 5 deletions test/onnx/expect/TestOperators.test_arange_dynamic.expect
Expand Up @@ -3,22 +3,144 @@ producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
node {
input: "0"
output: "1"
name: "Constant_0"
name: "Shape_0"
op_type: "Shape"
}
node {
output: "2"
name: "Constant_1"
op_type: "Constant"
attribute {
name: "value"
t {
dims: 10
data_type: 1
raw_data: "\000\000\240@\000\000\260@\000\000\300@\000\000\320@\000\000\340@\000\000\360@\000\000\000A\000\000\010A\000\000\020A\000\000\030A"
data_type: 7
raw_data: "\000\000\000\000\000\000\000\000"
}
type: TENSOR
}
}
node {
input: "1"
input: "2"
output: "3"
name: "Gather_2"
op_type: "Gather"
attribute {
name: "axis"
i: 0
type: INT
}
}
node {
input: "0"
output: "4"
name: "Shape_3"
op_type: "Shape"
}
node {
output: "5"
name: "Constant_4"
op_type: "Constant"
attribute {
name: "value"
t {
data_type: 7
raw_data: "\000\000\000\000\000\000\000\000"
}
type: TENSOR
}
}
node {
input: "4"
input: "5"
output: "6"
name: "Gather_5"
op_type: "Gather"
attribute {
name: "axis"
i: 0
type: INT
}
}
node {
output: "7"
name: "Constant_6"
op_type: "Constant"
attribute {
name: "value"
t {
data_type: 7
raw_data: "\005\000\000\000\000\000\000\000"
}
type: TENSOR
}
}
node {
input: "6"
input: "7"
output: "8"
name: "Add_7"
op_type: "Add"
}
node {
input: "3"
output: "10"
name: "Cast_8"
op_type: "Cast"
attribute {
name: "to"
i: 1
type: INT
}
}
node {
input: "8"
output: "11"
name: "Cast_9"
op_type: "Cast"
attribute {
name: "to"
i: 1
type: INT
}
}
node {
input: "10"
input: "11"
input: "14"
output: "13"
name: "Range_10"
op_type: "Range"
}
name: "torch-jit-export"
initializer {
data_type: 1
name: "14"
raw_data: "\000\000\000?"
}
input {
name: "0"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 5
}
dim {
dim_value: 3
}
dim {
dim_value: 2
}
}
}
}
}
output {
name: "1"
name: "13"
type {
tensor_type {
elem_type: 1
Expand Down
34 changes: 28 additions & 6 deletions test/onnx/expect/TestOperators.test_empty_like.expect
Expand Up @@ -3,23 +3,45 @@ producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
node {
input: "0"
output: "1"
name: "Constant_0"
op_type: "Constant"
name: "Shape_0"
op_type: "Shape"
}
node {
input: "1"
output: "2"
name: "ConstantOfShape_1"
op_type: "ConstantOfShape"
attribute {
name: "value"
t {
dims: 5
dims: 8
dims: 1
data_type: 1
raw_data: "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
raw_data: "\000\000\000\000"
}
type: TENSOR
}
}
name: "torch-jit-export"
input {
name: "0"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 5
}
dim {
dim_value: 8
}
}
}
}
}
output {
name: "1"
name: "2"
type {
tensor_type {
elem_type: 1
Expand Down
122 changes: 117 additions & 5 deletions test/onnx/expect/TestOperators.test_full.expect
Expand Up @@ -3,23 +3,135 @@ producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
node {
input: "0"
output: "1"
name: "Constant_0"
name: "Shape_0"
op_type: "Shape"
}
node {
output: "2"
name: "Constant_1"
op_type: "Constant"
attribute {
name: "value"
t {
data_type: 7
raw_data: "\000\000\000\000\000\000\000\000"
}
type: TENSOR
}
}
node {
input: "1"
input: "2"
output: "3"
name: "Gather_2"
op_type: "Gather"
attribute {
name: "axis"
i: 0
type: INT
}
}
node {
input: "0"
output: "4"
name: "Shape_3"
op_type: "Shape"
}
node {
output: "5"
name: "Constant_4"
op_type: "Constant"
attribute {
name: "value"
t {
dims: 3
dims: 4
data_type: 7
raw_data: "\001\000\000\000\000\000\000\000"
}
type: TENSOR
}
}
node {
input: "4"
input: "5"
output: "6"
name: "Gather_5"
op_type: "Gather"
attribute {
name: "axis"
i: 0
type: INT
}
}
node {
input: "3"
output: "7"
name: "Unsqueeze_6"
op_type: "Unsqueeze"
attribute {
name: "axes"
ints: 0
type: INTS
}
}
node {
input: "6"
output: "8"
name: "Unsqueeze_7"
op_type: "Unsqueeze"
attribute {
name: "axes"
ints: 0
type: INTS
}
}
node {
input: "7"
input: "8"
output: "9"
name: "Concat_8"
op_type: "Concat"
attribute {
name: "axis"
i: 0
type: INT
}
}
node {
input: "9"
output: "10"
name: "ConstantOfShape_9"
op_type: "ConstantOfShape"
attribute {
name: "value"
t {
dims: 1
data_type: 1
raw_data: "\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@"
raw_data: "\000\000\000@"
}
type: TENSOR
}
}
name: "torch-jit-export"
input {
name: "0"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 3
}
dim {
dim_value: 4
}
}
}
}
}
output {
name: "1"
name: "10"
type {
tensor_type {
elem_type: 1
Expand Down
34 changes: 28 additions & 6 deletions test/onnx/expect/TestOperators.test_full_like.expect
Expand Up @@ -3,23 +3,45 @@ producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
node {
input: "0"
output: "1"
name: "Constant_0"
op_type: "Constant"
name: "Shape_0"
op_type: "Shape"
}
node {
input: "1"
output: "2"
name: "ConstantOfShape_1"
op_type: "ConstantOfShape"
attribute {
name: "value"
t {
dims: 3
dims: 4
dims: 1
data_type: 1
raw_data: "\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@\000\000\000@"
raw_data: "\000\000\000@"
}
type: TENSOR
}
}
name: "torch-jit-export"
input {
name: "0"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 3
}
dim {
dim_value: 4
}
}
}
}
}
output {
name: "1"
name: "2"
type {
tensor_type {
elem_type: 1
Expand Down

0 comments on commit 3450669

Please sign in to comment.