Skip to content

Commit a1114b6

Browse files
author
Christian Convey
committed
various changes
1 parent c2b2426 commit a1114b6

File tree

1 file changed

+44
-49
lines changed

1 file changed

+44
-49
lines changed

tests/python/contrib/test_hexagon/test_launcher.py

Lines changed: 44 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,11 @@
4343

4444
@requires_hexagon_toolchain
4545
def test_add_hvx(android_serial_number, tvm_tracker_host, tvm_tracker_port, adb_server_socket):
46-
#for dtype in ['float16', 'int8', 'float32',]:
47-
for dtype in ['int8', 'float32',]:
48-
#for dtype in ['float32',]:
46+
for dtype in ['int8',]:
4947
for sched_type in [1,2,]:
5048
for mem_scope in [None, "global.vtcm"]:
5149
version_name = 'dtype:{}-schedtype:{}-memscope:{}'.format(dtype, str(sched_type), str(mem_scope))
5250

53-
#Eliminate potentially problematic characters...
54-
#version_name = version_name.replace('.', '_')
55-
#version_name = version_name.replace(':', '_')
56-
5751
print("CONFIGURATION: {}".format(version_name))
5852
#time.sleep(5)
5953

@@ -102,7 +96,7 @@ def test_add_hvx(android_serial_number, tvm_tracker_host, tvm_tracker_port, adb_
10296
)
10397

10498
temp = utils.tempdir()
105-
if True:
99+
if False:
106100
dso_binary = "test_binary.so".format(version_name)
107101
dso_binary_path = temp.relpath(dso_binary)
108102
else:
@@ -117,60 +111,61 @@ def test_add_hvx(android_serial_number, tvm_tracker_host, tvm_tracker_port, adb_
117111
if not android_serial_number:
118112
pytest.skip(msg="Skip hardware test since ANDROID_SERIAL_NUMBER is not set.")
119113

120-
rpc_info = {
121-
"rpc_tracker_host": tvm_tracker_host,
122-
"rpc_tracker_port": tvm_tracker_port,
123-
"rpc_server_port": RPC_SERVER_PORT + 0, # See note at the beginning of the file
124-
"adb_server_socket": adb_server_socket,
125-
}
126-
launcher = HexagonLauncher(serial_number=android_serial_number, rpc_info=rpc_info)
127-
launcher.upload(dso_binary_path, dso_binary)
128-
launcher.start_server()
114+
if False:
115+
rpc_info = {
116+
"rpc_tracker_host": tvm_tracker_host,
117+
"rpc_tracker_port": tvm_tracker_port,
118+
"rpc_server_port": RPC_SERVER_PORT + 0, # See note at the beginning of the file
119+
"adb_server_socket": adb_server_socket,
120+
}
121+
launcher = HexagonLauncher(serial_number=android_serial_number, rpc_info=rpc_info)
122+
launcher.upload(dso_binary_path, dso_binary)
123+
launcher.start_server()
129124

130-
with launcher.start_session() as sess:
131-
mod = launcher.load_module(dso_binary, sess)
125+
with launcher.start_session() as sess:
126+
mod = launcher.load_module(dso_binary, sess)
132127

133-
# TODO: I think I was hitting an error because I tried to write into
134-
# "B_data.numpy()[...]"; i.e. going through the TVM wrapper object
135-
# after it was created. Not sure if this is necessary.
136-
host_numpy_A_data = np.ndarray(shape, dtype=dtype)
137-
host_numpy_B_data = np.ndarray(shape, dtype=dtype)
138-
host_numpy_C_data = np.ndarray(shape, dtype=dtype)
139-
host_numpy_C_data_expected = np.ndarray(shape, dtype=dtype)
128+
# TODO: I think I was hitting an error because I tried to write into
129+
# "B_data.numpy()[...]"; i.e. going through the TVM wrapper object
130+
# after it was created. Not sure if this is necessary.
131+
host_numpy_A_data = np.ndarray(shape, dtype=dtype)
132+
host_numpy_B_data = np.ndarray(shape, dtype=dtype)
133+
host_numpy_C_data = np.ndarray(shape, dtype=dtype)
134+
host_numpy_C_data_expected = np.ndarray(shape, dtype=dtype)
140135

141-
def intended_val_A(i,j):
142-
return i + j
136+
def intended_val_A(i,j):
137+
return i + j
143138

144-
def intended_val_B(i,j):
145-
return (i+1) * (j+1)
139+
def intended_val_B(i,j):
140+
return (i+1) * (j+1)
146141

147-
for i in range(shape[0]):
148-
for j in range(shape[1]):
149-
host_numpy_A_data[i,j] = intended_val_A(i,j)
150-
host_numpy_B_data[i,j] = intended_val_B(i,j)
151-
host_numpy_C_data_expected[i,j] = intended_val_A(i,j) + intended_val_B(i,j)
142+
for i in range(shape[0]):
143+
for j in range(shape[1]):
144+
host_numpy_A_data[i,j] = intended_val_A(i,j)
145+
host_numpy_B_data[i,j] = intended_val_B(i,j)
146+
host_numpy_C_data_expected[i,j] = intended_val_A(i,j) + intended_val_B(i,j)
152147

153-
#A_data = tvm.nd.array(host_numpy_A_data, device=sess.device, mem_scope=mem_scope)
154-
#B_data = tvm.nd.array(host_numpy_B_data, device=sess.device, mem_scope=mem_scope)
155-
#C_data = tvm.nd.array(np.ndarray(shape, dtype=dtype), device=sess.device, mem_scope=mem_scope)
148+
#A_data = tvm.nd.array(host_numpy_A_data, device=sess.device, mem_scope=mem_scope)
149+
#B_data = tvm.nd.array(host_numpy_B_data, device=sess.device, mem_scope=mem_scope)
150+
#C_data = tvm.nd.array(np.ndarray(shape, dtype=dtype), device=sess.device, mem_scope=mem_scope)
156151

157-
A_data = tvm.nd.empty(shape, dtype, sess.device, mem_scope)
158-
A_data.copyfrom(host_numpy_A_data)
152+
A_data = tvm.nd.empty(shape, dtype, sess.device, mem_scope)
153+
A_data.copyfrom(host_numpy_A_data)
159154

160-
B_data = tvm.nd.empty(shape, dtype, sess.device, mem_scope)
161-
B_data.copyfrom(host_numpy_B_data)
155+
B_data = tvm.nd.empty(shape, dtype, sess.device, mem_scope)
156+
B_data.copyfrom(host_numpy_B_data)
162157

163-
C_data = tvm.nd.empty(shape, dtype, sess.device, mem_scope)
164-
#C_data.copyfrom(host_numpy_C_data)
158+
C_data = tvm.nd.empty(shape, dtype, sess.device, mem_scope)
159+
#C_data.copyfrom(host_numpy_C_data)
165160

166-
#import pdb; pdb.set_trace()
161+
#import pdb; pdb.set_trace()
167162

168-
mod["add_hvx"](A_data, B_data, C_data)
163+
mod["add_hvx"](A_data, B_data, C_data)
169164

170-
result = C_data.numpy()
171-
assert (result == host_numpy_C_data_expected).all()
165+
result = C_data.numpy()
166+
assert (result == host_numpy_C_data_expected).all()
172167

173-
launcher.stop_server()
168+
launcher.stop_server()
174169

175170

176171
@requires_hexagon_toolchain

0 commit comments

Comments
 (0)