Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit f5a72d8

Browse files
Minor Changes
1 parent 010ff49 commit f5a72d8

File tree

5 files changed

+26
-17
lines changed

5 files changed

+26
-17
lines changed

tftrt/examples/benchmark_runner.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,18 @@ def engine_build_input_fn(num_batches, model_phase):
224224
f"`{self._args.output_saved_model_dir}`"
225225
)
226226

227-
savedmodel_outputs = graph_func.structured_outputs
227+
savedmodel_outputs = print_dict(
228+
graph_func.structured_outputs,
229+
redirect_to_str=True
230+
)
228231

229-
chosen_outputs = sorted(self._args.output_tensors_name.split(","))
232+
chosen_outputs = "\n - ".join(
233+
sorted(self._args.output_tensors_name.split(","))
234+
)
230235

231-
self._debug_print(f"Available Output Tensors: {savedmodel_outputs}")
232-
self._debug_print(f"Chosen Output Tensor: {chosen_outputs}")
236+
self._debug_print(f"Available Output Tensors:\n{savedmodel_outputs}")
237+
print() # visual spacing
238+
self._debug_print(f"Chosen Output Tensor:\n - {chosen_outputs}")
233239

234240
return graph_func
235241

tftrt/examples/benchmark_utils.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,18 @@ def wrapper(*args, **kwargs):
2323
return wrapper
2424

2525

26-
def print_dict(input_dict, prefix=' ', postfix=''):
27-
for k, v in sorted(input_dict.items()):
28-
print(
29-
'{prefix}{arg_name}: {value}{postfix}'.format(
30-
prefix=prefix,
31-
arg_name=k,
32-
value='%.1f' % v if isinstance(v, float) else v,
33-
postfix=postfix
34-
)
35-
)
26+
def print_dict(input_dict, prefix=' ', postfix='', redirect_to_str=False):
27+
rslt_str = ""
28+
for key, val in sorted(input_dict.items()):
29+
val = f"{val:.1f}" if isinstance(val, float) else val
30+
tmp_str = f"{prefix}- {key}: {val}{postfix}"
31+
if not redirect_to_str:
32+
print(tmp_str)
33+
else:
34+
rslt_str += f"{tmp_str}\n"
35+
36+
if redirect_to_str:
37+
return rslt_str.rstrip()
3638

3739

3840
@contextmanager

tftrt/examples/image_classification/scripts/base_script.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,12 @@ COMMAND="${PREPEND_COMMAND} python image_classification.py \
163163
--input_size ${INPUT_SIZE} \
164164
--preprocess_method ${PREPROCESS_METHOD} \
165165
--num_classes ${NUM_CLASSES} \
166+
--total_max_samples=49920 \
166167
${OUTPUT_TENSOR_IDX_FLAG} \
167168
${OUTPUT_TENSOR_NAME_FLAG} \
168169
${BYPASS_ARGUMENTS}"
169170

170-
COMMAND=$(echo "${COMMAND}" | tr -s " ")
171+
COMMAND=$(echo ${COMMAND} | sed 's/ *$//g') # Trimming whitespaces
171172

172173
echo -e "**Executing:**\n\n${COMMAND}\n"
173174
sleep 5

tftrt/examples/object_detection/scripts/base_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ COMMAND="${PREPEND_COMMAND} python object_detection.py \
152152
--max_workspace_size ${MAX_WORKSPACE_SIZE} \
153153
${BYPASS_ARGUMENTS}"
154154

155-
COMMAND=$(echo "${COMMAND}" | tr -s " ")
155+
COMMAND=$(echo ${COMMAND} | sed 's/ *$//g') # Trimming whitespaces
156156

157157
echo -e "**Executing:**\n\n${COMMAND}\n"
158158
sleep 5

tftrt/examples/transformers/scripts/base_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ COMMAND="${PREPEND_COMMAND} python transformers.py \
138138
--minimum_segment_size ${MIN_SEGMENT_SIZE} \
139139
${BYPASS_ARGUMENTS}"
140140

141-
COMMAND=$(echo "${COMMAND}" | tr -s " ")
141+
COMMAND=$(echo ${COMMAND} | sed 's/ *$//g') # Trimming whitespaces
142142

143143
echo -e "**Executing:**\n\n${COMMAND}\n"
144144
sleep 5

0 commit comments

Comments
 (0)