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
*Author*: Chen Lai <https://github.com/cccclai>, Dhruv Matani <https://github.com/dhruvbird>
5
+
*저자*: Chen Lai <https://github.com/cccclai>, Dhruv Matani <https://github.com/dhruvbird>
6
6
7
-
.. warning::
8
-
Tracing-based selective build a prototype feature to minimize library size. Since the traced result relies on the model input and traced environment, if the tracer runs in a different environment than mobile interpreter, the operator list might be different from the actual used operator list and missing operators error might raise.
7
+
*역자*: Lee Jong Bub <https://github.com/bub3690>
8
+
9
+
10
+
.. 경고::
11
+
추적-기반 선택적 빌드는 라이브러리 사이즈를 줄이기 위한 프로토타입 기능입니다. 추적된 결과는 모델 입력과 추적된 환경에 의존합니다. 따라서, 만약 추적기가 모바일 인터프리터가 아닌 다른 환경에서 실행되면, 연산자 리스트가 실제 사용된 연산자 리스트와 다를 수 있고 빠진 연산자들이 오류를 발생시킬 수 있습니다.
9
12
10
13
Introduction
11
14
------------
12
15
16
+
이 튜토리얼은 모바일 인터프리터 사이즈를 더욱 더 최소화하기 위해, 모바일 인터프리터 빌드를 커스터마이즈하는 새로운 방법을 소개합니다. 컴파일된 이진 파일에 포함되는 연산자들을 목표 모델에 실제로 필요로 하는 집합만큼으로 제한합니다. 파이토치의 모바일 배포의 이진 파일 사이즈를 줄이는 기술입니다. 추적 기반 선택적 빌드는 모델을 특정 대표 입력값들과 함께 동작시킵니다, 그리고 어떤 연산자들이 호출되었는지 기록합니다. 그러면 빌드는 그 연산자들만 포함하게 됩니다.
13
17
14
-
This tutorial introduces a new way to custom build mobile interpreter to further optimize mobile interpreter size. It restricts the set of operators included in the compiled binary to only the set of operators actually needed by target models. It is a technique to reduce the binary size of PyTorch for mobile deployments. Tracing Based Selective Build runs a model with specific representative inputs, and records which operators were called. The build then includes just those operators.
15
18
16
19
17
-
Following are the processes to use tracing-based selective approach to build a custom mobile interpreter.
20
+
다음은 추적-기반 선택적 방법으로 커스텀 모바일 인터프리터를 제작하는 과정들입니다.
18
21
19
-
1. *Prepare model with bundled input*
22
+
1. *묶인 입력과 모델을 준비합니다*
20
23
21
24
.. code:: python
22
25
@@ -28,54 +31,54 @@ Following are the processes to use tracing-based selective approach to build a c
28
31
fromPILimport Image
29
32
from torchvision import transforms
30
33
31
-
#Step 1. Get the model
34
+
#단계 1. 모델을 가져옵니다.
32
35
model = torch.hub.load('pytorch/vision:v0.7.0', 'deeplabv3_resnet50', pretrained=True)
33
36
model.eval()
34
37
35
38
scripted_module = torch.jit.script(model)
36
-
#Export full jit version model (not compatible lite interpreter), leave it here for comparison
39
+
#비교를 위해, jit 전체 버전 모델을 출력합니다.(가벼운 인터프리터와는 호환되지 않습니다.)
37
40
scripted_module.save("deeplabv3_scripted.pt")
38
-
#Export lite interpreter version model (compatible with lite interpreter)
39
-
# path = "<base directory where models are stored>"
@@ -86,22 +89,22 @@ Following are the processes to use tracing-based selective approach to build a c
86
89
Android
87
90
-------
88
91
89
-
Get the Image Segmentation demo app in Android: https://github.com/pytorch/android-demo-app/tree/master/ImageSegmentation
92
+
이미지 영역 분할 Android 데모 App을 가져옵니다 : https://github.com/pytorch/android-demo-app/tree/master/ImageSegmentation
90
93
91
-
1. **Tracing-based build libtorch lite for android**: Build libtorch for android for all 4 android abis (``armeabi-v7a``, ``arm64-v8a``, ``x86``, ``x86_64``) by running
94
+
1. **Android를 위한 libtorch lite 추적-기반 빌드**: 모든 4 가지 Android abis(``armeabi-v7a``, ``arm64-v8a``, ``x86``, ``x86_64``)를 대상으로 libtorch를 빌드합니다.
if it will be tested on Pixel 4 emulator with ``x86``, use cmd ``BUILD_LITE_INTERPRETER=1 ./scripts/build_pytorch_android.sh x86`` to specify abi to save build time.
100
+
만약 ``x86`` 의 Pixel 4 emulator에서 테스트 된다면, cmd 에서 ``BUILD_LITE_INTERPRETER=1 ./scripts/build_pytorch_android.sh x86`` 사용하여, 빌드 시간을 절약하기 위해 abi를 명시해줍니다.
98
101
99
102
.. code-block:: bash
100
103
101
104
SELECTED_OP_LIST=${path}/deeplabv3_scripted.yaml TRACING_BASED=1 ./scripts/build_pytorch_android.sh x86
102
105
103
106
104
-
After the build finish, it will show the library path:
107
+
빌드가 끝난 후, 라이브러리 경로를 보여줄 것입니다 :
105
108
106
109
.. code-block:: bash
107
110
@@ -112,7 +115,7 @@ After the build finish, it will show the library path:
112
115
-rw-r--r-- 1 chenlai staff 13M Feb 11 11:48 /Users/chenlai/pytorch/android/pytorch_android/build/outputs/aar/pytorch_android-release.aar
113
116
-rw-r--r-- 1 chenlai staff 36K Feb 9 16:45 /Users/chenlai/pytorch/android/pytorch_android_torchvision/build/outputs/aar/pytorch_android_torchvision-release.aar
114
117
115
-
2. **Use the PyTorch Android libraries built from source in the ImageSegmentation app**: Create a folder `libs` in the path, the path from repository root will be `ImageSegmentation/app/libs`. Copy `pytorch_android-release` to the path ``ImageSegmentation/app/libs/pytorch_android-release.aar``. Copy `pytorch_android_torchvision` (downloaded from `Pytorch Android Torchvision Nightly <https://oss.sonatype.org/#nexus-search;quick~torchvision_android/>`_) to the path ``ImageSegmentation/app/libs/pytorch_android_torchvision.aar``. Update the `dependencies` part of ``ImageSegmentation/app/build.gradle`` to
118
+
2. **이미지 영역 분할 App 소스에서 빌드된 Pytorch Android 라이브러리를 사용합니다**: 경로에 `libs` 폴더를 만들고, 경로는 root 저장소로부터 `ImageSegmentation/app/libs` 가 됩니다. `pytorch_android-release` 를 경로 ``ImageSegmentation/app/libs/pytorch_android-release.aar`` 에 복사합니다. `pytorch_android_torchvision` (다운로드 : `Pytorch Android Torchvision Nightly <https://oss.sonatype.org/#nexus-search;quick~torchvision_android/>`_)를 경로 ``ImageSegmentation/app/libs/pytorch_android_torchvision.aar`` 에 복사합니다. ``ImageSegmentation/app/build.gradle`` 에서 `dependencies` 부분을 다음 코드와 같이 수정합니다 :
116
119
117
120
.. code:: gradle
118
121
@@ -131,7 +134,7 @@ After the build finish, it will show the library path:
2. **Remove Cocoapods from the project** (this step is only needed if you ran `pod install`):
168
+
2. **프로젝트에서 Cocoapods 제거합니다** (이 과정은 `pod install` 을 사용했을 때만 필요합니다):
167
169
168
170
169
171
.. code-block:: bash
170
172
171
173
pod deintegrate
172
174
173
175
174
-
3. **Link ImageSegmentation demo app with the custom built library**:
176
+
3. **이미지 영역 분할 데모 App을 커스텀 라이브러리들과 링크해줍니다**:
175
177
176
-
Open your project in XCode, go to your project Target’s **Build Phases - Link Binaries With Libraries**, click the **+** sign and add all the library files located in `build_ios/install/lib`. Navigate to the project **Build Settings**, set the value **Header Search Paths** to `build_ios/install/include` and **Library Search Paths** to `build_ios/install/lib`.
177
-
In the build settings, search for **other linker flags**. Add a custom linker flag below `-all_load`.
178
-
Finally, disable bitcode for your target by selecting the Build Settings, searching for Enable Bitcode, and set the value to **No**.
178
+
Xcode에서 프로젝트를 열고, 목표 프로젝트의 **Build Phases - Link Binaries With Libraries** 로 가서, **+** 기호를 클릭하고 `build_ios/install/lib` 에 위치한 모든 라이브러리 파일들을 추가합니다. 프로젝트 **Build Settings** 로 이동하여, **Header Search Paths** 에서 값을 `build_ios/install/include` 로 값을 설정하고 **Library Search Paths** 를 `build_ios/install/lib` 로 값을 설정합니다.
179
+
build settings에서, **other linker flags** 를 검색합니다. `-all_load` 아래에 커스텀 링커 플래그를 추가합니다.
180
+
마지막으로, 목표를 위해 Build Settings에서 bitcode를 사용하지 못하게 선택해야 합니다, Enable Bitcode를 검색하여, **No** 값으로 설정합니다.
179
181
180
-
181
-
4. **Build and test the app in Xcode.**
182
+
4. **Xcode에서 App을 빌드하고 테스트합니다**
182
183
183
184
184
185
185
186
Conclusion
186
187
----------
187
188
188
-
In this tutorial, we demonstrated a new way to custom build PyTorch's efficient mobile interpreter - tracing-based selective build, in an Android and iOS app.
189
-
190
-
We walked through an Image Segmentation example to show how to bundle inputs to a model, generated operator list by tracing the model with bundled input, and build a custom torch library from source with the operator list from tracing result.
189
+
이 튜토리얼에서는, Android와 iOS App에서 효율적인 Pyotorch 모바일 인터프리터를 커스텀 빌드하는 새로운 방법인 추적-기반 선택적 빌드를 시연했습니다.
191
190
192
-
The custom build is still under development, and we will continue improving its size in the future. Note, however, that the APIs are subject to change in future versions.
191
+
이미지 영역 분할 예제를 수행하며 모델에 들어갈 입력을 어떻게 묶는지 보여주었고, 묶인 입력과 모델을 추적함으로써 연산자 리스트를 생성했고, 추적된 결과의 연산자 리스트와 소스로 커스텀 torch 라이브러리를 빌드했습니다.
193
192
194
-
Thanks for reading! As always, we welcome any feedback, so please create an issue here <https://github.com/pytorch/pytorch/issues>`.
193
+
커스텀 빌드는 여전히 개발중이고, 앞으로 미래에도 계속 사이즈를 개선시킬 것입니다. 그러나, API들은 미래 version에 따라 종속된다는 것을 주의하세요.
195
194
196
-
Learn More
195
+
읽어주셔서 감사합니다! 언제나, 어떤 피드백이든 환영합니다. `<https://github.com/pytorch/pytorch/issues>`_ 에 이슈를 생성해주세요.
197
196
197
+
더 배우기
198
198
199
-
- To learn more about PyTorch Mobile, please refer to PyTorch Mobile Home Page <https://pytorch.org/mobile/home/>
199
+
- Pytorch 모바일에 대해 더 배우기 위해서는, Pytorch 모바일 홈페이지 `<https://pytorch.org/mobile/home/>`_ 를 참조해주세요.
200
200
201
-
* To learn more about Image Segmentation, please refer to the Image Segmentation DeepLabV3 on Android Recipe <https://tutorials.pytorch.kr/beginner/deeplabv3_on_android.html>_
201
+
* 이미지 영역 분할에 대해 더 배우려면, Andorid Recipe의 Image Segmentation DeepLabV3를 참조해주세요 `<https://tutorials.pytorch.kr/beginner/deeplabv3_on_android.html>`_
0 commit comments