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
7 changes: 3 additions & 4 deletions ios/LibTorch.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef LibTorch_h
#define LibTorch_h

#include <torch/script.h>

#if TARGET_OS_IPHONE
#define AT_NNPACK_ENABLED() 1
#define USE_NNPACK ON
#undef CAFFE2_PERF_WITH_AVX512
#endif
15 changes: 8 additions & 7 deletions ios/LibTorch.podspec
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
Pod::Spec.new do |s|
s.name = 'LibTorch'
s.version = '0.0.1'
s.version = '0.0.2'
s.authors = 'PyTorch Team'
s.license = { :type => 'BSD' }
s.homepage = 'https://github.com/pytorch/pytorch'
s.source = { :http => 'http://ossci-macos.s3.amazonaws.com/libtorch_x86_arm64.zip' }
s.source = { :http => 'https://ossci-ios-build.s3.amazonaws.com/libtorch_ios_nightly_build.zip' }
s.summary = 'The PyTorch C++ library for iOS'
s.description = <<-DESC
The PyTorch C++ library for iOS.
DESC
s.default_subspec = 'Core'
s.subspec 'Core' do |ss|
ss.dependency 'LibTorch/Torch'
ss.source_files = 'src/*.{h,cpp,cc}'
ss.source_files = 'src/*.{h,cpp,c,cc}'
ss.public_header_files = ['src/LibTorch.h']
end
s.subspec 'Torch' do |ss|
Copy link
Contributor

Choose a reason for hiding this comment

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

qq: Curious if it's needed to introduce subspecs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically, just to modulelize the code, keep the C++ libraries as a seperate podspec. If people just want to use the raw C++ API, they could say pod Libtorch/Torch

ss.header_mappings_dir = 'install/include/'
ss.preserve_paths = 'install/include/**/*.{h,cpp,cc,c}'
ss.vendored_libraries = 'install/lib/libtorch.a'
ss.vendored_libraries = 'install/lib/*.a'
ss.libraries = ['c++', 'stdc++']
end
s.user_target_xcconfig = {
Expand All @@ -27,8 +27,9 @@ Pod::Spec.new do |s|
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++11',
'CLANG_CXX_LIBRARY' => 'libc++'
}
s.pod_target_xcconfig = { 'VALID_ARCHS' => 'x86_64 armv7s arm64' }
s.module_name='LibTorch'
s.module_map = 'src/framework.modulemap'
s.pod_target_xcconfig = {
'HEADER_SEARCH_PATHS' => '$(inherited) "$(PODS_ROOT)/LibTorch/install/include/"',
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: May like to reuse s.name everywhere like so:

Suggested change
'HEADER_SEARCH_PATHS' => '$(inherited) "$(PODS_ROOT)/LibTorch/install/include/"',
'HEADER_SEARCH_PATHS' => "$(inherited) \"$(PODS_ROOT)/#{s.name}/install/include/\"",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, actually this won't work, Cocoapods won't inline this #{s.name}, it'll just copies the content to the XCode settings

'VALID_ARCHS' => 'x86_64 armv7s arm64'
}
s.library = ['c++', 'stdc++']
end
4 changes: 0 additions & 4 deletions ios/framework.modulemap

This file was deleted.