Skip to content

Commit f0f959c

Browse files
committed
some updates
1 parent bfdf6e8 commit f0f959c

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

_mobile/ios.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ for i in 0 ..< w * h {
7878
}
7979
```
8080

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]`.
8282

8383
#### TorchScript Module
8484

@@ -119,7 +119,7 @@ at::AutoNonVariableTypeMode non_var_type_mode(true);
119119
auto outputTensor = _impl.forward({tensor}).toTensor();
120120
float* floatBuffer = outputTensor.data_ptr<float>();
121121
```
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 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.
123123
124124
```cpp
125125
torch::autograd::AutoGradMode guard(false);
@@ -149,11 +149,17 @@ For more complex use cases, we recommend to check out the [PyTorch demo applicat
149149

150150
## Build PyTorch iOS Libraries from Source
151151

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.
153153

154-
### Setup Local Python Development Environment
154+
```
155+
git clone --recursive https://github.com/pytorch/pytorch
156+
cd pytorch
157+
# if you are updating an existing checkout
158+
git submodule sync
159+
git submodule update --init --recursive
160+
```
155161

156-
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
157163
158164
### Build LibTorch for iOS Simulators
159165

@@ -171,22 +177,22 @@ Open terminal and navigate to the PyTorch root directory. Run the following comm
171177
```
172178
BUILD_PYTORCH_MOBILE=1 IOS_ARCH=arm64 ./scripts/build_ios.sh
173179
```
174-
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`
175181

176182
### XCode Setup
177183

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.
179185

180186
In the build settings, search for **other linker flags**. Add a custom linker flag below
181187

182188
```
183-
-force_load $(PROJECT_DIR)/path-to-libtorch.a
189+
-force_load $(PROJECT_DIR)/${path-to-libtorch.a}
184190
```
185191
Finally, disable bitcode for your target by selecting the Build Settings, searching for **Enable Bitcode**, and set the value to **No**.
186192

187193
## API Docs
188194

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.
190196

191197
## Issues and Contribution
192198

0 commit comments

Comments
 (0)