wuxun-zhang commented on a change in pull request #15164: [C++] Improve inference script to support benchmark on Imagenet URL: https://github.com/apache/incubator-mxnet/pull/15164#discussion_r296142129
########## File path: cpp-package/example/inference/unit_test_imagenet_inference.sh ########## @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -ex +# create ./model directory if not existed +if [ ! -d model ]; then + mkdir -p model +fi +# create ./data directory if not existed +if [ ! -d data ]; then + mkdir -p data +fi +# Downloading the data and model if not existed +model_file=./model/Inception-BN-symbol.json +params_file=./model/Inception-BN-0126.params +if [ ! -f ${model_file} ] || [ ! -f ${params_file} ]; then + wget -nc http://data.mxnet.io/models/imagenet/inception-bn.tar.gz + tar -xvzf inception-bn.tar.gz -C model +fi +cd model +wget -nc https://raw.githubusercontent.com/dmlc/gluon-cv/master/gluoncv/model_zoo/quantized/resnet50_v1_int8-symbol.json +cd ../data +wget -nc http://data.mxnet.io/data/val_256_q90.rec +cd .. + +# Running inference on imagenet. +if [ "$(uname)" == "Darwin" ]; then + echo ">>> INFO: FP32 real data" + DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:../../../lib ./imagenet_inference --symbol_file "./model/Inception-BN-symbol.json" --params_file "./model/Inception-BN-0126.params" --dataset "./data/val_256_q90.rec" --rgb_mean "123.68 116.779 103.939" --batch_size 1 --num_skipped_batches 50 --num_inference_batches 500 + + echo ">>> INFO: FP32 dummy data" + DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:../../../lib ./imagenet_inference --symbol_file "./model/Inception-BN-symbol.json" --batch_size 1 --num_inference_batches 500 --benchmark +else + echo ">>> INFO: FP32 real data" + LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../../lib ./imagenet_inference --symbol_file "./model/Inception-BN-symbol.json" --params_file "./model/Inception-BN-0126.params" --dataset "./data/val_256_q90.rec" --rgb_mean "123.68 116.779 103.939" --batch_size 1 --num_skipped_batches 50 --num_inference_batches 500 + + echo ">>> INFO: FP32 dummy data" + LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../../lib ./imagenet_inference --symbol_file "./model/Inception-BN-symbol.json" --batch_size 1 --num_inference_batches 500 --benchmark + + lib_name=$(ls -a ../../../lib | grep -oE 'mkldnn' | tail -1) + if [[ -n ${lib_name} ]] && [[ 'mkldnn' =~ ${lib_name} ]]; then + echo ">>> INFO: INT8 dummy data" + LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../../lib ./imagenet_inference --symbol_file "./model/resnet50_v1_int8-symbol.json" --batch_size 1 --num_inference_batches 500 --benchmark Review comment: Now I cannot find someplace to download INT8 params file which is required for real data inference. So, I just added a dummy data inference here for INT8 resnet50 model. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
