chore: import upstream snapshot with attribution
Docker Image CI / build-ubuntu2004 (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:36:55 +08:00
commit c8a779b1bb
1887 changed files with 3245738 additions and 0 deletions
@@ -0,0 +1,22 @@
## Scripts for TRT Deployment
For both baseline and QAT, change:
- `RESNET_DEPTH` for 50 or 101,
- `RESNET_VERSION` for v1 or v2,
- `BS` for which batch sizes you wish to evaluate the engine on.
#### Baseline
```
./scripts/deploy_engine_baseline.sh
```
> Change `ROOT_DIR` to where your ONNX file is.
#### QAT
```
./scripts/deploy_engine_qat.sh
```
> Change `QAT_SUBDIR` and `ROOT_DIR` to where your ONNX file is.
### Only accuracy
```
./scripts/infer_engine.sh
```
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# Single run:
# ../../engine_builder/build_engine_single.py --root_dir=/home/nvidia/PycharmProjects/tensorflow-quantization/examples/resnet/weights/resnet50v1 --onnx=model_baseline_dynamic.onnx --engine=model_baseline_dynamic.engine --input=224,224,3 --min_bs=1 --max_bs=1 --opt_bs=1 --precision=fp32
#
RESNET_DEPTH=50
RESNET_VERSION=v1
ROOT_DIR=../weights/resnet${RESNET_DEPTH}${RESNET_VERSION}
LOGS_SUBDIR=baseline_engines_trtSource
LOGS_DIR=${ROOT_DIR}/${LOGS_SUBDIR}
mkdir $LOGS_DIR
echo "1/3. Building engine"
# bs=32 OOM in workstation
ONNX=model_baseline_dynamic.onnx
ENGINE=${LOGS_SUBDIR}/model_baseline_dynamic_bs{min1,opt8,max16}.engine
python ../../../engine_builder/build_engine_single.py --root_dir=$ROOT_DIR \
--onnx=$ONNX \
--engine=$ENGINE \
--input=224,224,3 \
--min_bs=1 --opt_bs=8 --max_bs=16 \
--precision=fp32
wait
for BS in 8 16; do # 8 32 128; do
echo "Model evaluation..."
echo "############### bs=${BS} ###############"
# Latency calculation from built engine
echo "2/3. Latency evaluation"
trtexec --device=0 \
--loadEngine=${ROOT_DIR}/${ENGINE} \
--shapes=input_1:0:${BS}x224x224x3 \
--workspace=2048 \
--separateProfileRun \
--dumpProfile \
--explicitBatch &> ${LOGS_DIR}/trtexec_latency_bs${BS}.log
wait
echo "3/3. Accuracy evaluation"
python ../infer_engine.py --engine=${ROOT_DIR}/${ENGINE} \
--log_file=engine_accuracy_bs${BS}.log \
--model_name=resnet_$RESNET_VERSION \
-b=$BS
wait
done
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# Single run:
# ../../engine_builder/build_engine_single.py --root_dir=/home/nvidia/PycharmProjects/tensorflow-quantization/examples/resnet/weights/resnet50v1 --onnx=model_baseline_dynamic.onnx --engine=model_baseline_dynamic.engine --input=224,224,3 --min_bs=1 --max_bs=1 --opt_bs=1 --precision=fp32
#
RESNET_DEPTH=50
RESNET_VERSION=v1
QAT_SUBDIR=qat_tfrecord_ep10_steps500_l2False_baselr0.0001_piecewise_sgd_bs128
ROOT_DIR=../weights/resnet${RESNET_DEPTH}${RESNET_VERSION}/${QAT_SUBDIR}
LOGS_SUBDIR=engines_trtSource
LOGS_DIR=${ROOT_DIR}/${LOGS_SUBDIR}
mkdir $LOGS_DIR
echo "1/3. Building engine"
# bs=32 OOM in workstation
ONNX=model_dynamic.onnx
ENGINE=${LOGS_SUBDIR}/model_baseline_bs{min1,opt8,max128}.engine
python ../../../engine_builder/build_engine_single.py --root_dir=$ROOT_DIR \
--onnx=$ONNX \
--engine=$ENGINE \
--input=224,224,3 \
--min_bs=1 --opt_bs=8 --max_bs=128 \
--precision=int8
wait
for BS in 1 8 128; do # 8 32 128; do
echo "Model evaluation..."
echo "############### bs=${BS} ###############"
# Latency calculation from built engine
echo "2/3. Latency evaluation"
trtexec --device=0 \
--loadEngine=${ROOT_DIR}/${ENGINE} \
--shapes=input_1:0:${BS}x224x224x3 \
--workspace=1024 \
--separateProfileRun \
--dumpProfile \
--explicitBatch \
--int8 &> ${LOGS_DIR}/trtexec_latency_bs${BS}.log
wait
echo "3/3. Accuracy evaluation"
python ../infer_engine.py --engine=${ROOT_DIR}/${ENGINE} \
--log_file=engine_accuracy_bs${BS}.log \
--model_name=resnet_$RESNET_VERSION \
-b=$BS
wait
done
@@ -0,0 +1,17 @@
ROOT_DIR="/home/nvidia/PycharmProjects/tensorrt_qat/examples/resnet/"
RESNET_DEPTH="50"
RESNET_VERSION="v1"
MODEL_TYPE="baseline" # "qat"
PRECISION="fp32" # "int8"
ENGINES_DIR="engines_gtc_trt8.4_gittrt/${MODEL_TYPE}"
LOGS_DIR="logs_gtc_trt8.4_gittrt/${MODEL_TYPE}"
for BS in 1; do
SUBDIR="resnet${RESNET_DEPTH}${RESNET_VERSION}_${PRECISION}_${BS}_sparsity_disable_DLA_disabled"
python ../infer_engine.py --engine=${ROOT_DIR}/${ENGINES_DIR}/${SUBDIR}.plan \
--log_file=${ROOT_DIR}/${LOGS_DIR}/${SUBDIR}_accuracy.log \
--model_name=resnet_$RESNET_VERSION -b=1
done