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

Commit 521deb9

Browse files
--use_xla_auto_jit added to the benchmark
1 parent 60194ec commit 521deb9

File tree

5 files changed

+15
-21
lines changed

5 files changed

+15
-21
lines changed

tftrt/examples/benchmark_args.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ def __init__(self):
140140
help="If set to True, the benchmark will use XLA JIT Compilation."
141141
)
142142

143+
self._add_bool_argument(
144+
name="use_xla_auto_jit",
145+
default=False,
146+
required=False,
147+
help="If set to True, the benchmark will use XLA JIT Auto "
148+
"Clustering Compilation."
149+
)
150+
143151
self._add_bool_argument(
144152
name="use_synthetic_data",
145153
default=False,

tftrt/examples/benchmark_runner.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ def evaluate_model(self, predictions, expected, bypass_data_to_eval):
5757
def __init__(self, args):
5858
self._args = args
5959

60+
if args.use_xla_auto_jit:
61+
print("[Benchmark] - Activating XLA JIT Auto Clustering")
62+
os.environ["TF_XLA_FLAGS"] = "--tf_xla_auto_jit=2 --tf_xla_cpu_global_jit"
63+
6064
logging.getLogger("tensorflow").setLevel(logging.INFO)
6165
logging.disable(logging.WARNING)
6266

tftrt/examples/image_classification/base_run_inference.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ MODEL_DIR=""
1111
NVIDIA_TF32_OVERRIDE=""
1212

1313
BYPASS_ARGUMENTS=""
14-
TF_AUTO_JIT_XLA_FLAG=""
1514

1615
# Loop through arguments and process them
1716
for arg in "$@"
@@ -39,10 +38,6 @@ do
3938
--output_tensors_name=*)
4039
shift # Remove --output_tensors_name= from processing
4140
;;
42-
--use_xla_auto_jit)
43-
TF_AUTO_JIT_XLA_FLAG="TF_XLA_FLAGS=\"--tf_xla_auto_jit=2 --tf_xla_cpu_global_jit\""
44-
shift # Remove --use_xla_auto_jit from processing
45-
;;
4641
*)
4742
BYPASS_ARGUMENTS=" ${BYPASS_ARGUMENTS} ${arg}"
4843
;;
@@ -114,7 +109,6 @@ echo "[*] NUM_CLASSES: ${NUM_CLASSES}"
114109
echo "[*] MAX_SAMPLES: ${MAX_SAMPLES}"
115110
echo "[*] OUTPUT_TENSORS_NAME: ${OUTPUT_TENSORS_NAME}"
116111
echo ""
117-
echo "[*] TF_AUTO_JIT_XLA_FLAG: ${TF_AUTO_JIT_XLA_FLAG}"
118112
echo "[*] BYPASS_ARGUMENTS: $(echo \"${BYPASS_ARGUMENTS}\" | tr -s ' ')"
119113
echo -e "********************************************************************\n"
120114

@@ -158,7 +152,7 @@ cd ${BENCH_DIR}
158152

159153
# Execute the example
160154

161-
PREPEND_COMMAND="${TF_AUTO_JIT_XLA_FLAG} ${NVIDIA_TF32_OVERRIDE}"
155+
PREPEND_COMMAND="${NVIDIA_TF32_OVERRIDE}"
162156

163157
COMMAND="${PREPEND_COMMAND} python image_classification.py \
164158
--data_dir ${DATA_DIR} \

tftrt/examples/object_detection/base_run_inference.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ MODEL_DIR=""
1111
NVIDIA_TF32_OVERRIDE=""
1212

1313
BYPASS_ARGUMENTS=""
14-
TF_AUTO_JIT_XLA_FLAG=""
1514
BATCH_SIZE=8
1615

1716
# Loop through arguments and process them
@@ -44,10 +43,6 @@ do
4443
MODEL_DIR="${arg#*=}"
4544
shift # Remove --input_saved_model_dir= from processing
4645
;;
47-
--use_xla_auto_jit)
48-
TF_AUTO_JIT_XLA_FLAG="TF_XLA_FLAGS=\"--tf_xla_auto_jit=2 --tf_xla_cpu_global_jit\""
49-
shift # Remove --use_xla_auto_jit from processing
50-
;;
5146
*)
5247
BYPASS_ARGUMENTS=" ${BYPASS_ARGUMENTS} ${arg}"
5348
;;
@@ -84,7 +79,6 @@ echo "[*] MAX_WORKSPACE_SIZE: ${MAX_WORKSPACE_SIZE}"
8479
echo "[*] MAX_SAMPLES: ${MAX_SAMPLES}"
8580
echo "[*] OUTPUT_TENSORS_NAME: ${OUTPUT_TENSORS_NAME}"
8681
echo ""
87-
echo "[*] TF_AUTO_JIT_XLA_FLAG: ${TF_AUTO_JIT_XLA_FLAG}"
8882
echo "[*] BYPASS_ARGUMENTS: $(echo \"${BYPASS_ARGUMENTS}\" | tr -s ' ')"
8983
echo -e "********************************************************************\n"
9084

@@ -149,7 +143,7 @@ fi
149143

150144
# Step 2: Execute the example
151145

152-
PREPEND_COMMAND="${TF_AUTO_JIT_XLA_FLAG} ${NVIDIA_TF32_OVERRIDE}"
146+
PREPEND_COMMAND="${NVIDIA_TF32_OVERRIDE}"
153147

154148
COMMAND="${PREPEND_COMMAND} python object_detection.py \
155149
--data_dir ${VAL_DATA_DIR} \

tftrt/examples/transformers/base_run_inference.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ NVIDIA_TF32_OVERRIDE=""
1313
DATA_DIR="/tmp"
1414

1515
BYPASS_ARGUMENTS=""
16-
TF_AUTO_JIT_XLA_FLAG=""
1716
BATCH_SIZE=32
1817
SEQ_LEN=128
1918

@@ -46,10 +45,6 @@ do
4645
MODEL_DIR="${arg#*=}"
4746
shift # Remove --input_saved_model_dir= from processing
4847
;;
49-
--use_xla_auto_jit)
50-
TF_AUTO_JIT_XLA_FLAG="TF_XLA_FLAGS=\"--tf_xla_auto_jit=2 --tf_xla_cpu_global_jit\""
51-
shift # Remove --use_xla_auto_jit from processing
52-
;;
5348
--vocab_size=*)
5449
shift # Remove --vocab_size= from processing
5550
;;
@@ -104,7 +99,6 @@ echo "[*] MAX_WORKSPACE_SIZE: ${MAX_WORKSPACE_SIZE}"
10499
echo "[*] MAX_SAMPLES: ${MAX_SAMPLES}"
105100
echo "[*] OUTPUT_TENSORS_NAME: ${OUTPUT_TENSORS_NAME}"
106101
echo ""
107-
echo "[*] TF_AUTO_JIT_XLA_FLAG: ${TF_AUTO_JIT_XLA_FLAG}"
108102
echo "[*] BYPASS_ARGUMENTS: $(echo \"${BYPASS_ARGUMENTS}\" | tr -s ' ')"
109103

110104
echo -e "********************************************************************\n"
@@ -149,7 +143,7 @@ cd ${BENCH_DIR}
149143

150144
# Execute the example
151145

152-
PREPEND_COMMAND="${TF_AUTO_JIT_XLA_FLAG} ${NVIDIA_TF32_OVERRIDE}"
146+
PREPEND_COMMAND="${NVIDIA_TF32_OVERRIDE}"
153147

154148
COMMAND="${PREPEND_COMMAND} python transformers.py \
155149
--data_dir ${DATA_DIR} \

0 commit comments

Comments
 (0)