pytorch
56ab94d6 - [Vulkan][TCC] Add tests for quantized convolution with QUInt8 activation, weights and bias (#90012)

Commit
2 years ago
[Vulkan][TCC] Add tests for quantized convolution with QUInt8 activation, weights and bias (#90012) Summary: - Registered vulkan_prepack::create_qconv2d_context to the QuantizedCPU backend. - Registered vulkan_prepack::run_qconv2d_context to the Vulkan backend. - Added function test_quantized_conv2d, in order to test Vulkan Quantized Conv2d with QUInt8 activation, weight and bias (all QUInt8). - Added multiples tests for vulkan quantized conv2d (regular, depthwise and pointwise). All these tests make use of the test_quantized_conv2d function. This function tests the correctness of vulkan quantized conv2d, by comparing the following two processes: (we start with randomly generated float cpu tensors) - random float cpu tensors -> to vulkan -> quantize them -> apply vulkan conv2d quantized op -> dequantize result -> to cpu - random float cpu tensors -> quantize them -> dequantize -> apply cpu floating point conv2d op on dequantized tensors -> quantize result -> dequantize This function takes three boolean flags that modify its behavior: - prepacking: - if false, then we directly call at::native::vulkan::ops::quantized_conv2d - if true, then we call vulkan_prepack::create_qconv2d_context and vulkan_prepack::run_qconv2d_context. - compute_quantization_params & random_quantization_params: - if both are false, all quantization params are fixed (given as input) - if compute_quantization_params is true, all params are computed - if random_quantization_params is true, the input params are random and the output params are computed. (compute_quantization_params takes precedence over random_quantization_params) Test Plan: On Mac ``` cd ~/fbsource buck1 run -c pt.vulkan_full_precision=1 //xplat/caffe2:pt_vulkan_quantized_api_test_binAppleMac\#macosx-arm64 ``` On Android ``` cd ~/fbsource buck1 build -c ndk.custom_libcxx=false -c pt.enable_qpl=0 -c pt.vulkan_full_precision=1 //xplat/caffe2:pt_vulkan_quantized_api_test_binAndroid\#android-arm64 --show-output adb push buck-out/gen/xplat/caffe2/pt_vulkan_quantized_api_test_binAndroid\#android-arm64 /data/local/tmp/vulkan_quantized_api_test adb shell "/data/local/tmp/vulkan_quantized_api_test" ``` Reviewed By: SS-JIA Differential Revision: D41047096 Pull Request resolved: https://github.com/pytorch/pytorch/pull/90012 Approved by: https://github.com/salilsdesai
Committer
Parents
Loading