Skip to content

Commit

Permalink
Add tvm.testing.requires_opencl for Adreno tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elvin-n committed May 2, 2022
1 parent b0d0130 commit ddfa320
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 137 deletions.
9 changes: 9 additions & 0 deletions tests/python/relay/test_conv2d_nchw_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def gpu_preprocess(tvm_mod):
return tvm_mod_nchwc


@tvm.testing.requires_opencl
def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -159,6 +160,7 @@ def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target, gpu_preprocess)


@tvm.testing.requires_opencl
def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad_pass():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -200,6 +202,7 @@ def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad_pass():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target, gpu_preprocess)


@tvm.testing.requires_opencl
def test_conv2d_inceptionv3_35_35_strides():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -241,6 +244,7 @@ def test_conv2d_inceptionv3_35_35_strides():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target, gpu_preprocess)


@tvm.testing.requires_opencl
def test_conv2d_resnet50_v2_nchw_3c():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -283,6 +287,7 @@ def test_conv2d_resnet50_v2_nchw_3c():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_conv2d_inceptionv3_nchw_3c():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -324,6 +329,7 @@ def test_conv2d_inceptionv3_nchw_3c():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_conv2d_1x1_16c16spatial():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -365,6 +371,7 @@ def test_conv2d_1x1_16c16spatial():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_conv2d_4x4_16c16pad():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -406,6 +413,7 @@ def test_conv2d_4x4_16c16pad():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_conv2d_4x4x4_16c16pad():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -447,6 +455,7 @@ def test_conv2d_4x4x4_16c16pad():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_conv2d_yolov3_v2_nchw_3c():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down
13 changes: 13 additions & 0 deletions tests/python/relay/test_conv2d_nhwc_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def gpu_preprocess(tvm_mod):
return tvm_mod_nhwcc


@tvm.testing.requires_opencl
def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -156,6 +157,7 @@ def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16_with_padding():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -197,6 +199,7 @@ def test_conv2d_deeplabv3_1_257_257_32x1_1_32_16_with_padding():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_conv2d_4_35_35_32x3_3_144_16():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -236,6 +239,7 @@ def test_conv2d_4_35_35_32x3_3_144_16():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_conv2d_deeplabv3_1_513_513_3x3_3_3_32():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -275,6 +279,7 @@ def test_conv2d_deeplabv3_1_513_513_3x3_3_3_32():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -316,6 +321,7 @@ def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target, gpu_preprocess)


@tvm.testing.requires_opencl
def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad_pass():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -357,6 +363,7 @@ def test_conv2d_inceptionv3_64x35x35_96x64x3x3_nopad_pass():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target, gpu_preprocess)


@tvm.testing.requires_opencl
def test_conv2d_inceptionv3_35_35_strides():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -398,6 +405,7 @@ def test_conv2d_inceptionv3_35_35_strides():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target, gpu_preprocess)


@tvm.testing.requires_opencl
def test_conv2d_resnet50_v2_nhwc_3c():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -440,6 +448,7 @@ def test_conv2d_resnet50_v2_nhwc_3c():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_conv2d_inceptionv3_nhwc_3c():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -481,6 +490,7 @@ def test_conv2d_inceptionv3_nhwc_3c():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_conv2d_1x1_16c16spatial():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -522,6 +532,7 @@ def test_conv2d_1x1_16c16spatial():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_conv2d_4x4_16c16pad():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -563,6 +574,7 @@ def test_conv2d_4x4_16c16pad():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_conv2d_4x4x4_16c16pad():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -604,6 +616,7 @@ def test_conv2d_4x4x4_16c16pad():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_conv2d_yolov3_v2_nhwc_3c():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down
133 changes: 4 additions & 129 deletions tests/python/relay/test_depthwise_conv2d_nchw_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def gpu_preprocess(tvm_mod):
return tvm_mod_nchwc


@tvm.testing.requires_opencl
def test_depthwise_conv2d_bias_nchwc():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -159,6 +160,7 @@ def test_depthwise_conv2d_bias_nchwc():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target, gpu_preprocess)


@tvm.testing.requires_opencl
def test_depthwise_conv2d_nchwc():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -197,6 +199,7 @@ def test_depthwise_conv2d_nchwc():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target, gpu_preprocess)


@tvm.testing.requires_opencl
def test_depthwise_conv2d_bias_nchw():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -240,6 +243,7 @@ def test_depthwise_conv2d_bias_nchw():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_depthwise_conv2d_repack_bias_nchw():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -281,132 +285,3 @@ def test_depthwise_conv2d_repack_bias_nchw():
}

build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


# def test_conv2d_inceptionv3_nchw_3c():
# target="opencl --device=adreno"
# dtype="float16"

# input_shape = (1, 3, 299, 299)
# filter_shape = (64, 3, 3, 3)
# bias_shape = (1, 64, 1, 1)
# A = relay.var("data", shape=input_shape, dtype=dtype)
# B = relay.var("weight", shape=filter_shape, dtype=dtype)
# bias = relay.var("bias", shape=bias_shape, dtype=dtype)

# #C = relay.nn.relu(A)
# conv = relay.nn.conv2d(A, B, data_layout="NCHW", kernel_layout="OIHW",
# padding=[0,0,0,0],strides=[2,2],
# out_dtype=dtype, channels=64, kernel_size=(3,3))
# D = relay.op.add(conv, bias)
# D = relay.op.nn.relu(D)

# mod = relay.Function([A, B, bias], D)
# np.random.seed(0)
# initializer = relay.testing.init.Xavier()
# filter_data = np.zeros(filter_shape).astype(dtype)
# bias_data = np.zeros(bias_shape).astype(dtype)
# initializer("weight", filter_data)
# initializer("bias", bias_data)
# params1 = {
# "weight": tvm.nd.array(filter_data),
# "bias" : tvm.nd.array(bias_data),
# }

# build_run_compare (mod, params1, {"data": input_shape}, dtype, target)

# def test_conv2d_1x1_16c16spatial():
# target="opencl --device=adreno"
# dtype="float16"

# input_shape = (1, 16, 256, 256)
# filter_shape = (32, 16, 4, 4)
# bias_shape = (1, 32, 1, 1)
# A = relay.var("data", shape=input_shape, dtype=dtype)
# B = relay.var("weight", shape=filter_shape, dtype=dtype)
# bias = relay.var("bias", shape=bias_shape, dtype=dtype)

# #C = relay.nn.relu(A)
# conv = relay.nn.conv2d(A, B, data_layout="NCHW", kernel_layout="OIHW",
# padding=[0,0,0,0],strides=[2,2],
# out_dtype=dtype, channels=32, kernel_size=(4,4))
# D = relay.op.add(conv, bias)
# D = relay.op.nn.relu(D)

# mod = relay.Function([A, B, bias], D)
# np.random.seed(0)
# initializer = relay.testing.init.Xavier()
# filter_data = np.zeros(filter_shape).astype(dtype)
# bias_data = np.zeros(bias_shape).astype(dtype)
# initializer("weight", filter_data)
# initializer("bias", bias_data)
# params1 = {
# "weight": tvm.nd.array(filter_data),
# "bias" : tvm.nd.array(bias_data),
# }

# build_run_compare (mod, params1, {"data": input_shape}, dtype, target)

# def test_conv2d_4x4_16c16pad():
# target="opencl --device=adreno"
# dtype="float16"

# input_shape = (1, 32, 256, 256)
# filter_shape = (32, 32, 4, 4)
# bias_shape = (1, 32, 1, 1)
# A = relay.var("data", shape=input_shape, dtype=dtype)
# B = relay.var("weight", shape=filter_shape, dtype=dtype)
# bias = relay.var("bias", shape=bias_shape, dtype=dtype)

# #C = relay.nn.relu(A)
# conv = relay.nn.conv2d(A, B, data_layout="NCHW", kernel_layout="OIHW",
# padding=[3,3,0,0],strides=[2,2],
# out_dtype=dtype, channels=32, kernel_size=(4,4))
# D = relay.op.add(conv, bias)
# D = relay.op.nn.relu(D)

# mod = relay.Function([A, B, bias], D)
# np.random.seed(0)
# initializer = relay.testing.init.Xavier()
# filter_data = np.zeros(filter_shape).astype(dtype)
# bias_data = np.zeros(bias_shape).astype(dtype)
# initializer("weight", filter_data)
# initializer("bias", bias_data)
# params1 = {
# "weight": tvm.nd.array(filter_data),
# "bias" : tvm.nd.array(bias_data),
# }

# build_run_compare (mod, params1, {"data": input_shape}, dtype, target)


# def test_conv2d_yolov3_v2_nchw_3c():
# target="opencl --device=adreno"
# dtype="float16"

# input_shape = (1, 1024, 13, 13)
# filter_shape = (255, 1024, 1, 1)
# A = relay.var("data", shape=input_shape, dtype=dtype)
# B = relay.var("weight", shape=filter_shape, dtype=dtype)

# conv = relay.nn.conv2d(A, B, data_layout="NCHW", kernel_layout="OIHW",
# padding=[0,0,0,0],strides=[1,1],
# out_dtype=dtype, channels=255, kernel_size=(1,1))

# mod = relay.Function([A, B], conv)
# # mod, params = relay.testing.init.create_workload(func)
# np.random.seed(0)
# initializer = relay.testing.init.Xavier()
# filter_data = np.zeros(filter_shape).astype(dtype)
# initializer("weight", filter_data)
# params = {
# "weight": tvm.nd.array(filter_data),
# }

# build_run_compare (mod, params, {"data": input_shape}, dtype, target)

if __name__ == "__main__":
test_depthwise_conv2d_bias_nchwc()
test_depthwise_conv2d_nchwc()
test_depthwise_conv2d_bias_nchw()
test_depthwise_conv2d_repack_bias_nchw()
13 changes: 5 additions & 8 deletions tests/python/relay/test_depthwise_conv2d_nhwc_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def gpu_preprocess(tvm_mod):
return tvm_mod_nhwcc


@tvm.testing.requires_opencl
def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -159,6 +160,7 @@ def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_depthwise_conv2d_deeplabv3_4_35_35_576x3_3_576_1():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -200,6 +202,7 @@ def test_depthwise_conv2d_deeplabv3_4_35_35_576x3_3_576_1():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1_with_padding():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -243,6 +246,7 @@ def test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1_with_padding():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_depthwise_conv2d_1_513_513_7x3_3_7_1():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -283,6 +287,7 @@ def test_depthwise_conv2d_1_513_513_7x3_3_7_1():
build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


@tvm.testing.requires_opencl
def test_depthwise_conv2d_1_513_513_3x3_3_3_1():
target = "opencl --device=adreno"
dtype = "float16"
Expand Down Expand Up @@ -321,11 +326,3 @@ def test_depthwise_conv2d_1_513_513_3x3_3_3_1():
}

build_run_compare(mod, params1, {"data": input_shape}, dtype, target)


if __name__ == "__main__":
test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1()
# test_depthwise_conv2d_deeplabv3_1_129_129_144x3_3_144_1_with_padding()
# test_depthwise_conv2d_deeplabv3_4_35_35_576x3_3_576_1()
# test_depthwise_conv2d_1_513_513_7x3_3_7_1()
# test_depthwise_conv2d_1_513_513_3x3_3_3_1()

0 comments on commit ddfa320

Please sign in to comment.