Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pytorch-iOS] remove ONNX & Turn on NO_API for mobile build #23546

Closed
wants to merge 12 commits into from
Closed

[Pytorch-iOS] remove ONNX & Turn on NO_API for mobile build #23546

wants to merge 12 commits into from

Conversation

xta0
Copy link
Contributor

@xta0 xta0 commented Jul 30, 2019

Summary

The iOS build was broken after this PR 馃憠 23195 was merged, as there are two files still have dependency on ONNX.

  • test.cpp in test/cpp/jit
  • export.cpp in torch/csrc/jit

This PR is to remove ONNX completely from mobile build.

Test plan

  • The build_ios.sh finished successfully.
  • The libtorch.a can be compiled and run on iOS devices

@xta0 xta0 requested review from orionr, dzhulgakov and ljk53 July 30, 2019 04:30
@pytorchbot pytorchbot added caffe2 module: build Build system issues labels Jul 30, 2019
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.

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

@@ -460,6 +460,11 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
${TORCH_ROOT}/test/cpp/jit/test.cpp
)

if (INTERN_BUILD_MOBILE)
list(REMOVE_ITEM TORCH_SRCS ${TORCH_SRC_DIR}/csrc/jit/export.cpp)
Copy link
Collaborator

Choose a reason for hiding this comment

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

REMOVE_ITEM is a bit magical, can we instead just add it only if the opposite condition is true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean something like this?

  if (NOT INTERN_BUILD_MOBILE)
    list(APPEND TORCH_SRCS ${TORCH_SRC_DIR}/csrc/jit/export.cpp)
    list(APPEND TORCH_SRCS ${TORCH_ROOT}/test/cpp/jit/test.cpp)
  endif()

list(APPEND TORCH_SRCS ${TORCH_SRC_DIR}/csrc/jit/fuser/cpu/fused_kernel.cpp)
endif()
endif()

if (NOT WIN32 AND NOT INTERN_BUILD_MOBILE)
Copy link
Contributor

Choose a reason for hiding this comment

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

delete the empty block?

if (NOT INTERN_BUILD_MOBILE)
list(APPEND TORCH_SRCS ${TORCH_SRC_DIR}/csrc/jit/export.cpp)
list(APPEND TORCH_SRCS ${TORCH_ROOT}/test/cpp/jit/test.cpp)
if(NOT WIN32)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: if (NOT WIN32)

@@ -497,7 +501,9 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
install(TARGETS caffe2_nvrtc DESTINATION "${TORCH_INSTALL_LIB_DIR}")
endif()

if (NOT NO_API)
if (INTERN_BUILD_MOBILE)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need both INTERN_BUILD_MOBILE and NO_API here? can we use one and drop the other? e.g.:
option 1: keep NO_API and set it automatically in master CMakeLists.txt for mobile build; use if (NOT NO_API) ... else() ...;
option 2: drop NO_API and use if (INTERN_BUILD_MOBILE) ... else () ...;

"csrc/api/src/jit.cpp" is already listed on line 432, so we should be able to directly set NO_API in master CMakeLists for mobile build.

Copy link
Contributor

Choose a reason for hiding this comment

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

And can we make NO_API change a separate PR our rename this PR to better reflect your change.

You can use ghstack to maintain a stack of local diffs / PRs.

Copy link
Contributor Author

@xta0 xta0 Jul 30, 2019

Choose a reason for hiding this comment

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

There is one file - output-archive.cpp that depends on export.h is included via this NO_API flag.

And can we make NO_API change a separate PR our rename this PR to better reflect your change.

Yea, let's open another PR for this NO_API change

do we need both INTERN_BUILD_MOBILE and NO_API here? can we use one and drop the other? e.g.:
option 1: keep NO_API and set it automatically in master CMakeLists.txt for mobile build; use if (NOT NO_API) ... else() ...;
option 2: drop NO_API and use if (INTERN_BUILD_MOBILE) ... else () ...;

"csrc/api/src/jit.cpp" is already listed on line 432, so we should be able to directly set NO_API in master CMakeLists for mobile build.

Actually I'm thinking if we can get rid of this jit.cpp, cuz there is only one function in this file. I've searched this symbol in the codebase, looks like no other cpp files use it. I'll double check

@xta0 xta0 changed the title [Pytorch-iOS] fix iOS build & remove ONNX for mobile build [Pytorch-iOS] remove ONNX & Turn on NO_API for mobile build Jul 30, 2019
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.

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

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.

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

@facebook-github-bot
Copy link
Contributor

@xta0 merged this pull request in 87a75bd.

@xsacha
Copy link
Contributor

xsacha commented Aug 1, 2019

Is this PR related to the latest Windows nightlies no longer having ONNX?

@dzhulgakov
Copy link
Collaborator

@xsacha - what exactly are you referring to by "no longer having ONNX"? from code it doesn't seem like it'd affect windows, but might make sense to investigate

@xsacha
Copy link
Contributor

xsacha commented Aug 1, 2019

Latest nightlies in the past 2 days at least are missing it.

@bddppq
Copy link
Contributor

bddppq commented Aug 1, 2019

@xsacha Which onnx files are you referring to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants