From 6d147c3fb8f4b18894caf167dbbf2b7b514ee2ca Mon Sep 17 00:00:00 2001 From: valmat07 Date: Thu, 18 Aug 2022 15:49:56 +0300 Subject: [PATCH 01/30] Add opencl target in test build script --- tests/scripts/task_config_build_gpu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/scripts/task_config_build_gpu.sh b/tests/scripts/task_config_build_gpu.sh index f79076e213cb..5163a16da3cd 100755 --- a/tests/scripts/task_config_build_gpu.sh +++ b/tests/scripts/task_config_build_gpu.sh @@ -28,6 +28,7 @@ echo set\(USE_CUDNN ON\) >> config.cmake echo set\(USE_CUDA ON\) >> config.cmake echo set\(USE_VULKAN ON\) >> config.cmake echo set\(USE_OPENGL ON\) >> config.cmake +echo set\(USE_OPENCL ON\) >> config.cmake echo set\(USE_MICRO ON\) >> config.cmake echo set\(USE_MICRO_STANDALONE_RUNTIME ON\) >> config.cmake echo set\(USE_LLVM \"/usr/bin/llvm-config-9 --link-static\"\) >> config.cmake From 2730ecc5de9dac635ca315c2414bef1ff9c42dc9 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Thu, 18 Aug 2022 20:40:24 +0300 Subject: [PATCH 02/30] Fix fp16 test and compile test for opencl --- tests/python/driver/tvmc/test_compiler.py | 3 ++- tests/python/unittest/test_target_codegen_vulkan.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/python/driver/tvmc/test_compiler.py b/tests/python/driver/tvmc/test_compiler.py index 27cd78d436c7..5535fc02249f 100644 --- a/tests/python/driver/tvmc/test_compiler.py +++ b/tests/python/driver/tvmc/test_compiler.py @@ -367,8 +367,9 @@ def test_compile_opencl(tflite_mobilenet_v1_0_25_128): tvmc_model = tvmc.load(tflite_mobilenet_v1_0_25_128) tvmc_package = tvmc.compile( tvmc_model, - target="opencl --host=llvm", + target="opencl -host=llvm", desired_layout="NCHW", + dump_code="asm", ) dumps_path = tvmc_package.package_path + ".asm" diff --git a/tests/python/unittest/test_target_codegen_vulkan.py b/tests/python/unittest/test_target_codegen_vulkan.py index 73e840208549..4dcd87f39b7c 100644 --- a/tests/python/unittest/test_target_codegen_vulkan.py +++ b/tests/python/unittest/test_target_codegen_vulkan.py @@ -16,6 +16,7 @@ # under the License. import os +from posixpath import split import random import re import threading @@ -91,6 +92,11 @@ def test_array_copy(dev, dtype, fuzz_seed): def test_array_vectorize_add(target, dev, dtype): arr_size = 64 lanes = 2 + + if "opencl" in target and dtype == "float16": + pytest.xfail( + "Opencl target does not support float16" + ) num_thread = 8 From bb48962b2a7e82a759213b567b75ce6cd13453aa Mon Sep 17 00:00:00 2001 From: valmat07 Date: Thu, 18 Aug 2022 23:20:20 +0300 Subject: [PATCH 03/30] fix lint --- tests/python/unittest/test_target_codegen_vulkan.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/python/unittest/test_target_codegen_vulkan.py b/tests/python/unittest/test_target_codegen_vulkan.py index 4dcd87f39b7c..76cad250e053 100644 --- a/tests/python/unittest/test_target_codegen_vulkan.py +++ b/tests/python/unittest/test_target_codegen_vulkan.py @@ -92,11 +92,8 @@ def test_array_copy(dev, dtype, fuzz_seed): def test_array_vectorize_add(target, dev, dtype): arr_size = 64 lanes = 2 - if "opencl" in target and dtype == "float16": - pytest.xfail( - "Opencl target does not support float16" - ) + pytest.xfail("Opencl target does not support float16") num_thread = 8 From 3a01e4191e2f7c37a78de4ac16f0e2f9b249e92c Mon Sep 17 00:00:00 2001 From: valmat07 Date: Fri, 19 Aug 2022 16:18:12 +0300 Subject: [PATCH 04/30] Fix relay OpenCL texture tests --- .../python/relay/test_conv2d_nchw_texture.py | 99 +++++++------------ .../python/relay/test_conv2d_nhwc_texture.py | 85 ++++++---------- .../test_depthwise_conv2d_nchw_texture.py | 25 ++--- .../test_depthwise_conv2d_nhwc_texture.py | 31 +++--- tests/scripts/task_config_build_gpu.sh | 1 + 5 files changed, 84 insertions(+), 157 deletions(-) diff --git a/tests/python/relay/test_conv2d_nchw_texture.py b/tests/python/relay/test_conv2d_nchw_texture.py index 58590998fdd2..730aa7efdd38 100644 --- a/tests/python/relay/test_conv2d_nchw_texture.py +++ b/tests/python/relay/test_conv2d_nchw_texture.py @@ -23,12 +23,11 @@ from tvm.contrib import utils from utils.adreno_utils import gpu_preprocess, build_run_compare +dtype = tvm.testing.parameter("float32") @tvm.testing.requires_opencl -def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad(target, dtype): input_shape = (1, 32, 42, 42) filter_shape = (96, 32, 3, 3) bias_shape = (1, 96, 1, 1) @@ -67,10 +66,8 @@ def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad(): @tvm.testing.requires_opencl -def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad_pass(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad_pass(target, dtype): input_shape = (1, 32, 40, 40) filter_shape = (96, 32, 2, 2) bias_shape = (1, 96, 1, 1) @@ -109,10 +106,8 @@ def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad_pass(): @tvm.testing.requires_opencl -def test_conv2d_inceptionv3_35_35_strides(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_inceptionv3_35_35_strides(target, dtype): input_shape = (1, 48, 35, 35) filter_shape = (64, 48, 5, 5) bias_shape = (1, 64, 1, 1) @@ -151,10 +146,8 @@ def test_conv2d_inceptionv3_35_35_strides(): @tvm.testing.requires_opencl -def test_conv2d_resnet50_v2_nchw_3c(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_resnet50_v2_nchw_3c(target, dtype): input_shape = (1, 3, 224, 224) filter_shape = (64, 3, 7, 7) bias_shape = (1, 64, 1, 1) @@ -194,10 +187,8 @@ def test_conv2d_resnet50_v2_nchw_3c(): @tvm.testing.requires_opencl -def test_conv2d_inceptionv3_nchw_3c(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_inceptionv3_nchw_3c(target, dtype): input_shape = (1, 3, 299, 299) filter_shape = (64, 3, 3, 3) bias_shape = (1, 64, 1, 1) @@ -236,10 +227,8 @@ def test_conv2d_inceptionv3_nchw_3c(): @tvm.testing.requires_opencl -def test_conv2d_1x1_16c16spatial(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_1x1_16c16spatial(target, dtype): input_shape = (1, 16, 256, 256) filter_shape = (32, 16, 4, 4) bias_shape = (1, 32, 1, 1) @@ -278,10 +267,8 @@ def test_conv2d_1x1_16c16spatial(): @tvm.testing.requires_opencl -def test_conv2d_4x4_16c16pad(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_4x4_16c16pad(target, dtype): input_shape = (1, 32, 256, 256) filter_shape = (32, 32, 4, 4) bias_shape = (1, 32, 1, 1) @@ -320,10 +307,8 @@ def test_conv2d_4x4_16c16pad(): @tvm.testing.requires_opencl -def test_conv2d_4x4x4_16c16pad(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_4x4x4_16c16pad(target, dtype): input_shape = (1, 32, 256, 256) filter_shape = (4, 32, 4, 4) bias_shape = (1, 4, 1, 1) @@ -362,10 +347,8 @@ def test_conv2d_4x4x4_16c16pad(): @tvm.testing.requires_opencl -def test_conv2d_yolov3_v2_nchw_3c(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_yolov3_v2_nchw_3c(target, dtype): input_shape = (1, 1024, 13, 13) filter_shape = (255, 1024, 1, 1) A = relay.var("data", shape=input_shape, dtype=dtype) @@ -397,10 +380,8 @@ def test_conv2d_yolov3_v2_nchw_3c(): @tvm.testing.requires_opencl -def test_conv2d_vgg16_winograd_4d(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_vgg16_winograd_4d(target, dtype): input_shape = (1, 512, 28, 28) filter_shape = (512, 512, 3, 3) bias_shape = (1, 512, 1, 1) @@ -447,10 +428,8 @@ def test_conv2d_vgg16_winograd_4d(): @tvm.testing.requires_opencl -def test_conv2d_winograd_conv(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_winograd_conv(target, dtype): input_shape = (1, 4, 3, 3) A = relay.var("data", shape=input_shape, dtype=dtype) filter_shape3 = (8, 4, 3, 3) @@ -496,7 +475,8 @@ def test_conv2d_winograd_conv(): @tvm.testing.requires_opencl -def test_residual_block(): +@tvm.testing.parametrize_targets("opencl") +def test_residual_block(target, dtype): """ - some kind of residual block followed by convolution to have texture after residual block - scalar data type verification which should be mapped to global memory scope @@ -515,9 +495,6 @@ def test_residual_block(): | <- buffer layout_transform (NCHW4c->NCHW) """ - target = "opencl --device=adreno" - dtype = "float16" - input_shape = (1, 32, 40, 40) filter_shape1 = (32, 32, 2, 2) filter_shape2 = (32, 32, 1, 1) @@ -555,7 +532,7 @@ def test_residual_block(): kernel_size=(1, 1), ) D = relay.op.add(conv2, D) - D = D * relay.const(0.15, "float16") + D = D * relay.const(0.15, dtype) D = relay.op.nn.relu(D) conv3 = relay.nn.conv2d( @@ -607,7 +584,8 @@ def test_residual_block(): @tvm.testing.requires_opencl -def test_concat(): +@tvm.testing.parametrize_targets("opencl") +def test_concat(target, dtype): """ layout_transform (NCHW->NCHW4c) | <- buffer @@ -619,9 +597,6 @@ def test_concat(): | <- buffer layout_transform (NCHW4c->NCHW) """ - target = "opencl --device=adreno" - dtype = "float16" - input_shape = (1, 32, 40, 40) filter_shape1 = (96, 32, 2, 2) filter_shape2 = (32, 96, 2, 2) @@ -721,7 +696,8 @@ def test_concat(): @tvm.testing.requires_opencl -def test_pooling_branching_texture_params(): +@tvm.testing.parametrize_targets("opencl") +def test_pooling_branching_texture_params(target, dtype): """ Verification of the pooling and many branches having textures layout_transform (NCHW->NCHW4c) @@ -738,9 +714,6 @@ def test_pooling_branching_texture_params(): | <- buffer layout_transform (NCHW4c->NCHW) """ - target = "opencl --device=adreno" - dtype = "float16" - input_shape = (1, 32, 40, 40) filter_shape0 = (32, 32, 1, 1) filter_shape1 = (32, 32, 2, 2) @@ -849,7 +822,8 @@ def test_pooling_branching_texture_params(): @tvm.testing.requires_opencl -def test_branching_texture_params(): +@tvm.testing.parametrize_targets("opencl") +def test_branching_texture_params(target, dtype): """ Verification of passing texture to several consumers markup of relay variables in primary functions + on_device @@ -866,9 +840,6 @@ def test_branching_texture_params(): | <- buffer layout_transform (NCHW4c->NCHW) """ - target = "opencl --device=adreno" - dtype = "float16" - input_shape = (1, 32, 40, 40) filter_shape0 = (32, 32, 1, 1) filter_shape1 = (32, 32, 2, 2) @@ -976,7 +947,8 @@ def test_branching_texture_params(): # function repeat, params scope are different in reused functions @tvm.testing.requires_opencl -def test_conv2d_different_lowering_same_op(): +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_different_lowering_same_op(target, dtype): """ Use case for verification of caching compiled functions Three convolutions following by each other in this case should be @@ -993,9 +965,6 @@ def test_conv2d_different_lowering_same_op(): | <- buffer layout_transform (NCHW4c->NCHW) """ - target = "opencl --device=adreno" - dtype = "float16" - input_shape = (1, 32, 40, 40) filter_shape1 = (32, 32, 1, 1) A = relay.var("data", shape=input_shape, dtype=dtype) diff --git a/tests/python/relay/test_conv2d_nhwc_texture.py b/tests/python/relay/test_conv2d_nhwc_texture.py index be5cefd46038..574d3540649c 100644 --- a/tests/python/relay/test_conv2d_nhwc_texture.py +++ b/tests/python/relay/test_conv2d_nhwc_texture.py @@ -24,12 +24,11 @@ from tvm.contrib import utils from utils.adreno_utils import gpu_preprocess, build_run_compare +dtype = tvm.testing.parameter("float32") @tvm.testing.requires_opencl -def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16(target, dtype): input_shape = (1, 257, 257, 32) filter_shape = (1, 1, 32, 16) bias_shape = (filter_shape[-1],) @@ -65,10 +64,8 @@ def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16(): @tvm.testing.requires_opencl -def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16_with_padding(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16_with_padding(target, dtype): input_shape = (1, 257, 257, 32) filter_shape = (1, 1, 32, 16) bias_shape = (filter_shape[-1],) @@ -107,10 +104,8 @@ def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16_with_padding(): @tvm.testing.requires_opencl -def test_conv2d_4_35_35_32x3_3_144_16(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_4_35_35_32x3_3_144_16(target, dtype): input_shape = (4, 35, 35, 32) filter_shape = (3, 3, 32, 16) bias_shape = (filter_shape[-1],) @@ -147,10 +142,8 @@ def test_conv2d_4_35_35_32x3_3_144_16(): @tvm.testing.requires_opencl -def test_conv2d_deeplabv3_1_513_513_3x3_3_3_32(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_deeplabv3_1_513_513_3x3_3_3_32(target, dtype): input_shape = (1, 513, 513, 3) filter_shape = (3, 3, 3, 32) bias_shape = (filter_shape[-1],) @@ -187,10 +180,8 @@ def test_conv2d_deeplabv3_1_513_513_3x3_3_3_32(): @tvm.testing.requires_opencl -def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad(target, dtype): input_shape = (1, 42, 42, 32) filter_shape = (3, 3, 32, 96) bias_shape = (1, 1, 1, 96) @@ -229,10 +220,8 @@ def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad(): @tvm.testing.requires_opencl -def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad_pass(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad_pass(target, dtype): input_shape = (1, 40, 40, 32) filter_shape = (2, 2, 32, 96) bias_shape = (1, 1, 1, 96) @@ -271,10 +260,8 @@ def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad_pass(): @tvm.testing.requires_opencl -def test_conv2d_inceptionv3_35_35_strides(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_inceptionv3_35_35_strides(target, dtype): input_shape = (1, 35, 35, 48) filter_shape = (5, 5, 48, 64) bias_shape = (1, 1, 1, 64) @@ -313,10 +300,8 @@ def test_conv2d_inceptionv3_35_35_strides(): @tvm.testing.requires_opencl -def test_conv2d_resnet50_v2_nhwc_3c(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_resnet50_v2_nhwc_3c(target, dtype): input_shape = (1, 224, 224, 3) filter_shape = (7, 7, 3, 64) bias_shape = (1, 1, 1, 64) @@ -356,10 +341,8 @@ def test_conv2d_resnet50_v2_nhwc_3c(): @tvm.testing.requires_opencl -def test_conv2d_inceptionv3_nhwc_3c(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_inceptionv3_nhwc_3c(target, dtype): input_shape = (1, 299, 299, 3) filter_shape = (3, 3, 3, 64) bias_shape = (1, 1, 1, 64) @@ -398,10 +381,8 @@ def test_conv2d_inceptionv3_nhwc_3c(): @tvm.testing.requires_opencl -def test_conv2d_1x1_16c16spatial(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_1x1_16c16spatial(target, dtype): input_shape = (1, 256, 256, 16) filter_shape = (4, 4, 16, 32) bias_shape = (1, 1, 1, 32) @@ -440,10 +421,8 @@ def test_conv2d_1x1_16c16spatial(): @tvm.testing.requires_opencl -def test_conv2d_4x4_16c16pad(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_4x4_16c16pad(target, dtype): input_shape = (1, 256, 256, 32) filter_shape = (4, 4, 32, 32) bias_shape = (1, 1, 1, 32) @@ -482,10 +461,8 @@ def test_conv2d_4x4_16c16pad(): @tvm.testing.requires_opencl -def test_conv2d_4x4x4_16c16pad(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_4x4x4_16c16pad(target, dtype): input_shape = (1, 256, 256, 32) filter_shape = (4, 4, 32, 4) bias_shape = (1, 1, 1, 4) @@ -523,10 +500,8 @@ def test_conv2d_4x4x4_16c16pad(): @tvm.testing.requires_opencl -def test_conv2d_yolov3_v2_nhwc_3c(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_yolov3_v2_nhwc_3c(target, dtype): input_shape = (1, 13, 13, 1024) filter_shape = (1, 1, 1024, 255) A = relay.var("data", shape=input_shape, dtype=dtype) @@ -558,10 +533,8 @@ def test_conv2d_yolov3_v2_nhwc_3c(): @tvm.testing.requires_opencl -def test_conv2d_vgg16_winograd_4d(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_conv2d_vgg16_winograd_4d(target, dtype): input_shape = (1, 28, 28, 512) filter_shape = (3, 3, 512, 512) bias_shape = (1, 1, 1, 512) diff --git a/tests/python/relay/test_depthwise_conv2d_nchw_texture.py b/tests/python/relay/test_depthwise_conv2d_nchw_texture.py index c94d085b5115..1b52c4ec8516 100644 --- a/tests/python/relay/test_depthwise_conv2d_nchw_texture.py +++ b/tests/python/relay/test_depthwise_conv2d_nchw_texture.py @@ -22,12 +22,11 @@ from tvm.relay import testing from utils.adreno_utils import gpu_preprocess, build_run_compare +dtype = tvm.testing.parameter("float32") @tvm.testing.requires_opencl -def test_depthwise_conv2d_bias_nchwc(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_depthwise_conv2d_bias_nchwc(target, dtype): input_shape = (1, 64, 112, 112) filter_shape = (64, 1, 3, 3) bias_shape = (1, 64, 1, 1) @@ -68,10 +67,8 @@ def test_depthwise_conv2d_bias_nchwc(): @tvm.testing.requires_opencl -def test_depthwise_conv2d_nchwc(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_depthwise_conv2d_nchwc(target, dtype): input_shape = (1, 64, 112, 112) filter_shape = (64, 1, 3, 3) bias_shape = (1, 64, 1, 1) @@ -107,10 +104,8 @@ def test_depthwise_conv2d_nchwc(): @tvm.testing.requires_opencl -def test_depthwise_conv2d_bias_nchw(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_depthwise_conv2d_bias_nchw(target, dtype): input_shape = (1, 64, 112, 112) filter_shape = (64, 1, 3, 3) bias_shape = (1, 64, 1, 1) @@ -151,10 +146,8 @@ def test_depthwise_conv2d_bias_nchw(): @tvm.testing.requires_opencl -def test_depthwise_conv2d_repack_bias_nchw(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_depthwise_conv2d_repack_bias_nchw(target, dtype): input_shape = (1, 63, 112, 112) filter_shape = (63, 1, 3, 3) bias_shape = (1, 63, 1, 1) diff --git a/tests/python/relay/test_depthwise_conv2d_nhwc_texture.py b/tests/python/relay/test_depthwise_conv2d_nhwc_texture.py index 16f9b8749909..67173c161634 100644 --- a/tests/python/relay/test_depthwise_conv2d_nhwc_texture.py +++ b/tests/python/relay/test_depthwise_conv2d_nhwc_texture.py @@ -22,12 +22,11 @@ from tvm.relay import testing from utils.adreno_utils import build_run_compare +dtype = tvm.testing.parameter("float32") @tvm.testing.requires_opencl -def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1(target, dtype): input_shape = (1, 129, 129, 144) filter_shape = (3, 3, 144, 1) kernel_size = (filter_shape[0], filter_shape[1]) @@ -66,10 +65,8 @@ def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1(): @tvm.testing.requires_opencl -def test_depthwise_conv2d_deeplabv3_4_35_35_576x3_3_576_1(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_depthwise_conv2d_deeplabv3_4_35_35_576x3_3_576_1(target, dtype): input_shape = (4, 35, 35, 576) filter_shape = (3, 3, 576, 1) kernel_size = (filter_shape[0], filter_shape[1]) @@ -108,10 +105,8 @@ def test_depthwise_conv2d_deeplabv3_4_35_35_576x3_3_576_1(): @tvm.testing.requires_opencl -def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1_with_padding(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1_with_padding(target, dtype): input_shape = (1, 129, 129, 144) filter_shape = (3, 3, 144, 1) kernel_size = (filter_shape[0], filter_shape[1]) @@ -152,10 +147,8 @@ def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1_with_padding(): @tvm.testing.requires_opencl -def test_depthwise_conv2d_1_513_513_7x3_3_7_1(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_depthwise_conv2d_1_513_513_7x3_3_7_1(target, dtype): input_shape = (1, 513, 513, 7) filter_shape = (3, 3, 7, 1) bias_shape = (filter_shape[2],) @@ -193,10 +186,8 @@ def test_depthwise_conv2d_1_513_513_7x3_3_7_1(): @tvm.testing.requires_opencl -def test_depthwise_conv2d_1_513_513_3x3_3_3_1(): - target = "opencl --device=adreno" - dtype = "float16" - +@tvm.testing.parametrize_targets("opencl") +def test_depthwise_conv2d_1_513_513_3x3_3_3_1(target, dtype): input_shape = (1, 513, 513, 3) filter_shape = (3, 3, 3, 1) bias_shape = (filter_shape[2],) diff --git a/tests/scripts/task_config_build_gpu.sh b/tests/scripts/task_config_build_gpu.sh index 5163a16da3cd..a18b9f3988b5 100755 --- a/tests/scripts/task_config_build_gpu.sh +++ b/tests/scripts/task_config_build_gpu.sh @@ -29,6 +29,7 @@ echo set\(USE_CUDA ON\) >> config.cmake echo set\(USE_VULKAN ON\) >> config.cmake echo set\(USE_OPENGL ON\) >> config.cmake echo set\(USE_OPENCL ON\) >> config.cmake +echo set\(USE_CPP_RPC ON\) >> config.cmake echo set\(USE_MICRO ON\) >> config.cmake echo set\(USE_MICRO_STANDALONE_RUNTIME ON\) >> config.cmake echo set\(USE_LLVM \"/usr/bin/llvm-config-9 --link-static\"\) >> config.cmake From 2d30a738f446f7daba0d735c976316db9c261b27 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Fri, 19 Aug 2022 16:30:14 +0300 Subject: [PATCH 05/30] Fix lint --- tests/python/relay/test_conv2d_nchw_texture.py | 1 + tests/python/relay/test_conv2d_nhwc_texture.py | 1 + tests/python/relay/test_depthwise_conv2d_nchw_texture.py | 1 + tests/python/relay/test_depthwise_conv2d_nhwc_texture.py | 3 ++- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/python/relay/test_conv2d_nchw_texture.py b/tests/python/relay/test_conv2d_nchw_texture.py index 730aa7efdd38..4641ffd68ac6 100644 --- a/tests/python/relay/test_conv2d_nchw_texture.py +++ b/tests/python/relay/test_conv2d_nchw_texture.py @@ -25,6 +25,7 @@ dtype = tvm.testing.parameter("float32") + @tvm.testing.requires_opencl @tvm.testing.parametrize_targets("opencl") def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad(target, dtype): diff --git a/tests/python/relay/test_conv2d_nhwc_texture.py b/tests/python/relay/test_conv2d_nhwc_texture.py index 574d3540649c..724e8660ad88 100644 --- a/tests/python/relay/test_conv2d_nhwc_texture.py +++ b/tests/python/relay/test_conv2d_nhwc_texture.py @@ -26,6 +26,7 @@ dtype = tvm.testing.parameter("float32") + @tvm.testing.requires_opencl @tvm.testing.parametrize_targets("opencl") def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16(target, dtype): diff --git a/tests/python/relay/test_depthwise_conv2d_nchw_texture.py b/tests/python/relay/test_depthwise_conv2d_nchw_texture.py index 1b52c4ec8516..70a767d3e8e2 100644 --- a/tests/python/relay/test_depthwise_conv2d_nchw_texture.py +++ b/tests/python/relay/test_depthwise_conv2d_nchw_texture.py @@ -24,6 +24,7 @@ dtype = tvm.testing.parameter("float32") + @tvm.testing.requires_opencl @tvm.testing.parametrize_targets("opencl") def test_depthwise_conv2d_bias_nchwc(target, dtype): diff --git a/tests/python/relay/test_depthwise_conv2d_nhwc_texture.py b/tests/python/relay/test_depthwise_conv2d_nhwc_texture.py index 67173c161634..6fac114b663c 100644 --- a/tests/python/relay/test_depthwise_conv2d_nhwc_texture.py +++ b/tests/python/relay/test_depthwise_conv2d_nhwc_texture.py @@ -24,7 +24,8 @@ dtype = tvm.testing.parameter("float32") -@tvm.testing.requires_opencl + +@tvm.testing.requires_opencl1 @tvm.testing.parametrize_targets("opencl") def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1(target, dtype): input_shape = (1, 129, 129, 144) From 53d8042ba985ba7aadfed9d9aa0b883ea7437493 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Fri, 19 Aug 2022 18:14:31 +0300 Subject: [PATCH 06/30] Enable relay OpenCL tests --- tests/python/relay/test_depthwise_conv2d_nhwc_texture.py | 2 +- tests/scripts/task_python_integration_gpuonly.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/python/relay/test_depthwise_conv2d_nhwc_texture.py b/tests/python/relay/test_depthwise_conv2d_nhwc_texture.py index 6fac114b663c..ce91a8e8ef07 100644 --- a/tests/python/relay/test_depthwise_conv2d_nhwc_texture.py +++ b/tests/python/relay/test_depthwise_conv2d_nhwc_texture.py @@ -25,7 +25,7 @@ dtype = tvm.testing.parameter("float32") -@tvm.testing.requires_opencl1 +@tvm.testing.requires_opencl @tvm.testing.parametrize_targets("opencl") def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1(target, dtype): input_shape = (1, 129, 129, 144) diff --git a/tests/scripts/task_python_integration_gpuonly.sh b/tests/scripts/task_python_integration_gpuonly.sh index 3ce5571caa0e..4187d218eda4 100755 --- a/tests/scripts/task_python_integration_gpuonly.sh +++ b/tests/scripts/task_python_integration_gpuonly.sh @@ -20,7 +20,7 @@ set -exo pipefail export TVM_TEST_TARGETS="cuda;opencl;metal;rocm;nvptx;opencl -device=mali,aocl_sw_emu" export PYTEST_ADDOPTS="-m gpu $PYTEST_ADDOPTS" -export TVM_RELAY_TEST_TARGETS="cuda" +export TVM_RELAY_TEST_TARGETS="cuda;opencl" export TVM_INTEGRATION_TESTSUITE_NAME=python-integration-gpu export TVM_INTEGRATION_GPU_ONLY=1 From 4c981a13f277fb2d9dc01f425cc8b4fd00f44e47 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Mon, 22 Aug 2022 19:17:24 +0300 Subject: [PATCH 07/30] Fix opencl relay texture tests --- .../test_conv2d_nchw_texture.py | 37 ++++++++++--------- .../test_conv2d_nhwc_texture.py | 30 +++++++-------- .../test_depthwise_conv2d_nchw_texture.py | 8 ++-- .../test_depthwise_conv2d_nhwc_texture.py | 10 ++--- .../utils/adreno_utils.py | 1 - tests/scripts/task_config_build_gpu.sh | 1 + tests/scripts/task_python_integration.sh | 4 ++ .../task_python_integration_gpuonly.sh | 5 ++- 8 files changed, 51 insertions(+), 45 deletions(-) rename tests/python/relay/{ => opencl_texture}/test_conv2d_nchw_texture.py (96%) rename tests/python/relay/{ => opencl_texture}/test_conv2d_nhwc_texture.py (95%) rename tests/python/relay/{ => opencl_texture}/test_depthwise_conv2d_nchw_texture.py (96%) rename tests/python/relay/{ => opencl_texture}/test_depthwise_conv2d_nhwc_texture.py (96%) rename tests/python/relay/{ => opencl_texture}/utils/adreno_utils.py (99%) diff --git a/tests/python/relay/test_conv2d_nchw_texture.py b/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py similarity index 96% rename from tests/python/relay/test_conv2d_nchw_texture.py rename to tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py index 4641ffd68ac6..0dec4ae3786f 100644 --- a/tests/python/relay/test_conv2d_nchw_texture.py +++ b/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py @@ -27,7 +27,7 @@ @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad(target, dtype): input_shape = (1, 32, 42, 42) filter_shape = (96, 32, 3, 3) @@ -63,11 +63,12 @@ def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad(target, dtype): "bias": tvm.nd.array(bias_data), } + build_run_compare(mod, params1, {"data": input_shape}, dtype, target, [], gpu_preprocess) @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad_pass(target, dtype): input_shape = (1, 32, 40, 40) filter_shape = (96, 32, 2, 2) @@ -107,7 +108,7 @@ def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad_pass(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_inceptionv3_35_35_strides(target, dtype): input_shape = (1, 48, 35, 35) filter_shape = (64, 48, 5, 5) @@ -147,7 +148,7 @@ def test_conv2d_inceptionv3_35_35_strides(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_resnet50_v2_nchw_3c(target, dtype): input_shape = (1, 3, 224, 224) filter_shape = (64, 3, 7, 7) @@ -188,7 +189,7 @@ def test_conv2d_resnet50_v2_nchw_3c(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_inceptionv3_nchw_3c(target, dtype): input_shape = (1, 3, 299, 299) filter_shape = (64, 3, 3, 3) @@ -228,7 +229,7 @@ def test_conv2d_inceptionv3_nchw_3c(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_1x1_16c16spatial(target, dtype): input_shape = (1, 16, 256, 256) filter_shape = (32, 16, 4, 4) @@ -268,7 +269,7 @@ def test_conv2d_1x1_16c16spatial(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_4x4_16c16pad(target, dtype): input_shape = (1, 32, 256, 256) filter_shape = (32, 32, 4, 4) @@ -308,7 +309,7 @@ def test_conv2d_4x4_16c16pad(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_4x4x4_16c16pad(target, dtype): input_shape = (1, 32, 256, 256) filter_shape = (4, 32, 4, 4) @@ -348,7 +349,7 @@ def test_conv2d_4x4x4_16c16pad(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_yolov3_v2_nchw_3c(target, dtype): input_shape = (1, 1024, 13, 13) filter_shape = (255, 1024, 1, 1) @@ -381,7 +382,7 @@ def test_conv2d_yolov3_v2_nchw_3c(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_vgg16_winograd_4d(target, dtype): input_shape = (1, 512, 28, 28) filter_shape = (512, 512, 3, 3) @@ -419,7 +420,7 @@ def test_conv2d_vgg16_winograd_4d(target, dtype): stat_file = temp.relpath("stat.log") with open(stat_file, "w") as f: f.write( - '{"input": ["opencl -keys=adreno,opencl,gpu -device=adreno -max_num_threads=256", "conv2d_nchw_winograd_acc32.image2d", [["TENSOR", [1, 512, 28, 28], "float16"], ["TENSOR", [512, 512, 3, 3], "float16"], [1, 1], [1, 1, 1, 1], [1, 1], "float16"], {}], "config": {"index": 1591, "code_hash": null, "entity": [["auto_unroll_max_step", "ot", 4], ["tile_y", "sp", [-1, 1, 32]], ["tile_x", "sp", [-1, 4, 2]], ["tile_rc", "sp", [-1, 8]]]}, "result": [[0.0037244], 0, 7.06374192237854, 1653898629.7427933], "version": 0.2, "tvm_version": "0.8.dev0"}\n' + '{"input": ["opencl -keys=adreno,opencl,gpu -device=adreno -max_num_threads=256", "conv2d_nchw_winograd_acc32.image2d", [["TENSOR", [1, 512, 28, 28], "float32"], ["TENSOR", [512, 512, 3, 3], "float32"], [1, 1], [1, 1, 1, 1], [1, 1], "float32"], {}], "config": {"index": 1591, "code_hash": null, "entity": [["auto_unroll_max_step", "ot", 4], ["tile_y", "sp", [-1, 1, 32]], ["tile_x", "sp", [-1, 4, 2]], ["tile_rc", "sp", [-1, 8]]]}, "result": [[0.0037244], 0, 7.06374192237854, 1653898629.7427933], "version": 0.2, "tvm_version": "0.8.dev0"}\n' ) graph = build_run_compare( mod, params1, {"data": input_shape}, dtype, target, stat_file=stat_file @@ -429,7 +430,7 @@ def test_conv2d_vgg16_winograd_4d(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_winograd_conv(target, dtype): input_shape = (1, 4, 3, 3) A = relay.var("data", shape=input_shape, dtype=dtype) @@ -466,7 +467,7 @@ def test_conv2d_winograd_conv(target, dtype): stat_file = temp.relpath("stat.log") with open(stat_file, "w") as f: f.write( - '{"input": ["opencl -keys=adreno,opencl,gpu -device=adreno -max_num_threads=256", "conv2d_nchw_winograd_acc32.image2d", [["TENSOR", [1, 4, 3, 3], "float16"], ["TENSOR", [8, 4, 3, 3], "float16"], [1, 1], [1, 1, 1, 1], [1, 1], "float16"], {}], "config": {"index": 1591, "code_hash": null, "entity": [["auto_unroll_max_step", "ot", 4], ["tile_y", "sp", [-1, 1, 32]], ["tile_x", "sp", [-1, 4, 2]], ["tile_rc", "sp", [-1, 8]]]}, "result": [[0.0037244], 0, 7.06374192237854, 1653898629.7427933], "version": 0.2, "tvm_version": "0.8.dev0"}\n' + '{"input": ["opencl -keys=adreno,opencl,gpu -device=adreno -max_num_threads=256", "conv2d_nchw_winograd_acc32.image2d", [["TENSOR", [1, 4, 3, 3], "float32"], ["TENSOR", [8, 4, 3, 3], "float32"], [1, 1], [1, 1, 1, 1], [1, 1], "float32"], {}], "config": {"index": 1591, "code_hash": null, "entity": [["auto_unroll_max_step", "ot", 4], ["tile_y", "sp", [-1, 1, 32]], ["tile_x", "sp", [-1, 4, 2]], ["tile_rc", "sp", [-1, 8]]]}, "result": [[0.0037244], 0, 7.06374192237854, 1653898629.7427933], "version": 0.2, "tvm_version": "0.8.dev0"}\n' ) graph = build_run_compare( mod, params1, {"data": input_shape}, dtype, target, stat_file=stat_file @@ -476,7 +477,7 @@ def test_conv2d_winograd_conv(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_residual_block(target, dtype): """ - some kind of residual block followed by convolution to have texture after residual block @@ -585,7 +586,7 @@ def test_residual_block(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_concat(target, dtype): """ layout_transform (NCHW->NCHW4c) @@ -697,7 +698,7 @@ def test_concat(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_pooling_branching_texture_params(target, dtype): """ Verification of the pooling and many branches having textures @@ -823,7 +824,7 @@ def test_pooling_branching_texture_params(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_branching_texture_params(target, dtype): """ Verification of passing texture to several consumers markup of relay variables in @@ -948,7 +949,7 @@ def test_branching_texture_params(target, dtype): # function repeat, params scope are different in reused functions @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_different_lowering_same_op(target, dtype): """ Use case for verification of caching compiled functions diff --git a/tests/python/relay/test_conv2d_nhwc_texture.py b/tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py similarity index 95% rename from tests/python/relay/test_conv2d_nhwc_texture.py rename to tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py index 724e8660ad88..fe7eff883e95 100644 --- a/tests/python/relay/test_conv2d_nhwc_texture.py +++ b/tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py @@ -28,7 +28,7 @@ @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16(target, dtype): input_shape = (1, 257, 257, 32) filter_shape = (1, 1, 32, 16) @@ -65,7 +65,7 @@ def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16_with_padding(target, dtype): input_shape = (1, 257, 257, 32) filter_shape = (1, 1, 32, 16) @@ -105,7 +105,7 @@ def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16_with_padding(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_4_35_35_32x3_3_144_16(target, dtype): input_shape = (4, 35, 35, 32) filter_shape = (3, 3, 32, 16) @@ -143,7 +143,7 @@ def test_conv2d_4_35_35_32x3_3_144_16(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_deeplabv3_1_513_513_3x3_3_3_32(target, dtype): input_shape = (1, 513, 513, 3) filter_shape = (3, 3, 3, 32) @@ -181,7 +181,7 @@ def test_conv2d_deeplabv3_1_513_513_3x3_3_3_32(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad(target, dtype): input_shape = (1, 42, 42, 32) filter_shape = (3, 3, 32, 96) @@ -221,7 +221,7 @@ def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad_pass(target, dtype): input_shape = (1, 40, 40, 32) filter_shape = (2, 2, 32, 96) @@ -261,7 +261,7 @@ def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad_pass(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_inceptionv3_35_35_strides(target, dtype): input_shape = (1, 35, 35, 48) filter_shape = (5, 5, 48, 64) @@ -301,7 +301,7 @@ def test_conv2d_inceptionv3_35_35_strides(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_resnet50_v2_nhwc_3c(target, dtype): input_shape = (1, 224, 224, 3) filter_shape = (7, 7, 3, 64) @@ -342,7 +342,7 @@ def test_conv2d_resnet50_v2_nhwc_3c(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_inceptionv3_nhwc_3c(target, dtype): input_shape = (1, 299, 299, 3) filter_shape = (3, 3, 3, 64) @@ -382,7 +382,7 @@ def test_conv2d_inceptionv3_nhwc_3c(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_1x1_16c16spatial(target, dtype): input_shape = (1, 256, 256, 16) filter_shape = (4, 4, 16, 32) @@ -422,7 +422,7 @@ def test_conv2d_1x1_16c16spatial(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_4x4_16c16pad(target, dtype): input_shape = (1, 256, 256, 32) filter_shape = (4, 4, 32, 32) @@ -462,7 +462,7 @@ def test_conv2d_4x4_16c16pad(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_4x4x4_16c16pad(target, dtype): input_shape = (1, 256, 256, 32) filter_shape = (4, 4, 32, 4) @@ -501,7 +501,7 @@ def test_conv2d_4x4x4_16c16pad(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_yolov3_v2_nhwc_3c(target, dtype): input_shape = (1, 13, 13, 1024) filter_shape = (1, 1, 1024, 255) @@ -534,7 +534,7 @@ def test_conv2d_yolov3_v2_nhwc_3c(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_conv2d_vgg16_winograd_4d(target, dtype): input_shape = (1, 28, 28, 512) filter_shape = (3, 3, 512, 512) @@ -572,7 +572,7 @@ def test_conv2d_vgg16_winograd_4d(target, dtype): stat_file = temp.relpath("stat.log") with open(stat_file, "w") as f: f.write( - '{"input": ["opencl -keys=adreno,opencl,gpu -device=adreno -max_num_threads=256", "conv2d_nhwc_winograd_acc32.image2d", [["TENSOR", [1, 28, 28, 512], "float16"], ["TENSOR", [3, 3, 512, 512], "float16"], [1, 1], [1, 1, 1, 1], [1, 1], "float16"], {}], "config": {"index": 1591, "code_hash": null, "entity": [["auto_unroll_max_step", "ot", 4], ["tile_y", "sp", [-1, 1, 32]], ["tile_x", "sp", [-1, 4, 2]], ["tile_rc", "sp", [-1, 8]]]}, "result": [[0.0037244], 0, 7.06374192237854, 1653898629.7427933], "version": 0.2, "tvm_version": "0.8.dev0"}\n' + '{"input": ["opencl -keys=adreno,opencl,gpu -device=adreno -max_num_threads=256", "conv2d_nhwc_winograd_acc32.image2d", [["TENSOR", [1, 28, 28, 512], "float32"], ["TENSOR", [3, 3, 512, 512], "float32"], [1, 1], [1, 1, 1, 1], [1, 1], "float32"], {}], "config": {"index": 1591, "code_hash": null, "entity": [["auto_unroll_max_step", "ot", 4], ["tile_y", "sp", [-1, 1, 32]], ["tile_x", "sp", [-1, 4, 2]], ["tile_rc", "sp", [-1, 8]]]}, "result": [[0.0037244], 0, 7.06374192237854, 1653898629.7427933], "version": 0.2, "tvm_version": "0.8.dev0"}\n' ) graph = build_run_compare( mod, params1, {"data": input_shape}, dtype, target, stat_file=stat_file diff --git a/tests/python/relay/test_depthwise_conv2d_nchw_texture.py b/tests/python/relay/opencl_texture/test_depthwise_conv2d_nchw_texture.py similarity index 96% rename from tests/python/relay/test_depthwise_conv2d_nchw_texture.py rename to tests/python/relay/opencl_texture/test_depthwise_conv2d_nchw_texture.py index 70a767d3e8e2..0ac92d03b6f9 100644 --- a/tests/python/relay/test_depthwise_conv2d_nchw_texture.py +++ b/tests/python/relay/opencl_texture/test_depthwise_conv2d_nchw_texture.py @@ -26,7 +26,7 @@ @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_depthwise_conv2d_bias_nchwc(target, dtype): input_shape = (1, 64, 112, 112) filter_shape = (64, 1, 3, 3) @@ -68,7 +68,7 @@ def test_depthwise_conv2d_bias_nchwc(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_depthwise_conv2d_nchwc(target, dtype): input_shape = (1, 64, 112, 112) filter_shape = (64, 1, 3, 3) @@ -105,7 +105,7 @@ def test_depthwise_conv2d_nchwc(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_depthwise_conv2d_bias_nchw(target, dtype): input_shape = (1, 64, 112, 112) filter_shape = (64, 1, 3, 3) @@ -147,7 +147,7 @@ def test_depthwise_conv2d_bias_nchw(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_depthwise_conv2d_repack_bias_nchw(target, dtype): input_shape = (1, 63, 112, 112) filter_shape = (63, 1, 3, 3) diff --git a/tests/python/relay/test_depthwise_conv2d_nhwc_texture.py b/tests/python/relay/opencl_texture/test_depthwise_conv2d_nhwc_texture.py similarity index 96% rename from tests/python/relay/test_depthwise_conv2d_nhwc_texture.py rename to tests/python/relay/opencl_texture/test_depthwise_conv2d_nhwc_texture.py index ce91a8e8ef07..3af7db3a4e1f 100644 --- a/tests/python/relay/test_depthwise_conv2d_nhwc_texture.py +++ b/tests/python/relay/opencl_texture/test_depthwise_conv2d_nhwc_texture.py @@ -26,7 +26,7 @@ @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1(target, dtype): input_shape = (1, 129, 129, 144) filter_shape = (3, 3, 144, 1) @@ -66,7 +66,7 @@ def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_depthwise_conv2d_deeplabv3_4_35_35_576x3_3_576_1(target, dtype): input_shape = (4, 35, 35, 576) filter_shape = (3, 3, 576, 1) @@ -106,7 +106,7 @@ def test_depthwise_conv2d_deeplabv3_4_35_35_576x3_3_576_1(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1_with_padding(target, dtype): input_shape = (1, 129, 129, 144) filter_shape = (3, 3, 144, 1) @@ -148,7 +148,7 @@ def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1_with_padding(target, @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_depthwise_conv2d_1_513_513_7x3_3_7_1(target, dtype): input_shape = (1, 513, 513, 7) filter_shape = (3, 3, 7, 1) @@ -187,7 +187,7 @@ def test_depthwise_conv2d_1_513_513_7x3_3_7_1(target, dtype): @tvm.testing.requires_opencl -@tvm.testing.parametrize_targets("opencl") +@tvm.testing.parametrize_targets("opencl -device=adreno") def test_depthwise_conv2d_1_513_513_3x3_3_3_1(target, dtype): input_shape = (1, 513, 513, 3) filter_shape = (3, 3, 3, 1) diff --git a/tests/python/relay/utils/adreno_utils.py b/tests/python/relay/opencl_texture/utils/adreno_utils.py similarity index 99% rename from tests/python/relay/utils/adreno_utils.py rename to tests/python/relay/opencl_texture/utils/adreno_utils.py index 27768c3d0cec..c490a26512de 100644 --- a/tests/python/relay/utils/adreno_utils.py +++ b/tests/python/relay/opencl_texture/utils/adreno_utils.py @@ -71,7 +71,6 @@ def build_run_compare( tvm_mod_nchwc = gpu_preprocess(tvm_mod) else: tvm_mod_nchwc = tvm_mod - if stat_file is not None: with autotvm.apply_history_best(stat_file): with tvm.transform.PassContext(opt_level=3): diff --git a/tests/scripts/task_config_build_gpu.sh b/tests/scripts/task_config_build_gpu.sh index a18b9f3988b5..b2d31585d40a 100755 --- a/tests/scripts/task_config_build_gpu.sh +++ b/tests/scripts/task_config_build_gpu.sh @@ -28,6 +28,7 @@ echo set\(USE_CUDNN ON\) >> config.cmake echo set\(USE_CUDA ON\) >> config.cmake echo set\(USE_VULKAN ON\) >> config.cmake echo set\(USE_OPENGL ON\) >> config.cmake +echo set\(USE_OPENCL_GTEST "${HEXAGON_SDK_ROOT}/utils/googletest/gtest"\) >> config.cmake echo set\(USE_OPENCL ON\) >> config.cmake echo set\(USE_CPP_RPC ON\) >> config.cmake echo set\(USE_MICRO ON\) >> config.cmake diff --git a/tests/scripts/task_python_integration.sh b/tests/scripts/task_python_integration.sh index d831481acea6..c60e36df6d92 100755 --- a/tests/scripts/task_python_integration.sh +++ b/tests/scripts/task_python_integration.sh @@ -68,6 +68,10 @@ run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-contrib-test_ethosu tests/py TVM_TEST_TARGETS="${TVM_RELAY_TEST_TARGETS:-llvm;cuda}" \ run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-relay tests/python/relay +# OpenCL texture test +TVM_TEST_TARGETS="$TVM_TEST_TARGETS;$TVM_RELAY_OPENCL_TEXTURE_TARGETS" +run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-opencl-texture tests/python/relay/opencl_texture + # Command line driver test run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-driver tests/python/driver diff --git a/tests/scripts/task_python_integration_gpuonly.sh b/tests/scripts/task_python_integration_gpuonly.sh index 4187d218eda4..432984c95561 100755 --- a/tests/scripts/task_python_integration_gpuonly.sh +++ b/tests/scripts/task_python_integration_gpuonly.sh @@ -18,9 +18,10 @@ set -exo pipefail -export TVM_TEST_TARGETS="cuda;opencl;metal;rocm;nvptx;opencl -device=mali,aocl_sw_emu" +export TVM_TEST_TARGETS="cuda;opencl;metal;rocm;nvptx;opencl -device=mali,aocl_sw_emu,adreno" export PYTEST_ADDOPTS="-m gpu $PYTEST_ADDOPTS" -export TVM_RELAY_TEST_TARGETS="cuda;opencl" +export TVM_RELAY_TEST_TARGETS="cuda" +export TVM_RELAY_OPENCL_TEXTURE_TARGETS="opencl -device=adreno" export TVM_INTEGRATION_TESTSUITE_NAME=python-integration-gpu export TVM_INTEGRATION_GPU_ONLY=1 From 61bf976b0fd48c2e9aefc799a0370cf9adeaf9cd Mon Sep 17 00:00:00 2001 From: valmat07 Date: Mon, 22 Aug 2022 19:54:21 +0300 Subject: [PATCH 08/30] fix lint --- tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py b/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py index 0dec4ae3786f..3f4f3b9624d9 100644 --- a/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py +++ b/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py @@ -63,7 +63,6 @@ def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad(target, dtype): "bias": tvm.nd.array(bias_data), } - build_run_compare(mod, params1, {"data": input_shape}, dtype, target, [], gpu_preprocess) From 19a115367410832287b1667aa26b8b13fb1cd8e8 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Mon, 22 Aug 2022 20:28:20 +0300 Subject: [PATCH 09/30] Remove OpenCL gtest variable --- tests/scripts/task_config_build_gpu.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/scripts/task_config_build_gpu.sh b/tests/scripts/task_config_build_gpu.sh index b2d31585d40a..a18b9f3988b5 100755 --- a/tests/scripts/task_config_build_gpu.sh +++ b/tests/scripts/task_config_build_gpu.sh @@ -28,7 +28,6 @@ echo set\(USE_CUDNN ON\) >> config.cmake echo set\(USE_CUDA ON\) >> config.cmake echo set\(USE_VULKAN ON\) >> config.cmake echo set\(USE_OPENGL ON\) >> config.cmake -echo set\(USE_OPENCL_GTEST "${HEXAGON_SDK_ROOT}/utils/googletest/gtest"\) >> config.cmake echo set\(USE_OPENCL ON\) >> config.cmake echo set\(USE_CPP_RPC ON\) >> config.cmake echo set\(USE_MICRO ON\) >> config.cmake From 213620c250dee464d47db45998ac490f98321a6a Mon Sep 17 00:00:00 2001 From: valmat07 Date: Mon, 22 Aug 2022 22:54:22 +0300 Subject: [PATCH 10/30] Fix unbound variable --- tests/scripts/task_python_integration.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/scripts/task_python_integration.sh b/tests/scripts/task_python_integration.sh index c60e36df6d92..963940329ca5 100755 --- a/tests/scripts/task_python_integration.sh +++ b/tests/scripts/task_python_integration.sh @@ -69,8 +69,8 @@ TVM_TEST_TARGETS="${TVM_RELAY_TEST_TARGETS:-llvm;cuda}" \ run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-relay tests/python/relay # OpenCL texture test -TVM_TEST_TARGETS="$TVM_TEST_TARGETS;$TVM_RELAY_OPENCL_TEXTURE_TARGETS" -run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-opencl-texture tests/python/relay/opencl_texture +TVM_TEST_TARGETS="$TVM_RELAY_OPENCL_TEXTURE_TARGETS" \ + run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-opencl-texture tests/python/relay/opencl_texture # Command line driver test run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-driver tests/python/driver From 2107de081cbb6faacb5f48d814a03e7ab7cbb4ea Mon Sep 17 00:00:00 2001 From: valmat07 Date: Tue, 23 Aug 2022 15:18:32 +0300 Subject: [PATCH 11/30] Skip tests that are not supported in CI --- tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py | 4 +++- tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py | 3 +++ tests/scripts/task_python_integration.sh | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py b/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py index a9e29a4eb7f4..573db061ba72 100644 --- a/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py +++ b/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py @@ -22,7 +22,7 @@ from tvm.relay import testing from tvm.contrib import utils from utils.adreno_utils import gpu_preprocess, build_run_compare - +import pytest dtype = tvm.testing.parameter("float32") @@ -148,6 +148,7 @@ def test_conv2d_inceptionv3_35_35_strides(target, dtype): @tvm.testing.requires_opencl @tvm.testing.parametrize_targets("opencl -device=adreno") +@pytest.mark.xfail(raises=tvm._ffi.base.TVMError) def test_conv2d_resnet50_v2_nchw_3c(target, dtype): input_shape = (1, 3, 224, 224) filter_shape = (64, 3, 7, 7) @@ -477,6 +478,7 @@ def test_conv2d_winograd_conv(target, dtype): @tvm.testing.requires_opencl @tvm.testing.parametrize_targets("opencl -device=adreno") +@pytest.mark.xfail def test_residual_block(target, dtype): """ - some kind of residual block followed by convolution to have texture after residual block diff --git a/tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py b/tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py index fe7eff883e95..8b9d5eb81437 100644 --- a/tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py +++ b/tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py @@ -23,6 +23,7 @@ from tvm.relay import testing from tvm.contrib import utils from utils.adreno_utils import gpu_preprocess, build_run_compare +import pytest dtype = tvm.testing.parameter("float32") @@ -302,6 +303,7 @@ def test_conv2d_inceptionv3_35_35_strides(target, dtype): @tvm.testing.requires_opencl @tvm.testing.parametrize_targets("opencl -device=adreno") +@pytest.mark.xfail(raises=tvm._ffi.base.TVMError) def test_conv2d_resnet50_v2_nhwc_3c(target, dtype): input_shape = (1, 224, 224, 3) filter_shape = (7, 7, 3, 64) @@ -383,6 +385,7 @@ def test_conv2d_inceptionv3_nhwc_3c(target, dtype): @tvm.testing.requires_opencl @tvm.testing.parametrize_targets("opencl -device=adreno") +@pytest.mark.xfail(raises=tvm._ffi.base.TVMError) def test_conv2d_1x1_16c16spatial(target, dtype): input_shape = (1, 256, 256, 16) filter_shape = (4, 4, 16, 32) diff --git a/tests/scripts/task_python_integration.sh b/tests/scripts/task_python_integration.sh index 15d32b5b347a..06bc273639c1 100755 --- a/tests/scripts/task_python_integration.sh +++ b/tests/scripts/task_python_integration.sh @@ -68,7 +68,7 @@ TVM_TEST_TARGETS="${TVM_RELAY_TEST_TARGETS:-llvm;cuda}" \ run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-relay tests/python/relay # OpenCL texture test -TVM_TEST_TARGETS="$TVM_RELAY_OPENCL_TEXTURE_TARGETS" \ +TVM_TEST_TARGETS="${TVM_RELAY_OPENCL_TEXTURE_TARGETS:-opencl}" \ run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-opencl-texture tests/python/relay/opencl_texture # Command line driver test From be5fb16d90e69c79e509b3c1f89cc455b1b90e0c Mon Sep 17 00:00:00 2001 From: valmat07 Date: Tue, 23 Aug 2022 15:42:29 +0300 Subject: [PATCH 12/30] fix lint --- tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py | 2 ++ tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py | 1 + 2 files changed, 3 insertions(+) diff --git a/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py b/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py index 573db061ba72..ee6a41f57e37 100644 --- a/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py +++ b/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py @@ -23,6 +23,8 @@ from tvm.contrib import utils from utils.adreno_utils import gpu_preprocess, build_run_compare import pytest + + dtype = tvm.testing.parameter("float32") diff --git a/tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py b/tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py index 8b9d5eb81437..27123df7942a 100644 --- a/tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py +++ b/tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py @@ -25,6 +25,7 @@ from utils.adreno_utils import gpu_preprocess, build_run_compare import pytest + dtype = tvm.testing.parameter("float32") From 757f9d30b9bfef3d53245ba415b50b91a0d4189c Mon Sep 17 00:00:00 2001 From: valmat07 Date: Tue, 23 Aug 2022 17:30:31 +0300 Subject: [PATCH 13/30] Add path for opencl gtest directory --- tests/scripts/task_config_build_gpu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/scripts/task_config_build_gpu.sh b/tests/scripts/task_config_build_gpu.sh index a18b9f3988b5..cca53fd6d5e9 100755 --- a/tests/scripts/task_config_build_gpu.sh +++ b/tests/scripts/task_config_build_gpu.sh @@ -30,6 +30,7 @@ echo set\(USE_VULKAN ON\) >> config.cmake echo set\(USE_OPENGL ON\) >> config.cmake echo set\(USE_OPENCL ON\) >> config.cmake echo set\(USE_CPP_RPC ON\) >> config.cmake +echo set\(USE_OPENCL_GTEST /usr/src/gtest\) >> config.cmake echo set\(USE_MICRO ON\) >> config.cmake echo set\(USE_MICRO_STANDALONE_RUNTIME ON\) >> config.cmake echo set\(USE_LLVM \"/usr/bin/llvm-config-9 --link-static\"\) >> config.cmake From b17219d6ea917f135904ae430149d6cc3e5c0593 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Wed, 24 Aug 2022 14:22:57 +0300 Subject: [PATCH 14/30] Fix opencl gtests include directory --- tests/scripts/task_config_build_gpu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/task_config_build_gpu.sh b/tests/scripts/task_config_build_gpu.sh index cca53fd6d5e9..ca37e30c113e 100755 --- a/tests/scripts/task_config_build_gpu.sh +++ b/tests/scripts/task_config_build_gpu.sh @@ -30,7 +30,7 @@ echo set\(USE_VULKAN ON\) >> config.cmake echo set\(USE_OPENGL ON\) >> config.cmake echo set\(USE_OPENCL ON\) >> config.cmake echo set\(USE_CPP_RPC ON\) >> config.cmake -echo set\(USE_OPENCL_GTEST /usr/src/gtest\) >> config.cmake +echo set\(USE_OPENCL_GTEST /usr/src/googletest\) >> config.cmake echo set\(USE_MICRO ON\) >> config.cmake echo set\(USE_MICRO_STANDALONE_RUNTIME ON\) >> config.cmake echo set\(USE_LLVM \"/usr/bin/llvm-config-9 --link-static\"\) >> config.cmake From ad16842160c042d74ec10bb616d124b735359d75 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Fri, 26 Aug 2022 17:36:36 +0300 Subject: [PATCH 15/30] Enable OpenCL googletest. Fix bug in opencl timer test --- CMakeLists.txt | 22 +++++++++++++------ cmake/modules/OpenCL.cmake | 2 +- src/runtime/opencl/opencl_common.h | 2 +- tests/cpp-runtime/opencl/opencl_timer_test.cc | 1 + tests/cpp-runtime/opencl/run_gtests.cc | 2 +- tests/scripts/task_config_build_gpu.sh | 2 +- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8995f9a87fb7..42efcdd44403 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ endif() # Alernatively, use cmake -DOPTION=VALUE through command-line. tvm_option(USE_CUDA "Build with CUDA" OFF) tvm_option(USE_OPENCL "Build with OpenCL" OFF) -tvm_option(USE_OPENCL_GTEST "Path to OpenCL specific gtest version for runtime cpp tests." /path/to/opencl/gtest) +tvm_option(USE_OPENCL_GTEST "Path to OpenCL specific gtest version for runtime cpp tests. Or pass ON/OFF value" OFF) tvm_option(USE_VULKAN "Build with Vulkan" OFF) @@ -617,16 +617,24 @@ if(BUILD_FOR_HEXAGON AND DEFINED USE_HEXAGON_GTEST AND EXISTS ${USE_HEXAGON_GTES include_directories("${USE_HEXAGON_GTEST}/include") endif() -if(USE_OPENCL AND DEFINED USE_OPENCL_GTEST AND EXISTS ${USE_OPENCL_GTEST}) +if(USE_OPENCL AND DEFINED USE_OPENCL_GTEST AND (EXISTS ${USE_OPENCL_GTEST} OR "${USE_OPENCL_GTEST}" MATCHES ${IS_TRUE_PATTERN})) include(FetchContent) - FetchContent_Declare(googletest SOURCE_DIR "${USE_OPENCL_GTEST}") + if ("${USE_OPENCL_GTEST}" MATCHES ${IS_TRUE_PATTERN}) + FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG 703bd9caab50b139428cea1aaff9974ebee5742e # release-1.10.0 + ) + elseif(EXISTS ${USE_OPENCL_GTEST}) + FetchContent_Declare(googletest SOURCE_DIR "${USE_OPENCL_GTEST}") + include_directories("${USE_OPENCL_GTEST}/include") + include_directories("${USE_OPENCL_GTEST}/googletest/include") + message(STATUS "Found OpenCL gtest at ${USE_OPENCL_GTEST}") + endif() set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) target_link_libraries(tvm_runtime PUBLIC gtest) target_link_libraries(tvm PUBLIC gtest) - include_directories("${USE_OPENCL_GTEST}/include") - include_directories("${USE_OPENCL_GTEST}/googletest/include") - message(STATUS "Found OpenCL gtest at ${USE_OPENCL_GTEST}") endif() # Set flags for clang @@ -691,7 +699,7 @@ install(TARGETS tvm_runtime EXPORT ${PROJECT_NAME}Targets DESTINATION lib${LIB_S if(BUILD_FOR_HEXAGON AND DEFINED USE_HEXAGON_GTEST AND EXISTS ${USE_HEXAGON_GTEST}) install(TARGETS gtest EXPORT ${PROJECT_NAME}Targets DESTINATION lib${LIB_SUFFIX}) endif() -if(USE_OPENCL AND DEFINED USE_OPENCL_GTEST AND EXISTS ${USE_OPENCL_GTEST}) +if(USE_OPENCL AND DEFINED USE_OPENCL_GTEST AND (EXISTS ${USE_OPENCL_GTEST} OR "${USE_OPENCL_GTEST}" MATCHES ${IS_TRUE_PATTERN})) install(TARGETS gtest EXPORT ${PROJECT_NAME}Targets DESTINATION lib${LIB_SUFFIX}) endif() diff --git a/cmake/modules/OpenCL.cmake b/cmake/modules/OpenCL.cmake index 430af7e8722c..d71eabda6e6f 100644 --- a/cmake/modules/OpenCL.cmake +++ b/cmake/modules/OpenCL.cmake @@ -56,7 +56,7 @@ if(USE_OPENCL) tvm_file_glob(GLOB RUNTIME_OPENCL_SRCS src/runtime/opencl/*.cc) list(APPEND TVM_RUNTIME_LINKER_LIBS ${OpenCL_LIBRARIES}) - if(DEFINED USE_OPENCL_GTEST AND EXISTS ${USE_OPENCL_GTEST}) + if(DEFINED USE_OPENCL_GTEST AND (EXISTS ${USE_OPENCL_GTEST} OR "${USE_OPENCL_GTEST}" MATCHES ${IS_TRUE_PATTERN})) file_glob_append(RUNTIME_OPENCL_SRCS "${CMAKE_SOURCE_DIR}/tests/cpp-runtime/opencl/*.cc" ) diff --git a/src/runtime/opencl/opencl_common.h b/src/runtime/opencl/opencl_common.h index f16e1e936d96..7f7f083cf303 100644 --- a/src/runtime/opencl/opencl_common.h +++ b/src/runtime/opencl/opencl_common.h @@ -439,9 +439,9 @@ class OpenCLTimerNode : public TimerNode { public: // Timer start virtual void Start() { + this->duration = 0; if (count_timer_execs == 0) { cl::OpenCLWorkspace::Global()->GetEventQueue(dev_).clear(); - this->duration = 0; // Very first call of Start() leads to the recreation of // OpenCL command queue in profiling mode. This allows to run profile after inference. recreateCommandQueue(); diff --git a/tests/cpp-runtime/opencl/opencl_timer_test.cc b/tests/cpp-runtime/opencl/opencl_timer_test.cc index 40ec65d8dfe2..6faf2f6a1482 100644 --- a/tests/cpp-runtime/opencl/opencl_timer_test.cc +++ b/tests/cpp-runtime/opencl/opencl_timer_test.cc @@ -46,6 +46,7 @@ TEST(OpenCLTimerNode, nested_timers) { cl_mem cl_buf = clCreateBuffer(workspace->context, CL_MEM_READ_ONLY, BUFF_SIZE * sizeof(cl_int), NULL, &err); OPENCL_CHECK_ERROR(err); + queue = workspace->GetQueue(thr->device); OPENCL_CALL(clEnqueueWriteBuffer(queue, cl_buf, false, 0, BUFF_SIZE * sizeof(cl_int), tmp_buf, 0, NULL, &ev)); OPENCL_CALL(clReleaseMemObject(cl_buf)); diff --git a/tests/cpp-runtime/opencl/run_gtests.cc b/tests/cpp-runtime/opencl/run_gtests.cc index b16ae3efc74d..97297108ae03 100644 --- a/tests/cpp-runtime/opencl/run_gtests.cc +++ b/tests/cpp-runtime/opencl/run_gtests.cc @@ -40,7 +40,7 @@ TVM_REGISTER_GLOBAL("opencl.run_gtests").set_body([](TVMArgs args, TVMRetValue* argv.push_back(const_cast("opencl_run_gtests")); // add parsed arguments - for (int i = 0; i < parsed_args.size(); ++i) { + for (uint i = 0; i < parsed_args.size(); ++i) { argv.push_back(const_cast(parsed_args[i].data())); } diff --git a/tests/scripts/task_config_build_gpu.sh b/tests/scripts/task_config_build_gpu.sh index ca37e30c113e..2f86c20b17d1 100755 --- a/tests/scripts/task_config_build_gpu.sh +++ b/tests/scripts/task_config_build_gpu.sh @@ -30,7 +30,7 @@ echo set\(USE_VULKAN ON\) >> config.cmake echo set\(USE_OPENGL ON\) >> config.cmake echo set\(USE_OPENCL ON\) >> config.cmake echo set\(USE_CPP_RPC ON\) >> config.cmake -echo set\(USE_OPENCL_GTEST /usr/src/googletest\) >> config.cmake +echo set\(USE_OPENCL_GTEST ON\) >> config.cmake echo set\(USE_MICRO ON\) >> config.cmake echo set\(USE_MICRO_STANDALONE_RUNTIME ON\) >> config.cmake echo set\(USE_LLVM \"/usr/bin/llvm-config-9 --link-static\"\) >> config.cmake From 4b8298299de15ec7c682eff969a73e5c1020a54a Mon Sep 17 00:00:00 2001 From: valmat07 Date: Mon, 29 Aug 2022 00:25:47 +0300 Subject: [PATCH 16/30] testing fix for build cpp tests --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 42efcdd44403..cc591f6e5601 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -625,6 +625,8 @@ if(USE_OPENCL AND DEFINED USE_OPENCL_GTEST AND (EXISTS ${USE_OPENCL_GTEST} OR "$ GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG 703bd9caab50b139428cea1aaff9974ebee5742e # release-1.10.0 ) + set(BUILD_GMOCK OFF CACHE BOOL "" FORCE) + set(BUILD_GTEST ON CACHE BOOL "" FORCE) elseif(EXISTS ${USE_OPENCL_GTEST}) FetchContent_Declare(googletest SOURCE_DIR "${USE_OPENCL_GTEST}") include_directories("${USE_OPENCL_GTEST}/include") From a5903ba10af283357f0c95799b38e1a7015545db Mon Sep 17 00:00:00 2001 From: valmat07 Date: Mon, 29 Aug 2022 12:19:21 +0300 Subject: [PATCH 17/30] update googletest git version for opencl tests build --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc591f6e5601..3a62ce95a753 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -623,7 +623,7 @@ if(USE_OPENCL AND DEFINED USE_OPENCL_GTEST AND (EXISTS ${USE_OPENCL_GTEST} OR "$ FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG 703bd9caab50b139428cea1aaff9974ebee5742e # release-1.10.0 + GIT_TAG 830fb567285c63ab5b5873e2e8b02f2249864916 ) set(BUILD_GMOCK OFF CACHE BOOL "" FORCE) set(BUILD_GTEST ON CACHE BOOL "" FORCE) @@ -635,8 +635,8 @@ if(USE_OPENCL AND DEFINED USE_OPENCL_GTEST AND (EXISTS ${USE_OPENCL_GTEST} OR "$ endif() set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) - target_link_libraries(tvm_runtime PUBLIC gtest) - target_link_libraries(tvm PUBLIC gtest) + target_link_libraries(tvm_runtime PRIVATE gtest) + target_link_libraries(tvm PRIVATE gtest) endif() # Set flags for clang From 650c20ee9701a8ebc85cb145aa406fc80550dd15 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Mon, 29 Aug 2022 13:33:37 +0300 Subject: [PATCH 18/30] update cmakelist --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a62ce95a753..6348a63b130e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -625,8 +625,6 @@ if(USE_OPENCL AND DEFINED USE_OPENCL_GTEST AND (EXISTS ${USE_OPENCL_GTEST} OR "$ GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG 830fb567285c63ab5b5873e2e8b02f2249864916 ) - set(BUILD_GMOCK OFF CACHE BOOL "" FORCE) - set(BUILD_GTEST ON CACHE BOOL "" FORCE) elseif(EXISTS ${USE_OPENCL_GTEST}) FetchContent_Declare(googletest SOURCE_DIR "${USE_OPENCL_GTEST}") include_directories("${USE_OPENCL_GTEST}/include") From e9990e90c2f54a9ebbbe9af61b1db4796d1e69d3 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Mon, 29 Aug 2022 14:25:11 +0300 Subject: [PATCH 19/30] Update CMakeList --- CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6348a63b130e..db72125bb496 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -632,7 +632,22 @@ if(USE_OPENCL AND DEFINED USE_OPENCL_GTEST AND (EXISTS ${USE_OPENCL_GTEST} OR "$ message(STATUS "Found OpenCL gtest at ${USE_OPENCL_GTEST}") endif() set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + get_property( + compile_options + DIRECTORY + PROPERTY COMPILE_OPTIONS + ) + set_property( + DIRECTORY + APPEND + PROPERTY COMPILE_OPTIONS -Wno-undef + ) FetchContent_MakeAvailable(googletest) + set_property( + DIRECTORY + PROPERTY COMPILE_OPTIONS ${compile_options} + ) + unset(compile_options) target_link_libraries(tvm_runtime PRIVATE gtest) target_link_libraries(tvm PRIVATE gtest) endif() From afb2c988e2a407e6f923e98e63053a3439b0887c Mon Sep 17 00:00:00 2001 From: valmat07 Date: Mon, 29 Aug 2022 15:10:52 +0300 Subject: [PATCH 20/30] Update CMakeList --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index db72125bb496..3d4b08ff9b26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -640,7 +640,7 @@ if(USE_OPENCL AND DEFINED USE_OPENCL_GTEST AND (EXISTS ${USE_OPENCL_GTEST} OR "$ set_property( DIRECTORY APPEND - PROPERTY COMPILE_OPTIONS -Wno-undef + PROPERTY COMPILE_OPTIONS -Wno-error=sign-compare ) FetchContent_MakeAvailable(googletest) set_property( From 48b5606052e2403e4c84d0aea36690d6b338e491 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Mon, 29 Aug 2022 22:22:23 +0300 Subject: [PATCH 21/30] Disable opencl googletests --- CMakeLists.txt | 43 +++++-------------- .../contrib/test_opencl/test_run_gtests.py | 2 + tests/scripts/task_config_build_gpu.sh | 2 - 3 files changed, 12 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d4b08ff9b26..8048d8becf7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ endif() # Alernatively, use cmake -DOPTION=VALUE through command-line. tvm_option(USE_CUDA "Build with CUDA" OFF) tvm_option(USE_OPENCL "Build with OpenCL" OFF) -tvm_option(USE_OPENCL_GTEST "Path to OpenCL specific gtest version for runtime cpp tests. Or pass ON/OFF value" OFF) +tvm_option(USE_OPENCL_GTEST "Path to OpenCL specific gtest version for runtime cpp tests." /path/to/opencl/gtest) tvm_option(USE_VULKAN "Build with Vulkan" OFF) @@ -617,39 +617,16 @@ if(BUILD_FOR_HEXAGON AND DEFINED USE_HEXAGON_GTEST AND EXISTS ${USE_HEXAGON_GTES include_directories("${USE_HEXAGON_GTEST}/include") endif() -if(USE_OPENCL AND DEFINED USE_OPENCL_GTEST AND (EXISTS ${USE_OPENCL_GTEST} OR "${USE_OPENCL_GTEST}" MATCHES ${IS_TRUE_PATTERN})) +if(USE_OPENCL AND DEFINED USE_OPENCL_GTEST AND EXISTS ${USE_OPENCL_GTEST}) include(FetchContent) - if ("${USE_OPENCL_GTEST}" MATCHES ${IS_TRUE_PATTERN}) - FetchContent_Declare( - googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG 830fb567285c63ab5b5873e2e8b02f2249864916 - ) - elseif(EXISTS ${USE_OPENCL_GTEST}) - FetchContent_Declare(googletest SOURCE_DIR "${USE_OPENCL_GTEST}") - include_directories("${USE_OPENCL_GTEST}/include") - include_directories("${USE_OPENCL_GTEST}/googletest/include") - message(STATUS "Found OpenCL gtest at ${USE_OPENCL_GTEST}") - endif() + FetchContent_Declare(googletest SOURCE_DIR "${USE_OPENCL_GTEST}") set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - get_property( - compile_options - DIRECTORY - PROPERTY COMPILE_OPTIONS - ) - set_property( - DIRECTORY - APPEND - PROPERTY COMPILE_OPTIONS -Wno-error=sign-compare - ) FetchContent_MakeAvailable(googletest) - set_property( - DIRECTORY - PROPERTY COMPILE_OPTIONS ${compile_options} - ) - unset(compile_options) - target_link_libraries(tvm_runtime PRIVATE gtest) - target_link_libraries(tvm PRIVATE gtest) + target_link_libraries(tvm_runtime PUBLIC gtest) + target_link_libraries(tvm PUBLIC gtest) + include_directories("${USE_OPENCL_GTEST}/include") + include_directories("${USE_OPENCL_GTEST}/googletest/include") + message(STATUS "Found OpenCL gtest at ${USE_OPENCL_GTEST}") endif() # Set flags for clang @@ -714,7 +691,7 @@ install(TARGETS tvm_runtime EXPORT ${PROJECT_NAME}Targets DESTINATION lib${LIB_S if(BUILD_FOR_HEXAGON AND DEFINED USE_HEXAGON_GTEST AND EXISTS ${USE_HEXAGON_GTEST}) install(TARGETS gtest EXPORT ${PROJECT_NAME}Targets DESTINATION lib${LIB_SUFFIX}) endif() -if(USE_OPENCL AND DEFINED USE_OPENCL_GTEST AND (EXISTS ${USE_OPENCL_GTEST} OR "${USE_OPENCL_GTEST}" MATCHES ${IS_TRUE_PATTERN})) +if(USE_OPENCL AND DEFINED USE_OPENCL_GTEST AND EXISTS ${USE_OPENCL_GTEST}) install(TARGETS gtest EXPORT ${PROJECT_NAME}Targets DESTINATION lib${LIB_SUFFIX}) endif() @@ -821,4 +798,4 @@ if(${SUMMARIZE}) print_summary() endif() -dump_options_to_file("${TVM_ALL_OPTIONS}") +dump_options_to_file("${TVM_ALL_OPTIONS}") \ No newline at end of file diff --git a/tests/python/contrib/test_opencl/test_run_gtests.py b/tests/python/contrib/test_opencl/test_run_gtests.py index 4afcf7ee8d66..ef6d1f049488 100644 --- a/tests/python/contrib/test_opencl/test_run_gtests.py +++ b/tests/python/contrib/test_opencl/test_run_gtests.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +from inspect import Attribute import os import pytest import numpy as np @@ -28,6 +29,7 @@ # for example to run all "foo" tests twice and observe gtest output run # pytest -sv --gtests_args="--gtest_filter=*foo* --gtest_repeat=2" @tvm.testing.requires_opencl +@pytest.mark.xfail(raises=AttributeError) def test_run_gtests(gtest_args): if ( "TVM_TRACKER_HOST" in os.environ diff --git a/tests/scripts/task_config_build_gpu.sh b/tests/scripts/task_config_build_gpu.sh index 2f86c20b17d1..5163a16da3cd 100755 --- a/tests/scripts/task_config_build_gpu.sh +++ b/tests/scripts/task_config_build_gpu.sh @@ -29,8 +29,6 @@ echo set\(USE_CUDA ON\) >> config.cmake echo set\(USE_VULKAN ON\) >> config.cmake echo set\(USE_OPENGL ON\) >> config.cmake echo set\(USE_OPENCL ON\) >> config.cmake -echo set\(USE_CPP_RPC ON\) >> config.cmake -echo set\(USE_OPENCL_GTEST ON\) >> config.cmake echo set\(USE_MICRO ON\) >> config.cmake echo set\(USE_MICRO_STANDALONE_RUNTIME ON\) >> config.cmake echo set\(USE_LLVM \"/usr/bin/llvm-config-9 --link-static\"\) >> config.cmake From b2382805d2ac5343a939877cff723bfd6c8b65d1 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Tue, 30 Aug 2022 10:49:34 +0300 Subject: [PATCH 22/30] update Opecnl.cmake --- cmake/modules/OpenCL.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/OpenCL.cmake b/cmake/modules/OpenCL.cmake index d71eabda6e6f..fa97a2b5da2b 100644 --- a/cmake/modules/OpenCL.cmake +++ b/cmake/modules/OpenCL.cmake @@ -56,7 +56,7 @@ if(USE_OPENCL) tvm_file_glob(GLOB RUNTIME_OPENCL_SRCS src/runtime/opencl/*.cc) list(APPEND TVM_RUNTIME_LINKER_LIBS ${OpenCL_LIBRARIES}) - if(DEFINED USE_OPENCL_GTEST AND (EXISTS ${USE_OPENCL_GTEST} OR "${USE_OPENCL_GTEST}" MATCHES ${IS_TRUE_PATTERN})) + if(DEFINED USE_OPENCL_GTEST EXISTS ${USE_OPENCL_GTEST}) file_glob_append(RUNTIME_OPENCL_SRCS "${CMAKE_SOURCE_DIR}/tests/cpp-runtime/opencl/*.cc" ) From 4f132bddcb1106f731600f3d0a2586c8f5bc99b3 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Tue, 30 Aug 2022 12:46:43 +0300 Subject: [PATCH 23/30] fix Opecnl.cmake --- cmake/modules/OpenCL.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/OpenCL.cmake b/cmake/modules/OpenCL.cmake index fa97a2b5da2b..430af7e8722c 100644 --- a/cmake/modules/OpenCL.cmake +++ b/cmake/modules/OpenCL.cmake @@ -56,7 +56,7 @@ if(USE_OPENCL) tvm_file_glob(GLOB RUNTIME_OPENCL_SRCS src/runtime/opencl/*.cc) list(APPEND TVM_RUNTIME_LINKER_LIBS ${OpenCL_LIBRARIES}) - if(DEFINED USE_OPENCL_GTEST EXISTS ${USE_OPENCL_GTEST}) + if(DEFINED USE_OPENCL_GTEST AND EXISTS ${USE_OPENCL_GTEST}) file_glob_append(RUNTIME_OPENCL_SRCS "${CMAKE_SOURCE_DIR}/tests/cpp-runtime/opencl/*.cc" ) From f007b8eeb8d982091a6bb476cfaf09332d53c758 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Mon, 5 Sep 2022 19:34:23 +0300 Subject: [PATCH 24/30] Apply comments. Remove xfail decerator for opencl tests. Now specific tests are skipped in the environment script --- tests/cpp-runtime/opencl/run_gtests.cc | 2 +- tests/python/contrib/test_opencl/test_run_gtests.py | 1 - .../python/relay/opencl_texture/test_conv2d_nchw_texture.py | 6 ++---- .../python/relay/opencl_texture/test_conv2d_nhwc_texture.py | 6 ++---- tests/scripts/task_python_integration.sh | 6 +++--- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/tests/cpp-runtime/opencl/run_gtests.cc b/tests/cpp-runtime/opencl/run_gtests.cc index 97297108ae03..ffe86a7f52c0 100644 --- a/tests/cpp-runtime/opencl/run_gtests.cc +++ b/tests/cpp-runtime/opencl/run_gtests.cc @@ -40,7 +40,7 @@ TVM_REGISTER_GLOBAL("opencl.run_gtests").set_body([](TVMArgs args, TVMRetValue* argv.push_back(const_cast("opencl_run_gtests")); // add parsed arguments - for (uint i = 0; i < parsed_args.size(); ++i) { + for (size_t i = 0; i < parsed_args.size(); ++i) { argv.push_back(const_cast(parsed_args[i].data())); } diff --git a/tests/python/contrib/test_opencl/test_run_gtests.py b/tests/python/contrib/test_opencl/test_run_gtests.py index ef6d1f049488..5dd655dd5c21 100644 --- a/tests/python/contrib/test_opencl/test_run_gtests.py +++ b/tests/python/contrib/test_opencl/test_run_gtests.py @@ -29,7 +29,6 @@ # for example to run all "foo" tests twice and observe gtest output run # pytest -sv --gtests_args="--gtest_filter=*foo* --gtest_repeat=2" @tvm.testing.requires_opencl -@pytest.mark.xfail(raises=AttributeError) def test_run_gtests(gtest_args): if ( "TVM_TRACKER_HOST" in os.environ diff --git a/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py b/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py index 9de3aef158f9..2247ca709a28 100644 --- a/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py +++ b/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py @@ -150,7 +150,6 @@ def test_conv2d_inceptionv3_35_35_strides(target, dtype): @tvm.testing.requires_opencl @tvm.testing.parametrize_targets("opencl -device=adreno") -@pytest.mark.xfail(raises=tvm._ffi.base.TVMError) def test_conv2d_resnet50_v2_nchw_3c(target, dtype): input_shape = (1, 3, 224, 224) filter_shape = (64, 3, 7, 7) @@ -422,7 +421,7 @@ def test_conv2d_vgg16_winograd_4d(target, dtype): stat_file = temp.relpath("stat.log") with open(stat_file, "w") as f: f.write( - '{"input": ["opencl -keys=adreno,opencl,gpu -device=adreno -max_num_threads=256", "conv2d_nchw_winograd.image2d", [["TENSOR", [1, 512, 28, 28], "float16"], ["TENSOR", [512, 512, 3, 3], "float16"], [1, 1], [1, 1, 1, 1], [1, 1], "float16"], {}], "config": {"index": 1591, "code_hash": null, "entity": [["auto_unroll_max_step", "ot", 4], ["tile_y", "sp", [-1, 1, 32]], ["tile_x", "sp", [-1, 4, 2]], ["tile_rc", "sp", [-1, 8]]]}, "result": [[0.0037244], 0, 7.06374192237854, 1653898629.7427933], "version": 0.2, "tvm_version": "0.8.dev0"}\n' + f'{{"input": ["opencl -keys=adreno,opencl,gpu -device=adreno -max_num_threads=256", "conv2d_nchw_winograd.image2d", [["TENSOR", [1, 512, 28, 28], "{dtype}"], ["TENSOR", [512, 512, 3, 3], "{dtype}"], [1, 1], [1, 1, 1, 1], [1, 1], "{dtype}"], {{}}], "config": {{"index": 1591, "code_hash": null, "entity": [["auto_unroll_max_step", "ot", 4], ["tile_y", "sp", [-1, 1, 32]], ["tile_x", "sp", [-1, 4, 2]], ["tile_rc", "sp", [-1, 8]]]}}, "result": [[0.0037244], 0, 7.06374192237854, 1653898629.7427933], "version": 0.2, "tvm_version": "0.8.dev0"}}\n' ) graph = build_run_compare( mod, params1, {"data": input_shape}, dtype, target, stat_file=stat_file @@ -469,7 +468,7 @@ def test_conv2d_winograd_conv(target, dtype): stat_file = temp.relpath("stat.log") with open(stat_file, "w") as f: f.write( - '{"input": ["opencl -keys=adreno,opencl,gpu -device=adreno -max_num_threads=256", "conv2d_nchw_winograd.image2d", [["TENSOR", [1, 4, 3, 3], "float16"], ["TENSOR", [8, 4, 3, 3], "float16"], [1, 1], [1, 1, 1, 1], [1, 1], "float16"], {}], "config": {"index": 1591, "code_hash": null, "entity": [["auto_unroll_max_step", "ot", 4], ["tile_y", "sp", [-1, 1, 32]], ["tile_x", "sp", [-1, 4, 2]], ["tile_rc", "sp", [-1, 8]]]}, "result": [[0.0037244], 0, 7.06374192237854, 1653898629.7427933], "version": 0.2, "tvm_version": "0.8.dev0"}\n' + f'{{"input": ["opencl -keys=adreno,opencl,gpu -device=adreno -max_num_threads=256", "conv2d_nchw_winograd.image2d", [["TENSOR", [1, 4, 3, 3], "{dtype}"], ["TENSOR", [8, 4, 3, 3], "{dtype}"], [1, 1], [1, 1, 1, 1], [1, 1], "{dtype}"], {{}}], "config": {{"index": 1591, "code_hash": null, "entity": [["auto_unroll_max_step", "ot", 4], ["tile_y", "sp", [-1, 1, 32]], ["tile_x", "sp", [-1, 4, 2]], ["tile_rc", "sp", [-1, 8]]]}}, "result": [[0.0037244], 0, 7.06374192237854, 1653898629.7427933], "version": 0.2, "tvm_version": "0.8.dev0"}}\n' ) graph = build_run_compare( mod, params1, {"data": input_shape}, dtype, target, stat_file=stat_file @@ -480,7 +479,6 @@ def test_conv2d_winograd_conv(target, dtype): @tvm.testing.requires_opencl @tvm.testing.parametrize_targets("opencl -device=adreno") -@pytest.mark.xfail def test_residual_block(target, dtype): """ - some kind of residual block followed by convolution to have texture after residual block diff --git a/tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py b/tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py index 2bbad3c9831d..37c22137f035 100644 --- a/tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py +++ b/tests/python/relay/opencl_texture/test_conv2d_nhwc_texture.py @@ -304,7 +304,6 @@ def test_conv2d_inceptionv3_35_35_strides(target, dtype): @tvm.testing.requires_opencl @tvm.testing.parametrize_targets("opencl -device=adreno") -@pytest.mark.xfail(raises=tvm._ffi.base.TVMError) def test_conv2d_resnet50_v2_nhwc_3c(target, dtype): input_shape = (1, 224, 224, 3) filter_shape = (7, 7, 3, 64) @@ -386,9 +385,8 @@ def test_conv2d_inceptionv3_nhwc_3c(target, dtype): @tvm.testing.requires_opencl @tvm.testing.parametrize_targets("opencl -device=adreno") -@pytest.mark.xfail(raises=tvm._ffi.base.TVMError) def test_conv2d_1x1_16c16spatial(target, dtype): - input_shape = (1, 256, 256, 16) + input_shape = (1, 128, 128, 16) filter_shape = (4, 4, 16, 32) bias_shape = (1, 1, 1, 32) A = relay.var("data", shape=input_shape, dtype=dtype) @@ -576,7 +574,7 @@ def test_conv2d_vgg16_winograd_4d(target, dtype): stat_file = temp.relpath("stat.log") with open(stat_file, "w") as f: f.write( - '{"input": ["opencl -keys=adreno,opencl,gpu -device=adreno -max_num_threads=256", "conv2d_nhwc_winograd.image2d", [["TENSOR", [1, 28, 28, 512], "float16"], ["TENSOR", [3, 3, 512, 512], "float16"], [1, 1], [1, 1, 1, 1], [1, 1], "float16"], {}], "config": {"index": 1591, "code_hash": null, "entity": [["auto_unroll_max_step", "ot", 4], ["tile_y", "sp", [-1, 1, 32]], ["tile_x", "sp", [-1, 4, 2]], ["tile_rc", "sp", [-1, 8]]]}, "result": [[0.0037244], 0, 7.06374192237854, 1653898629.7427933], "version": 0.2, "tvm_version": "0.8.dev0"}\n' + f'{{"input": ["opencl -keys=adreno,opencl,gpu -device=adreno -max_num_threads=256", "conv2d_nhwc_winograd.image2d", [["TENSOR", [1, 28, 28, 512], "{dtype}"], ["TENSOR", [3, 3, 512, 512], "{dtype}"], [1, 1], [1, 1, 1, 1], [1, 1], "{dtype}"], {{}}], "config": {{"index": 1591, "code_hash": null, "entity": [["auto_unroll_max_step", "ot", 4], ["tile_y", "sp", [-1, 1, 32]], ["tile_x", "sp", [-1, 4, 2]], ["tile_rc", "sp", [-1, 8]]]}}, "result": [[0.0037244], 0, 7.06374192237854, 1653898629.7427933], "version": 0.2, "tvm_version": "0.8.dev0"}}\n' ) graph = build_run_compare( mod, params1, {"data": input_shape}, dtype, target, stat_file=stat_file diff --git a/tests/scripts/task_python_integration.sh b/tests/scripts/task_python_integration.sh index 06bc273639c1..dc8d4fb3287d 100755 --- a/tests/scripts/task_python_integration.sh +++ b/tests/scripts/task_python_integration.sh @@ -61,15 +61,15 @@ run_pytest cython ${TVM_INTEGRATION_TESTSUITE_NAME}-dso_plugin_module-1 apps/dso run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-integration tests/python/integration # Ignoring Arm(R) Ethos(TM)-U NPU tests in the collective to run to run them in parallel in the next step. -run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-contrib tests/python/contrib --ignore=tests/python/contrib/test_ethosu --ignore=tests/python/contrib/test_cmsisnn +run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-contrib tests/python/contrib --ignore=tests/python/contrib/test_ethosu --ignore=tests/python/contrib/test_cmsisnn --ignore=tests/python/contrib/test_opencl # forked is needed because the global registry gets contaminated TVM_TEST_TARGETS="${TVM_RELAY_TEST_TARGETS:-llvm;cuda}" \ run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-relay tests/python/relay -# OpenCL texture test +# OpenCL texture test. Deselected specific tests that fails in CI TVM_TEST_TARGETS="${TVM_RELAY_OPENCL_TEXTURE_TARGETS:-opencl}" \ - run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-opencl-texture tests/python/relay/opencl_texture + run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-opencl-texture tests/python/relay/opencl_texture --deselect=tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py::test_residual_block # Command line driver test run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-driver tests/python/driver From 269e49189dd713fae3cf2863a5bf7f9521ff2f90 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Mon, 5 Sep 2022 21:39:51 +0300 Subject: [PATCH 25/30] minor code changes --- tests/python/contrib/test_opencl/test_run_gtests.py | 1 - tests/python/relay/opencl_texture/utils/adreno_utils.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/contrib/test_opencl/test_run_gtests.py b/tests/python/contrib/test_opencl/test_run_gtests.py index 5dd655dd5c21..4afcf7ee8d66 100644 --- a/tests/python/contrib/test_opencl/test_run_gtests.py +++ b/tests/python/contrib/test_opencl/test_run_gtests.py @@ -15,7 +15,6 @@ # specific language governing permissions and limitations # under the License. -from inspect import Attribute import os import pytest import numpy as np diff --git a/tests/python/relay/opencl_texture/utils/adreno_utils.py b/tests/python/relay/opencl_texture/utils/adreno_utils.py index c490a26512de..1733a25659e5 100644 --- a/tests/python/relay/opencl_texture/utils/adreno_utils.py +++ b/tests/python/relay/opencl_texture/utils/adreno_utils.py @@ -71,6 +71,7 @@ def build_run_compare( tvm_mod_nchwc = gpu_preprocess(tvm_mod) else: tvm_mod_nchwc = tvm_mod + if stat_file is not None: with autotvm.apply_history_best(stat_file): with tvm.transform.PassContext(opt_level=3): From 560219c1020d3cec664c6e2ce551e85f6eda6f49 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Tue, 6 Sep 2022 13:31:24 +0300 Subject: [PATCH 26/30] apply comments --- CMakeLists.txt | 2 +- tests/python/relay/opencl_texture/utils/adreno_utils.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8048d8becf7b..8995f9a87fb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -798,4 +798,4 @@ if(${SUMMARIZE}) print_summary() endif() -dump_options_to_file("${TVM_ALL_OPTIONS}") \ No newline at end of file +dump_options_to_file("${TVM_ALL_OPTIONS}") diff --git a/tests/python/relay/opencl_texture/utils/adreno_utils.py b/tests/python/relay/opencl_texture/utils/adreno_utils.py index 1733a25659e5..c490a26512de 100644 --- a/tests/python/relay/opencl_texture/utils/adreno_utils.py +++ b/tests/python/relay/opencl_texture/utils/adreno_utils.py @@ -71,7 +71,6 @@ def build_run_compare( tvm_mod_nchwc = gpu_preprocess(tvm_mod) else: tvm_mod_nchwc = tvm_mod - if stat_file is not None: with autotvm.apply_history_best(stat_file): with tvm.transform.PassContext(opt_level=3): From 17e49ec70269374954ac110b5b9b6bf0a2721da2 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Tue, 6 Sep 2022 18:24:29 +0300 Subject: [PATCH 27/30] apply comment --- tests/python/relay/opencl_texture/utils/adreno_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/python/relay/opencl_texture/utils/adreno_utils.py b/tests/python/relay/opencl_texture/utils/adreno_utils.py index c490a26512de..27768c3d0cec 100644 --- a/tests/python/relay/opencl_texture/utils/adreno_utils.py +++ b/tests/python/relay/opencl_texture/utils/adreno_utils.py @@ -71,6 +71,7 @@ def build_run_compare( tvm_mod_nchwc = gpu_preprocess(tvm_mod) else: tvm_mod_nchwc = tvm_mod + if stat_file is not None: with autotvm.apply_history_best(stat_file): with tvm.transform.PassContext(opt_level=3): From 42df63a72684ac7afc646c0ca8f23c143f715711 Mon Sep 17 00:00:00 2001 From: valmat07 Date: Wed, 7 Sep 2022 23:14:13 +0300 Subject: [PATCH 28/30] skip test in ci by decorator --- tests/python/contrib/test_opencl/test_run_gtests.py | 1 + .../python/relay/opencl_texture/test_conv2d_nchw_texture.py | 1 + tests/scripts/task_python_integration.sh | 6 ++---- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/python/contrib/test_opencl/test_run_gtests.py b/tests/python/contrib/test_opencl/test_run_gtests.py index 4afcf7ee8d66..bee50da2dd0c 100644 --- a/tests/python/contrib/test_opencl/test_run_gtests.py +++ b/tests/python/contrib/test_opencl/test_run_gtests.py @@ -28,6 +28,7 @@ # for example to run all "foo" tests twice and observe gtest output run # pytest -sv --gtests_args="--gtest_filter=*foo* --gtest_repeat=2" @tvm.testing.requires_opencl +@pytest.mark.skipIf(tvm.testing.utils.IS_IN_CI, reason="failed due to nvidia libOpencl") def test_run_gtests(gtest_args): if ( "TVM_TRACKER_HOST" in os.environ diff --git a/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py b/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py index 2247ca709a28..4c60b638e166 100644 --- a/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py +++ b/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py @@ -479,6 +479,7 @@ def test_conv2d_winograd_conv(target, dtype): @tvm.testing.requires_opencl @tvm.testing.parametrize_targets("opencl -device=adreno") +@pytest.mark.skipIf(tvm.testing.utils.IS_IN_CI, reason="failed due to nvidia libOpencl") def test_residual_block(target, dtype): """ - some kind of residual block followed by convolution to have texture after residual block diff --git a/tests/scripts/task_python_integration.sh b/tests/scripts/task_python_integration.sh index dc8d4fb3287d..5eac7b45ba61 100755 --- a/tests/scripts/task_python_integration.sh +++ b/tests/scripts/task_python_integration.sh @@ -61,16 +61,14 @@ run_pytest cython ${TVM_INTEGRATION_TESTSUITE_NAME}-dso_plugin_module-1 apps/dso run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-integration tests/python/integration # Ignoring Arm(R) Ethos(TM)-U NPU tests in the collective to run to run them in parallel in the next step. -run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-contrib tests/python/contrib --ignore=tests/python/contrib/test_ethosu --ignore=tests/python/contrib/test_cmsisnn --ignore=tests/python/contrib/test_opencl - +run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-contrib tests/python/contrib --ignore=tests/python/contrib/test_ethosu --ignore=tests/python/contrib/test_cmsisnn # forked is needed because the global registry gets contaminated TVM_TEST_TARGETS="${TVM_RELAY_TEST_TARGETS:-llvm;cuda}" \ run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-relay tests/python/relay # OpenCL texture test. Deselected specific tests that fails in CI TVM_TEST_TARGETS="${TVM_RELAY_OPENCL_TEXTURE_TARGETS:-opencl}" \ - run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-opencl-texture tests/python/relay/opencl_texture --deselect=tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py::test_residual_block - + run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-opencl-texture tests/python/relay/opencl_texture # Command line driver test run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-driver tests/python/driver From 307ba3cde5e88adea07df83530dd05597209b30b Mon Sep 17 00:00:00 2001 From: valmat07 Date: Thu, 8 Sep 2022 02:07:53 +0300 Subject: [PATCH 29/30] fix pytest skipif warnings --- tests/python/contrib/test_opencl/test_run_gtests.py | 2 +- tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/python/contrib/test_opencl/test_run_gtests.py b/tests/python/contrib/test_opencl/test_run_gtests.py index bee50da2dd0c..8ce6150940f3 100644 --- a/tests/python/contrib/test_opencl/test_run_gtests.py +++ b/tests/python/contrib/test_opencl/test_run_gtests.py @@ -28,7 +28,7 @@ # for example to run all "foo" tests twice and observe gtest output run # pytest -sv --gtests_args="--gtest_filter=*foo* --gtest_repeat=2" @tvm.testing.requires_opencl -@pytest.mark.skipIf(tvm.testing.utils.IS_IN_CI, reason="failed due to nvidia libOpencl") +@pytest.mark.skipif(True, reason="failed due to nvidia libOpencl in the CI") def test_run_gtests(gtest_args): if ( "TVM_TRACKER_HOST" in os.environ diff --git a/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py b/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py index 4c60b638e166..504a2b4e3ed3 100644 --- a/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py +++ b/tests/python/relay/opencl_texture/test_conv2d_nchw_texture.py @@ -479,7 +479,7 @@ def test_conv2d_winograd_conv(target, dtype): @tvm.testing.requires_opencl @tvm.testing.parametrize_targets("opencl -device=adreno") -@pytest.mark.skipIf(tvm.testing.utils.IS_IN_CI, reason="failed due to nvidia libOpencl") +@pytest.mark.skipif(tvm.testing.utils.IS_IN_CI, reason="failed due to nvidia libOpencl in the CI") def test_residual_block(target, dtype): """ - some kind of residual block followed by convolution to have texture after residual block From dd6aa8b1d7236c0574d0af64859971375c85182f Mon Sep 17 00:00:00 2001 From: valmat07 Date: Thu, 8 Sep 2022 20:11:57 +0300 Subject: [PATCH 30/30] Fix skipif for opencl gtests --- tests/python/contrib/test_opencl/test_run_gtests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/contrib/test_opencl/test_run_gtests.py b/tests/python/contrib/test_opencl/test_run_gtests.py index 8ce6150940f3..ee59086b25f1 100644 --- a/tests/python/contrib/test_opencl/test_run_gtests.py +++ b/tests/python/contrib/test_opencl/test_run_gtests.py @@ -28,7 +28,7 @@ # for example to run all "foo" tests twice and observe gtest output run # pytest -sv --gtests_args="--gtest_filter=*foo* --gtest_repeat=2" @tvm.testing.requires_opencl -@pytest.mark.skipif(True, reason="failed due to nvidia libOpencl in the CI") +@pytest.mark.skipif(tvm.testing.utils.IS_IN_CI, reason="failed due to nvidia libOpencl in the CI") def test_run_gtests(gtest_args): if ( "TVM_TRACKER_HOST" in os.environ