Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#287: Hotfix for seg fault when executing dir of flatbuffers #288

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions runtime/tools/python/ttrt/common/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def read(args):
arg_binary = args.binary
arg_clean_artifacts = args.clean_artifacts
arg_save_artifacts = args.save_artifacts
arg_section = arg.section
arg_section = args.section

# preprocessing
if os.path.isdir(arg_binary):
Expand Down Expand Up @@ -129,11 +129,18 @@ def run(args):

# execution
print("executing action for all provided flatbuffers")
system_desc, device_ids = ttrt.runtime.get_current_system_desc()
device = ttrt.runtime.open_device(device_ids)
atexit.register(lambda: ttrt.runtime.close_device(device))

for (binary_name, fbb, fbb_dict) in fbb_list:
torch_inputs[binary_name] = []
torch_outputs[binary_name] = []
program = fbb_dict["programs"][program_index]
print(f"running program[{program_index}]:", program["name"])
print(
f"running binary={binary_name} with program[{program_index}]:",
program["name"],
)

for i in program["inputs"]:
torch_tensor = torch.randn(
Expand Down Expand Up @@ -180,9 +187,6 @@ def run(args):
total_inputs.append(inputs)
total_outputs.append(outputs)

system_desc, device_ids = ttrt.runtime.get_current_system_desc()
device = ttrt.runtime.open_device(device_ids)
atexit.register(lambda: ttrt.runtime.close_device(device))
for loop in range(arg_loops):
ttrt.runtime.submit(device, fbb, 0, total_inputs[loop], total_outputs[loop])
print(f"finished loop={loop}")
Expand Down
Loading