elvin-n commented on code in PR #11878: URL: https://github.com/apache/tvm/pull/11878#discussion_r931845224
########## tests/python/relay/test_conv2d_nchw_texture.py: ########## @@ -435,3 +435,558 @@ def test_conv2d_vgg16_winograd_4d(): graph = build_run_compare(mod, params1, {"data": input_shape}, dtype, target) matches = re.findall("winograd", graph) assert len(matches) > 0 + + +@tvm.testing.requires_opencl +def test_residual_block(): + target = "opencl --device=adreno" + dtype = "float16" + + input_shape = (1, 32, 40, 40) + filter_shape1 = (32, 32, 2, 2) + filter_shape2 = (32, 32, 1, 1) + filter_shape3 = (32, 32, 2, 2) + bias_shape1 = (1, 32, 1, 1) + A = relay.var("data", shape=input_shape, dtype=dtype) + W1 = relay.var("weight1", shape=filter_shape1, dtype=dtype) + B1 = relay.var("bias1", shape=bias_shape1, dtype=dtype) + W2 = relay.var("weight2", shape=filter_shape2, dtype=dtype) + W3 = relay.var("weight3", shape=filter_shape3, dtype=dtype) + + conv1 = relay.nn.conv2d( + A, + W1, + data_layout="NCHW", + kernel_layout="OIHW", + padding=[0, 0, 0, 0], + strides=[2, 2], + out_dtype=dtype, + channels=32, + kernel_size=(2, 2), + ) + D = relay.op.add(conv1, B1) + D = relay.op.nn.relu(D) + + conv2 = relay.nn.conv2d( + D, + W2, + data_layout="NCHW", + kernel_layout="OIHW", + padding=[0, 0, 0, 0], + strides=[1, 1], + out_dtype=dtype, + channels=32, + kernel_size=(1, 1), + ) + D = relay.op.add(conv2, D) + D = D * relay.const(0.15, "float16") + D = relay.op.nn.relu(D) + + conv3 = relay.nn.conv2d( + D, + W3, + data_layout="NCHW", + kernel_layout="OIHW", + padding=[0, 0, 0, 0], + strides=[2, 2], + out_dtype=dtype, + channels=32, + kernel_size=(2, 2), + ) + D = relay.op.nn.relu(conv3) + + mod = relay.Function([A, W1, B1, W2, W3], D) + np.random.seed(0) + initializer = relay.testing.init.Xavier() + filter_data1 = np.zeros(filter_shape1).astype(dtype) + bias_data1 = np.zeros(bias_shape1).astype(dtype) + initializer("weight", filter_data1) + initializer("bias", bias_data1) + filter_data2 = np.zeros(filter_shape2).astype(dtype) + initializer("weight", filter_data2) + filter_data3 = np.zeros(filter_shape3).astype(dtype) + initializer("weight", filter_data3) + params1 = { + "weight1": tvm.nd.array(filter_data1), + "bias1": tvm.nd.array(bias_data1), + "weight2": tvm.nd.array(filter_data2), + "weight3": tvm.nd.array(filter_data3), + } + + static_memory_scope = [ + "", + "global", + "global.texture-weight", + "global.texture-weight", + "global.texture", + "global.texture-weight", + "global", + "global.texture", + "global.texture-weight", + "", Review Comment: The network output memory scope is "" / (empty string) that is _ideologically_ synonym for "global" but attempt to mark the tail by "global" memory scope causes PlanDevice pass behaves unexpectedly and fails the transformation. Sometimes PlanDevice try to put device_copy from global to empty scope, sometime just aborts. The idea of having mapping of `op->scope` instead of just array was dictated by the nature how memory scopes are stored in json. To compare the mapped values, we have to build such mapping basing on json. That is doable but requires more efforts. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org