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

Back2back apps #132

Merged
merged 3 commits into from
May 18, 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
42 changes: 34 additions & 8 deletions sam/onyx/generate_matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,20 +489,22 @@ def create_matrix_from_point_list(name, pt_list, shape, use_fp=False) -> MatrixG
return mg


def convert_aha_glb_output_file(glbfile, output_dir, tiles):
def convert_aha_glb_output_file(glbfile, output_dir, tiles, batches):

glbfile_s = os.path.basename(glbfile).rstrip(".txt")

files = []
if 'mode_vals' in glbfile:
# num_blocks = 1
for i in range(tiles):
files.append(f"{output_dir}/{glbfile_s}_tile{i}")
for j in range(batches):
for i in range(tiles):
files.append(f"{output_dir}/{glbfile_s}_batch{j}_tile{i}")
else:
# num_blocks = 2
for i in range(tiles):
files.append(f"{output_dir}/{glbfile_s}_seg_tile{i}")
files.append(f"{output_dir}/{glbfile_s}_crd_tile{i}")
for j in range(batches):
for i in range(tiles):
files.append(f"{output_dir}/{glbfile_s}_seg_batch{j}_tile{i}")
files.append(f"{output_dir}/{glbfile_s}_crd_batch{j}_tile{i}")

straightline = []

Expand All @@ -513,18 +515,42 @@ def convert_aha_glb_output_file(glbfile, output_dir, tiles):
sp_line = line.strip().split(" ")
for sp_line_tok in sp_line:
sp_line_tok_stripped = sp_line_tok.strip()
if (sp_line_tok_stripped == ""):
continue
straightline.append(int(sp_line_tok_stripped, base=16))

# Now we have straightline having the items in order
# Now write them to the output

if 'mode_vals' in glbfile:
num_blocks = 1
else:
num_blocks = 2

sl_ptr = 0
tile = 0
batch = 0
block = 0
for file_path in files:
num_items = straightline[sl_ptr]
sl_ptr += 1
with open(file_path, "w+") as fh_:
for _ in range(num_items):
# Edge case, write out 0 is this correct?
if num_items == 0:
fh_.write(f"{straightline[sl_ptr]:04X}\n")
sl_ptr += 1
else:
for _ in range(num_items):
fh_.write(f"{straightline[sl_ptr]:04X}\n")
sl_ptr += 1
block += 1
if block == num_blocks:
block = 0
tile += 1
if tile == tiles:
tile = 0
batch = batch + 1
# TODO hardcoded value for now
sl_ptr = 32768 * batch # size of glb


def find_file_based_on_sub_string(files_dir, sub_string_list):
Expand Down
Loading