Skip to content

Conversation

@BowenBao
Copy link
Collaborator

@BowenBao BowenBao commented Jun 4, 2019

  • Fix typo in torch/onnx/utils.py when looking up registered custom ops.
  • Add a simple test case
    1. Register custom op with TorchScript using cpp_extension.load_inline.
    2. Register custom op with torch.onnx.symbolic using register_custom_op_symbolic.
    3. Export model with custom op, and verify with Caffe2 backend.

@pytorchbot pytorchbot added the module: onnx Related to torch.onnx label Jun 4, 2019
@BowenBao BowenBao changed the title Fix onnx custom op export & add initial test case [ONNX] Fix onnx custom op export & add initial test case Jun 4, 2019
@jerryzh168 jerryzh168 requested a review from houseroad June 4, 2019 18:51
@pytorchbot pytorchbot added the module: build Build system issues label Jun 4, 2019
@BowenBao
Copy link
Collaborator Author

BowenBao commented Jun 5, 2019

hi @houseroad, I'm adding test case for custom op support, that requires JIT C++ extensions. The CI for caffe2_onnx_py2_gcc5_ubuntu16_04_test is throwing errors

Jun 05 00:05:25 > raise RuntimeError(message)
Jun 05 00:05:25 E RuntimeError: Error building extension 'custom_add': [1/2] c++ -MMD -MF main.o.d -DTORCH_EXTENSION_NAME=custom_add -DTORCH_API_INCLUDE_EXTENSION_H -isystem /var/lib/jenkins/.local/lib/python2.7/site-packages/torch/include -isystem /var/lib/jenkins/.local/lib/python2.7/site-packages/torch/include/torch/csrc/api/include -isystem /var/lib/jenkins/.local/lib/python2.7/site-packages/torch/include/TH -isystem /var/lib/jenkins/.local/lib/python2.7/site-packages/torch/include/THC -isystem /usr/local/include/python2.7 -D_GLIBCXX_USE_CXX11_ABI=1 -fPIC -std=c++11 -c /tmp/torch_extensions/custom_add/main.cpp -o main.o
Jun 05 00:05:25 E FAILED: main.o
Jun 05 00:05:25 E c++ -MMD -MF main.o.d -DTORCH_EXTENSION_NAME=custom_add -DTORCH_API_INCLUDE_EXTENSION_H -isystem /var/lib/jenkins/.local/lib/python2.7/site-packages/torch/include -isystem /var/lib/jenkins/.local/lib/python2.7/site-packages/torch/include/torch/csrc/api/include -isystem /var/lib/jenkins/.local/lib/python2.7/site-packages/torch/include/TH -isystem /var/lib/jenkins/.local/lib/python2.7/site-packages/torch/include/THC -isystem /usr/local/include/python2.7 -D_GLIBCXX_USE_CXX11_ABI=1 -fPIC -std=c++11 -c /tmp/torch_extensions/custom_add/main.cpp -o main.o
Jun 05 00:05:25 E In file included from /var/lib/jenkins/.local/lib/python2.7/site-packages/torch/include/torch/csrc/Device.h:3:0,
Jun 05 00:05:25 E from /var/lib/jenkins/.local/lib/python2.7/site-packages/torch/include/torch/csrc/api/include/torch/python.h:8,
Jun 05 00:05:25 E from /var/lib/jenkins/.local/lib/python2.7/site-packages/torch/include/torch/extension.h:6,
Jun 05 00:05:25 E from /tmp/torch_extensions/custom_add/main.cpp:1:
Jun 05 00:05:25 E /var/lib/jenkins/.local/lib/python2.7/site-packages/torch/include/torch/csrc/python_headers.h:9:20: fatal error: Python.h: No such file or directory
Jun 05 00:05:25 E compilation terminated.
Jun 05 00:05:25 E ninja: build stopped: subcommand failed.

Do you have suggestions on how to fix this?

@BowenBao BowenBao force-pushed the onnx_custom_ops_fix branch from fd07eca to 25da36b Compare June 8, 2019 06:18
@BowenBao
Copy link
Collaborator Author

BowenBao commented Jun 9, 2019

@pytorchbot retest this please

@BowenBao
Copy link
Collaborator Author

BowenBao commented Jun 9, 2019

@pytorchbot rebase this please

@jeffreyksmithjr jeffreyksmithjr added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jun 10, 2019
@jeffreyksmithjr
Copy link
Contributor

Requesting review from @dzhulgakov and/or @houseroad .

Copy link
Member

@houseroad houseroad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, I am adding/changing the onnx runtime ci.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these debug command?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed ... from the debug commands it seems the path /usr/local/include/python2.7 doesn't exist, that might be the reason why JIT compiler couldn't find Python.h file.

@BowenBao BowenBao force-pushed the onnx_custom_ops_fix branch from ce0ee89 to 42bbae7 Compare June 12, 2019 01:05
@BowenBao BowenBao force-pushed the onnx_custom_ops_fix branch from 42bbae7 to 1e3582d Compare June 24, 2019 20:00
@BowenBao BowenBao force-pushed the onnx_custom_ops_fix branch from 1e3582d to ec394c6 Compare July 2, 2019 21:07
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@houseroad has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Member

@houseroad houseroad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. It's fine to skip the custom op test in python 2, since py2 is approaching the end of its life.

@facebook-github-bot
Copy link
Contributor

@houseroad merged this pull request in 319ef3b.

xzhu1900 pushed a commit to xzhu1900/pytorch that referenced this pull request Jul 5, 2019
Summary:
- Fix typo in ```torch/onnx/utils.py``` when looking up registered custom ops.
- Add a simple test case
    1. Register custom op with ```TorchScript``` using ```cpp_extension.load_inline```.
    2. Register custom op with ```torch.onnx.symbolic``` using ```register_custom_op_symbolic```.
    3. Export model with custom op, and verify with Caffe2 backend.
Pull Request resolved: pytorch#21321

Differential Revision: D16101097

Pulled By: houseroad

fbshipit-source-id: 084f8b55e230e1cb6e9bd7bd52d7946cefda8e33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: build Build system issues module: onnx Related to torch.onnx open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants