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: prototype_source/vulkan_workflow.rst
+8-4Lines changed: 8 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -102,7 +102,7 @@ Python script to save pretrained mobilenet_v2 to a file:
102
102
script_model = torch.jit.script(model)
103
103
torch.jit.save(script_model, "mobilenet2.pt")
104
104
105
-
PyTorch 1.7 Vulkan backend supports only float 32bit operators. The default model needs additional step that will optimize operators fusing
105
+
PyTorch 1.7 Vulkan backend supports only float 32bit operators. The default model needs additional step that will optimize operators fusing
106
106
107
107
::
108
108
@@ -112,6 +112,10 @@ PyTorch 1.7 Vulkan backend supports only float 32bit operators. The default mode
112
112
113
113
The result model can be used only on Vulkan backend as it contains specific to the Vulkan backend operators.
114
114
115
+
By default, ``optimize_for_mobile`` with ``backend='vulkan'`` rewrites the graph so that inputs are transferred to the Vulkan backend, and outputs are transferred to the CPU backend, therefore, the model can be run on CPU inputs and produce CPU outputs. To disable this, add the argument ``optimization_blocklist={MobileOptimizerType.VULKAN_AUTOMATIC_GPU_TRANSFER}`` to ``optimize_for_mobile``. (``MobileOptimizerType`` can be imported from ``torch.utils.mobile_optimizer``)
116
+
117
+
For more information, see the `torch.utils.mobile_optimizer` `API documentation <https://pytorch.org/docs/stable/mobile_optimizer.html>`_.
118
+
115
119
Using Vulkan backend in code
116
120
----------------------------
117
121
@@ -219,19 +223,19 @@ Or if you need only specific abi you can set it as an argument:
219
223
Add prepared model ``mobilenet2-vulkan.pt`` to test applocation assets:
By default, `optimize_for_mobile` will perform the following types of optimizations:
197
+
By default, for the CPU backend, `optimize_for_mobile` performs the following types of optimizations:
198
198
199
-
* Conv2D and BatchNorm fusion which folds Conv2d-BatchNorm2d into Conv2d;
199
+
* `Conv2D and BatchNorm fusion` which folds Conv2d-BatchNorm2d into Conv2d;
200
200
201
-
* Insert and fold prepacked ops which rewrites the model graph to replace 2D convolutions and linear ops with their prepacked counterparts.
201
+
* `Insert and fold prepacked ops` which rewrites the model graph to replace 2D convolutions and linear ops with their prepacked counterparts.
202
202
203
-
* ReLU and hardtanh fusion which rewrites graph by finding ReLU/hardtanh ops and fuses them together.
203
+
* `ReLU and hardtanh fusion` which rewrites graph by finding ReLU/hardtanh ops and fuses them together.
204
204
205
-
* Dropout removal which removes dropout nodes from this module when training is false.
205
+
* `Dropout removal` which removes dropout nodes from this module when training is false.
206
206
207
+
* `Conv packed params hoisting` which moves convolution packed params to the root module, so that the convolution structs can be deleted. This decreases model size without impacting numerics.
208
+
209
+
For the Vulkan backend,`optimize_for_mobile` performs the following type of optimization:
210
+
211
+
* `Automatic GPU transfer` which rewrites the graph so that moving input and output data to and from the GPU becomes part of the model.
212
+
213
+
Optimization types can be disabled by passing an optimization blocklist as an argument to `optimize_for_mobile`.
0 commit comments