diff --git a/tests/python/contrib/test_hexagon/test_launcher.py b/tests/python/contrib/test_hexagon/test_launcher.py index 707bd7218b374..b2609f77507f1 100644 --- a/tests/python/contrib/test_hexagon/test_launcher.py +++ b/tests/python/contrib/test_hexagon/test_launcher.py @@ -43,17 +43,11 @@ @requires_hexagon_toolchain def test_add_hvx(android_serial_number, tvm_tracker_host, tvm_tracker_port, adb_server_socket): - #for dtype in ['float16', 'int8', 'float32',]: - for dtype in ['int8', 'float32',]: - #for dtype in ['float32',]: + for dtype in ['int8',]: for sched_type in [1,2,]: for mem_scope in [None, "global.vtcm"]: version_name = 'dtype:{}-schedtype:{}-memscope:{}'.format(dtype, str(sched_type), str(mem_scope)) - #Eliminate potentially problematic characters... - #version_name = version_name.replace('.', '_') - #version_name = version_name.replace(':', '_') - print("CONFIGURATION: {}".format(version_name)) #time.sleep(5) @@ -102,7 +96,7 @@ def test_add_hvx(android_serial_number, tvm_tracker_host, tvm_tracker_port, adb_ ) temp = utils.tempdir() - if True: + if False: dso_binary = "test_binary.so".format(version_name) dso_binary_path = temp.relpath(dso_binary) else: @@ -117,60 +111,61 @@ def test_add_hvx(android_serial_number, tvm_tracker_host, tvm_tracker_port, adb_ if not android_serial_number: pytest.skip(msg="Skip hardware test since ANDROID_SERIAL_NUMBER is not set.") - rpc_info = { - "rpc_tracker_host": tvm_tracker_host, - "rpc_tracker_port": tvm_tracker_port, - "rpc_server_port": RPC_SERVER_PORT + 0, # See note at the beginning of the file - "adb_server_socket": adb_server_socket, - } - launcher = HexagonLauncher(serial_number=android_serial_number, rpc_info=rpc_info) - launcher.upload(dso_binary_path, dso_binary) - launcher.start_server() + if False: + rpc_info = { + "rpc_tracker_host": tvm_tracker_host, + "rpc_tracker_port": tvm_tracker_port, + "rpc_server_port": RPC_SERVER_PORT + 0, # See note at the beginning of the file + "adb_server_socket": adb_server_socket, + } + launcher = HexagonLauncher(serial_number=android_serial_number, rpc_info=rpc_info) + launcher.upload(dso_binary_path, dso_binary) + launcher.start_server() - with launcher.start_session() as sess: - mod = launcher.load_module(dso_binary, sess) + with launcher.start_session() as sess: + mod = launcher.load_module(dso_binary, sess) - # TODO: I think I was hitting an error because I tried to write into - # "B_data.numpy()[...]"; i.e. going through the TVM wrapper object - # after it was created. Not sure if this is necessary. - host_numpy_A_data = np.ndarray(shape, dtype=dtype) - host_numpy_B_data = np.ndarray(shape, dtype=dtype) - host_numpy_C_data = np.ndarray(shape, dtype=dtype) - host_numpy_C_data_expected = np.ndarray(shape, dtype=dtype) + # TODO: I think I was hitting an error because I tried to write into + # "B_data.numpy()[...]"; i.e. going through the TVM wrapper object + # after it was created. Not sure if this is necessary. + host_numpy_A_data = np.ndarray(shape, dtype=dtype) + host_numpy_B_data = np.ndarray(shape, dtype=dtype) + host_numpy_C_data = np.ndarray(shape, dtype=dtype) + host_numpy_C_data_expected = np.ndarray(shape, dtype=dtype) - def intended_val_A(i,j): - return i + j + def intended_val_A(i,j): + return i + j - def intended_val_B(i,j): - return (i+1) * (j+1) + def intended_val_B(i,j): + return (i+1) * (j+1) - for i in range(shape[0]): - for j in range(shape[1]): - host_numpy_A_data[i,j] = intended_val_A(i,j) - host_numpy_B_data[i,j] = intended_val_B(i,j) - host_numpy_C_data_expected[i,j] = intended_val_A(i,j) + intended_val_B(i,j) + for i in range(shape[0]): + for j in range(shape[1]): + host_numpy_A_data[i,j] = intended_val_A(i,j) + host_numpy_B_data[i,j] = intended_val_B(i,j) + host_numpy_C_data_expected[i,j] = intended_val_A(i,j) + intended_val_B(i,j) - #A_data = tvm.nd.array(host_numpy_A_data, device=sess.device, mem_scope=mem_scope) - #B_data = tvm.nd.array(host_numpy_B_data, device=sess.device, mem_scope=mem_scope) - #C_data = tvm.nd.array(np.ndarray(shape, dtype=dtype), device=sess.device, mem_scope=mem_scope) + #A_data = tvm.nd.array(host_numpy_A_data, device=sess.device, mem_scope=mem_scope) + #B_data = tvm.nd.array(host_numpy_B_data, device=sess.device, mem_scope=mem_scope) + #C_data = tvm.nd.array(np.ndarray(shape, dtype=dtype), device=sess.device, mem_scope=mem_scope) - A_data = tvm.nd.empty(shape, dtype, sess.device, mem_scope) - A_data.copyfrom(host_numpy_A_data) + A_data = tvm.nd.empty(shape, dtype, sess.device, mem_scope) + A_data.copyfrom(host_numpy_A_data) - B_data = tvm.nd.empty(shape, dtype, sess.device, mem_scope) - B_data.copyfrom(host_numpy_B_data) + B_data = tvm.nd.empty(shape, dtype, sess.device, mem_scope) + B_data.copyfrom(host_numpy_B_data) - C_data = tvm.nd.empty(shape, dtype, sess.device, mem_scope) - #C_data.copyfrom(host_numpy_C_data) + C_data = tvm.nd.empty(shape, dtype, sess.device, mem_scope) + #C_data.copyfrom(host_numpy_C_data) - #import pdb; pdb.set_trace() + #import pdb; pdb.set_trace() - mod["add_hvx"](A_data, B_data, C_data) + mod["add_hvx"](A_data, B_data, C_data) - result = C_data.numpy() - assert (result == host_numpy_C_data_expected).all() + result = C_data.numpy() + assert (result == host_numpy_C_data_expected).all() - launcher.stop_server() + launcher.stop_server() @requires_hexagon_toolchain