You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _mobile/ios.md
+15-9Lines changed: 15 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@ for i in 0 ..< w * h {
78
78
}
79
79
```
80
80
81
-
The code might look weird at first glance, but it’ll make sense once we understand our model. The input data is a 3-channel RGB image of shape (3 x H x W), where H and W are expected to be at least 224. The image has to be loaded in to a range of [0, 1] and then normalized using mean = [0.485, 0.456, 0.406] and std = [0.229, 0.224, 0.225].
81
+
The code might look weird at first glance, but it’ll make sense once we understand our model. The input data is a 3-channel RGB image of shape (3 x H x W), where H and W are expected to be at least 224. The image has to be loaded in to a range of `[0, 1]` and then normalized using `mean = [0.485, 0.456, 0.406]` and `std = [0.229, 0.224, 0.225]`.
The C++ function `torch::from_blob` will create an input tensor from the pixel buffer. Note that the shape of the tensor is `{1,3,224,224}` which represents `NxCxWxH` as we discussed in above section.
122
+
The C++ function `torch::from_blob` will create an input tensor from the pixel buffer. Note that the shape of the tensor is `{1,3,224,224}` which represents `NxCxWxH` as we discussed in the above section.
123
123
124
124
```cpp
125
125
torch::autograd::AutoGradMode guard(false);
@@ -149,11 +149,17 @@ For more complex use cases, we recommend to check out the [PyTorch demo applicat
149
149
150
150
## Build PyTorch iOS Libraries from Source
151
151
152
-
To track the latest progress on mobile, we can always build the PyTorch iOS libraries from the source. Follow the steps below.
152
+
To track the latest updates for iOS, you can build the PyTorch iOS libraries from the source code.
Follow the PyTorch Github page to set up the Python environment. Make sure you have `cmake` and Python installed correctly on your local machine.
162
+
> Make sure you have `cmake` and Python installed correctly on your local machine. We recommend following the [Pytorch Github page](https://github.com/pytorch/pytorch) to set up the Python development environment
157
163
158
164
### Build LibTorch for iOS Simulators
159
165
@@ -171,22 +177,22 @@ Open terminal and navigate to the PyTorch root directory. Run the following comm
After the build succeed, all static libraries and header files will be generated under `build_ios/install`
180
+
After the build succeeds, all static libraries and header files will be generated under `build_ios/install`
175
181
176
182
### XCode Setup
177
183
178
-
Open your project in XCode, copy all the static libraries as well as header files to your project. Navigate to the project settings, set the value **Header Search Paths** to the path of header files you just copied in the first step.
184
+
Open your project in XCode, copy all the static libraries as well as header files to your project. Navigate to the project settings, set the value **Header Search Paths** to the path of header files you just copied.
179
185
180
186
In the build settings, search for **other linker flags**. Add a custom linker flag below
181
187
182
188
```
183
-
-force_load $(PROJECT_DIR)/path-to-libtorch.a
189
+
-force_load $(PROJECT_DIR)/${path-to-libtorch.a}
184
190
```
185
191
Finally, disable bitcode for your target by selecting the Build Settings, searching for **Enable Bitcode**, and set the value to **No**.
186
192
187
193
## API Docs
188
194
189
-
Currently, the iOS framework uses raw Pytorch C++ APIs directly. The C++ document can be found here https://pytorch.org/cppdocs/. To learn more about it, we recommend exploring the [C++ front-end tutorials](https://pytorch.org/tutorials/advanced/cpp_frontend.html) on PyTorch webpage. In the meantime, we're working on providing the Swift/Objective-C API wrappers to PyTorch.
195
+
Currently, the iOS framework uses the Pytorch C++ front-end APIs directly. The C++ document can be found here https://pytorch.org/cppdocs/. To learn more about it, we recommend exploring the [C++ front-end tutorials](https://pytorch.org/tutorials/advanced/cpp_frontend.html) on PyTorch webpage. In the meantime, we're working on providing the Swift/Objective-C API wrappers to PyTorch.
0 commit comments