Skip to content

Commit 3c360dc

Browse files
author
Jian Weng
committed
clean up
1 parent f413e53 commit 3c360dc

File tree

4 files changed

+27
-60
lines changed

4 files changed

+27
-60
lines changed

models/arm/compile.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def tracer(module, info, is_before):
9696
print('Model Load!')
9797
import tensorizer
9898
from tensorizer import tune
99-
tune.enable = True
99+
tune.enable = False
100+
tune.cpu_idx = None
100101
with tvm.transform.PassContext(config={'tir.add_lower_pass': [(1, tensorizer.rewrite)]},
101102
trace=tracer, opt_level=3):
102103
graph, lib, params = relay.build_module.build(
@@ -140,9 +141,15 @@ def tracer(module, info, is_before):
140141
parser.add_argument('--data-layer-type', type=str, default="float32",
141142
choices=['float32', 'int8', 'uint8'],
142143
help='data type for data layer')
144+
parser.add_argument('--target', type=str, default="tensorize")
143145

144146
args = parser.parse_args()
145147

148+
if args.target == 'tensorize':
149+
target = 'llvm -device=arm_cpu -mtriple=aarch64-none-linux-gnu -mattr=+v8.2a,+dotprod,+neon'
150+
else:
151+
target = 'llvm -device=arm_cpu -mtriple=aarch64-none-linux-gnu -mattr=+v8.2a,+neon'
152+
146153
if args.ctx == 'gpu':
147154
ctx = mx.gpu(0)
148155
elif args.ctx == 'cpu':

models/arm/compile_all.sh

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
rm -rf compiled
22
mkdir compiled
33

4-
python3 compile.py --symbol-file=${MODELS}/resnet18_v1-quantized.json --param-file=${MODELS}/resnet18_v1-quantized.params --image-shape=3,224,224 --ctx=cpu
5-
python3 compile.py --symbol-file=${MODELS}/resnet50_v1-quantized.json --param-file=${MODELS}/resnet50_v1-quantized.params --image-shape=3,224,224 --ctx=cpu
6-
python3 compile.py --symbol-file=${MODELS}/resnet50_v1b-quantized.json --param-file=${MODELS}/resnet50_v1b-quantized.params --image-shape=3,224,224 --ctx=cpu
7-
python3 compile.py --symbol-file=${MODELS}/imagenet1k-inception-bn-quantized.json --param-file=${MODELS}/imagenet1k-inception-bn-quantized.params --image-shape=3,224,224 --ctx=cpu
8-
python3 compile.py --symbol-file=${MODELS}/inceptionv3-quantized.json --param-file=${MODELS}/inceptionv3-quantized.params --image-shape=3,299,299 --ctx=cpu
9-
python3 compile.py --symbol-file=${MODELS}/resnet101_v1-quantized.json --param-file=${MODELS}/resnet101_v1-quantized.params --image-shape=3,224,224 --ctx=cpu
10-
python3 compile.py --symbol-file=${MODELS}/imagenet1k-resnet-152-quantized.json --param-file=${MODELS}/imagenet1k-resnet-152-quantized.params --image-shape=3,224,224 --ctx=cpu
11-
python3 compile.py --symbol-file=${MODELS}/mobilenet1.0-quantized.json --param-file=${MODELS}/mobilenet1.0-quantized.params --image-shape=3,224,224 --ctx=cpu
12-
python3 compile.py --symbol-file=${MODELS}/mobilenetv2_1.0-quantized.json --param-file=${MODELS}/mobilenetv2_1.0-quantized.params --image-shape=3,224,224 --ctx=cpu
4+
python3 compile.py --symbol-file=${MODELS}/resnet18_v1-quantized.json --param-file=${MODELS}/resnet18_v1-quantized.params --image-shape=3,224,224 --ctx=cpu --target=$1
5+
python3 compile.py --symbol-file=${MODELS}/resnet50_v1-quantized.json --param-file=${MODELS}/resnet50_v1-quantized.params --image-shape=3,224,224 --ctx=cpu --target=$1
6+
python3 compile.py --symbol-file=${MODELS}/resnet50_v1b-quantized.json --param-file=${MODELS}/resnet50_v1b-quantized.params --image-shape=3,224,224 --ctx=cpu --target=$1
7+
python3 compile.py --symbol-file=${MODELS}/imagenet1k-inception-bn-quantized.json --param-file=${MODELS}/imagenet1k-inception-bn-quantized.params --image-shape=3,224,224 --ctx=cpu --target=$1
8+
python3 compile.py --symbol-file=${MODELS}/inceptionv3-quantized.json --param-file=${MODELS}/inceptionv3-quantized.params --image-shape=3,299,299 --ctx=cpu --target=$1
9+
python3 compile.py --symbol-file=${MODELS}/resnet101_v1-quantized.json --param-file=${MODELS}/resnet101_v1-quantized.params --image-shape=3,224,224 --ctx=cpu --target=$1
10+
python3 compile.py --symbol-file=${MODELS}/imagenet1k-resnet-152-quantized.json --param-file=${MODELS}/imagenet1k-resnet-152-quantized.params --image-shape=3,224,224 --ctx=cpu --target=$1
11+
python3 compile.py --symbol-file=${MODELS}/mobilenet1.0-quantized.json --param-file=${MODELS}/mobilenet1.0-quantized.params --image-shape=3,224,224 --ctx=cpu --target=$1
12+
python3 compile.py --symbol-file=${MODELS}/mobilenetv2_1.0-quantized.json --param-file=${MODELS}/mobilenetv2_1.0-quantized.params --image-shape=3,224,224 --ctx=cpu --target=$1

models/mxnet/profile.sh

+9-49
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,13 @@ export MODEL_PATH=$MODELS
1616

1717
export PYTHONPATH=/root/tvms/tensorize/python/:/root/tvms/tensorize/topi/python/:$COMMON_PYPATH
1818

19-
python3 profile_mxnet.py --symbol-file=${MODELS}/resnet18_v1-quantized.json --param-file=${MODELS}/resnet18_v1-quantized.params --image-shape=3,224,224 --ctx=cpu --num-inference-batches=10
19+
python3 profile_mxnet.py --symbol-file=${MODELS}/resnet18_v1-quantized.json --param-file=${MODELS}/resnet18_v1-quantized.params --image-shape=3,224,224 --ctx=cpu --num-inference-batches=5
20+
python3 profile_mxnet.py --symbol-file=${MODELS}/resnet50_v1-quantized.json --param-file=${MODELS}/resnet50_v1-quantized.params --image-shape=3,224,224 --ctx=cpu --num-inference-batches=5
21+
python3 profile_mxnet.py --symbol-file=${MODELS}/resnet50_v1b-quantized.json --param-file=${MODELS}/resnet50_v1b-quantized.params --image-shape=3,224,224 --ctx=cpu --num-inference-batches=5
22+
python3 profile_mxnet.py --symbol-file=${MODELS}/imagenet1k-inception-bn-quantized.json --param-file=${MODELS}/imagenet1k-inception-bn-quantized.params --image-shape=3,224,224 --ctx=cpu --num-inference-batches=5
23+
python3 profile_mxnet.py --symbol-file=${MODELS}/inceptionv3-quantized.json --param-file=${MODELS}/inceptionv3-quantized.params --image-shape=3,299,299 --ctx=cpu --num-inference-batches=5
24+
python3 profile_mxnet.py --symbol-file=${MODELS}/resnet101_v1-quantized.json --param-file=${MODELS}/resnet101_v1-quantized.params --image-shape=3,224,224 --ctx=cpu --num-inference-batches=5
25+
python3 profile_mxnet.py --symbol-file=${MODELS}/imagenet1k-resnet-152-quantized.json --param-file=${MODELS}/imagenet1k-resnet-152-quantized.params --image-shape=3,224,224 --ctx=cpu --num-inference-batches=5
26+
python3 profile_mxnet.py --symbol-file=${MODELS}/mobilenet1.0-quantized.json --param-file=${MODELS}/mobilenet1.0-quantized.params --image-shape=3,224,224 --ctx=cpu --num-inference-batches=5
27+
python3 profile_mxnet.py --symbol-file=${MODELS}/mobilenetv2_1.0-quantized.json --param-file=${MODELS}/mobilenetv2_1.0-quantized.params --image-shape=3,224,224 --ctx=cpu --num-inference-batches=5
2028

21-
#python3 profile_mxnet.py --symbol-file=$MODEL_PATH/resnet18_v1-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/resnet18_v1-quantized-0000.params --num-inference-batches=2000 |& tee -a perf.txt
22-
#
23-
#python3 profile_mxnet.py --symbol-file=$MODEL_PATH/resnet50_v1-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/resnet50_v1-quantized-0000.params --num-inference-batches=2000 |& tee -a perf.txt
24-
#
25-
#for i in $(seq 1 $NUM_ITERS)
26-
#do
27-
# python3 profile_mxnet.py --symbol-file=$MODEL_PATH/resnet50_v1b-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/resnet50_v1b-quantized-0000.params --num-inference-batches=2000 |& tee -a perf.txt
28-
# python3 profile_tvm.py --symbol-file=$MODEL_PATH/resnet50_v1b-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/resnet50_v1b-quantized-0000.params --num-inference-batches=2000 |& tee -a perf.txt
29-
#done
30-
#
31-
#for i in $(seq 1 $NUM_ITERS)
32-
#do
33-
# python3 profile_mxnet.py --symbol-file=$MODEL_PATH/resnet101_v1-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/resnet101_v1-quantized-0000.params --image-shape=3,224,224 --num-inference-batches=2000 |& tee -a perf.txt
34-
# python3 profile_tvm.py --symbol-file=$MODEL_PATH/resnet101_v1-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/resnet101_v1-quantized-0000.params --image-shape=3,224,224 --num-inference-batches=2000 |& tee -a perf.txt
35-
#done
36-
#
37-
#
38-
#for i in $(seq 1 $NUM_ITERS)
39-
#do
40-
# python3 profile_mxnet.py --symbol-file=$MODEL_PATH/imagenet1k-resnet-152-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/imagenet1k-resnet-152-quantized-0000.params --image-shape=3,224,224 --num-inference-batches=2000 |& tee -a perf.txt
41-
# python3 profile_tvm.py --symbol-file=$MODEL_PATH/imagenet1k-resnet-152-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/imagenet1k-resnet-152-quantized-0000.params --image-shape=3,224,224 --num-inference-batches=2000 |& tee -a perf.txt
42-
#done
43-
#
44-
#for i in $(seq 1 $NUM_ITERS)
45-
#do
46-
# python3 profile_mxnet.py --symbol-file=$MODEL_PATH/inceptionv3-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/inceptionv3-quantized-0000.params --image-shape=3,299,299 --num-inference-batches=2000 |& tee -a perf.txt
47-
# python3 profile_tvm.py --symbol-file=$MODEL_PATH/inceptionv3-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/inceptionv3-quantized-0000.params --image-shape=3,299,299 --num-inference-batches=2000 |& tee -a perf.txt
48-
#done
49-
#
50-
#for i in $(seq 1 $NUM_ITERS)
51-
#do
52-
# python3 profile_mxnet.py --symbol-file=$MODEL_PATH/imagenet1k-inception-bn-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/imagenet1k-inception-bn-quantized-0000.params --image-shape=3,224,224 --num-inference-batches=2000 |& tee -a perf.txt
53-
# python3 profile_tvm.py --symbol-file=$MODEL_PATH/imagenet1k-inception-bn-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/imagenet1k-inception-bn-quantized-0000.params --image-shape=3,224,224 --num-inference-batches=2000 |& tee -a perf.txt
54-
#done
55-
#
56-
#for i in $(seq 1 $NUM_ITERS)
57-
#do
58-
# python3 profile_mxnet.py --symbol-file=$MODEL_PATH/mobilenet1.0-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/mobilenet1.0-quantized-0000.params --num-inference-batches=2000 --image-shape=3,224,224 |& tee -a perf.txt
59-
# python3 profile_tvm.py --symbol-file=$MODEL_PATH/mobilenet1.0-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/mobilenet1.0-quantized-0000.params --num-inference-batches=2000 --image-shape=3,224,224 |& tee -a perf.txt
60-
#done
61-
#
62-
#for i in $(seq 1 $NUM_ITERS)
63-
#do
64-
# python3 profile_mxnet.py --symbol-file=$MODEL_PATH/mobilenetv2_1.0-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/mobilenetv2_1.0-quantized-0000.params --image-shape=3,224,224 --num-inference-batches=2000 |& tee -a perf.txt
65-
# python3 profile_tvm.py --symbol-file=$MODEL_PATH/mobilenetv2_1.0-quantized-5batches-naive-symbol.json --param-file=$MODEL_PATH/mobilenetv2_1.0-quantized-0000.params --image-shape=3,224,224 --num-inference-batches=2000 |& tee -a perf.txt
66-
#done
67-
#
68-
#

models/mxnet/profile_mxnet.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def profile(data, symbol_file, num_inference_images, sym, devs, label_name):
130130
parser.add_argument('--score_tvm', type=bool, default=False, help='score tvm')
131131
parser.add_argument('--symbol-file', type=str, required=True, help='symbol file path')
132132
parser.add_argument('--param-file', type=str, required=False, help='param file path')
133-
parser.add_argument('--batch-size', type=int, default=32)
133+
parser.add_argument('--batch-size', type=int, default=1)
134134
parser.add_argument('--label-name', type=str, default='softmax_label')
135135
parser.add_argument('--dataset', type=str, required=False, help='dataset path')
136136
parser.add_argument('--rgb-mean', type=str, default='0,0,0')

0 commit comments

Comments
 (0)