Skip to content

Commit eff8673

Browse files
committed
support x86 enumerator for custom op example script
1 parent 3bbb5c0 commit eff8673

File tree

2 files changed

+47
-19
lines changed

2 files changed

+47
-19
lines changed

backends/qualcomm/tests/test_qnn_delegate.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4974,6 +4974,8 @@ def test_custom_op(self):
49744974
]
49754975
if self.host:
49764976
cmds.extend(["--host", self.host])
4977+
if self.enable_x86_64:
4978+
cmds.extend(["--enable_x86_64"])
49774979

49784980
p = subprocess.Popen(cmds, stdout=subprocess.DEVNULL)
49794981
with Listener((self.ip, self.port)) as listener:

examples/qualcomm/custom_op/custom_ops_1.py

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
)
2727
from executorch.examples.qualcomm.utils import (
2828
build_executorch_binary,
29+
generate_inputs,
2930
make_output_dir,
3031
make_quantizer,
3132
setup_common_args_and_variables,
@@ -230,29 +231,54 @@ def main(args):
230231
if args.compile_only:
231232
sys.exit(0)
232233

233-
# setup required paths accordingly
234-
# qnn_sdk : QNN SDK path setup in environment variable
235-
# artifact_path : path where artifacts were built
236-
# pte_path : path where executorch binary was stored
237-
# device_id : serial number of android device
238-
# workspace : folder for storing artifacts on android device
239-
adb = SimpleADB(
240-
qnn_sdk=os.getenv("QNN_SDK_ROOT"),
241-
build_path=f"{args.build_folder}",
242-
pte_path=f"{args.artifact}/{pte_filename}.pte",
243-
workspace=workspace,
244-
device_id=args.device,
245-
host_id=args.host,
246-
soc_model=args.model,
247-
)
248-
adb.push(inputs=sample_input, input_list=input_list, files=op_package_paths)
249-
adb.execute()
250-
251234
# collect output data
252235
output_data_folder = f"{args.artifact}/outputs"
253236
make_output_dir(output_data_folder)
254237

255-
adb.pull(output_path=args.artifact)
238+
if args.enable_x86_64:
239+
input_list_filename = "input_list.txt"
240+
input_list = f"{args.artifact}/{input_list}"
241+
generate_inputs(args.artifact, input_list_filename, sample_input, input_list)
242+
qnn_sdk = os.getenv("QNN_SDK_ROOT")
243+
assert qnn_sdk, "QNN_SDK_ROOT was not found in environment variable"
244+
target = "x86_64-linux-clang"
245+
246+
runner_cmd = " ".join(
247+
[
248+
f"export LD_LIBRARY_PATH={qnn_sdk}/lib/{target}/:{args.build_folder}/lib &&",
249+
f"./{args.build_folder}/examples/qualcomm/executor_runner/qnn_executor_runner",
250+
f"--model_path {args.artifact}/{pte_filename}.pte",
251+
f"--input_list_path {args.artifact}/{input_list_filename}",
252+
f"--output_folder_path {output_data_folder}",
253+
]
254+
)
255+
subprocess.run(
256+
runner_cmd,
257+
# stdout=subprocess.PIPE,
258+
# stderr=subprocess.STDOUT,
259+
shell=True,
260+
executable="/bin/bash",
261+
capture_output=True,
262+
)
263+
else:
264+
# setup required paths accordingly
265+
# qnn_sdk : QNN SDK path setup in environment variable
266+
# artifact_path : path where artifacts were built
267+
# pte_path : path where executorch binary was stored
268+
# device_id : serial number of android device
269+
# workspace : folder for storing artifacts on android device
270+
adb = SimpleADB(
271+
qnn_sdk=os.getenv("QNN_SDK_ROOT"),
272+
build_path=f"{args.build_folder}",
273+
pte_path=f"{args.artifact}/{pte_filename}.pte",
274+
workspace=workspace,
275+
device_id=args.device,
276+
host_id=args.host,
277+
soc_model=args.model,
278+
)
279+
adb.push(inputs=sample_input, input_list=input_list, files=op_package_paths)
280+
adb.execute()
281+
adb.pull(output_path=args.artifact)
256282

257283
x86_golden = instance(*sample_input)
258284
device_output = torch.from_numpy(

0 commit comments

Comments
 (0)