Skip to content

Commit e719bc7

Browse files
committed
[runtime]: fixed test_model bugs
1 parent 5d58254 commit e719bc7

File tree

4 files changed

+82
-77
lines changed

4 files changed

+82
-77
lines changed

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ all: lib python tests html
1111

1212
# Mac OS should install libomp with brew
1313
dep:
14-
python3 install/deps.py
14+
python3 conf/deps.py
1515

1616
lib: dep
1717
@cd ${BUILD} && cmake ../ && $(MAKE)
@@ -39,6 +39,9 @@ test_gpu: ${TEST_GPUS}
3939
test_formal: ${TEST_FORMALS}
4040
test_opencl: ${TEST_OPENCL}
4141

42+
%: %_cpu %_gpu %_formal
43+
@echo "compile $@ succeed"
44+
4245
%_cpu: ${TESTS}/%.cc lib
4346
g++ -o ${BUILD}/${TESTS}/$@ $< -DDEVICE=0 -std=c++11 -I${INCLUDE} -L${BUILD} -lcvm -fopenmp -fsigned-char -pthread -Wl,-rpath=${BUILD}
4447

conf/env.sh

+18-25
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,36 @@
1-
CURR_DIR=$(dirname $(realpath $0))
1+
CURR_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
22
ROOT_DIR=$(dirname ${CURR_DIR})
33
PROJECT_NAME=$(basename ${ROOT_DIR})
44

55
COM=""
6-
LN=$'\n '
76

87
if [[ "${PYTHONPATH}" != *"${PROJECT_NAME}/python"* ]]; then
9-
read -d '' COM <<EOF
10-
${COM}
11-
12-
PYTHONPATH=${ROOT_DIR}/python:\${PYTHONPATH}
13-
echo "PYTHONPATH=\${PYTHONPATH}"
14-
EOF
8+
TPATH=${ROOT_DIR}/python
9+
[[ -z ${PYTHONPATH} ]] || TPATH=${TPATH}:${PYTHONPATH}
10+
export PYTHONPATH=${TPATH}
1511
fi
1612

1713
if [[ "${LD_LIBRARY_PATH}" != *"${PROJECT_NAME}/build"* ]]; then
18-
read -d '' COM <<EOF
19-
${COM}
20-
21-
export LD_LIBRARY_PATH=${ROOT_DIR}/build:\${LD_LIBRARY_PATH}
22-
echo "LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}"
23-
EOF
14+
TPATH=${ROOT_DIR}/build
15+
[[ -z ${LD_LIBRARY_PATH} ]] || TPATH=${TPATH}:${LD_LIBRARY_PATH}
16+
export LD_LIBRARY_PATH=${TPATH}
2417
fi
2518

26-
if [[ ${COM} != "" ]]; then
27-
cat <<EOF
19+
# if [[ ${COM} != "" ]]; then
20+
# cat <<EOF
2821

29-
Due to bash limitation, we cannot add python & link library
30-
environment via scripts, and then we supply the below commands to
31-
help to setup the project, copy and execute it in terminal please:
22+
# Due to bash limitation, we cannot add python & link library
23+
# environment via scripts, and then we supply the below commands to
24+
# help to setup the project, copy and execute it in terminal please:
3225

33-
\`
34-
${COM}
35-
\`
26+
# \`
27+
# ${COM}
28+
# \`
3629

37-
EOF
38-
fi
30+
# EOF
31+
# fi
3932

40-
echo "Done."
33+
# echo "Done."
4134

4235
# compile the cython module
4336
# echo "Compile the cython setup"

tests/python/model-infer.py

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
# model_root = "/data/ryt/tf_mobilenet_v1_0.50_192_lite_tfm"
3434
model_root = "/data/ryt/tf_mobilenet_tfm"
3535

36+
if len(os.sys.argv) > 1:
37+
model_root = os.sys.argv[1]
38+
39+
print("Modal Load: ", model_root)
40+
3641
json, params = utils.load_model(
3742
os.path.join(model_root, "symbol"),
3843
os.path.join(model_root, "params"))

tests/test_model.cc

+55-51
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
#include <cvm/c_api.h>
2-
#include <cvm/model.h>
31
#include <iostream>
42
#include <thread>
53
#include <omp.h>
4+
#include <vector>
5+
#include <fstream>
6+
7+
#include <cvm/c_api.h>
8+
#include <cvm/model.h>
69
#include <cvm/runtime/registry.h>
710
#include <cvm/op.h>
811
#include "npy.hpp"
@@ -129,7 +132,7 @@ int run_LIF(string model_root, int device_type = 0) {
129132
{
130133
vector<int32_t> input_int32_t;
131134
std::vector<unsigned long> tshape;
132-
npy::LoadArrayFromNumpy("/data/std_out/trec/data.npy", tshape, input_int32_t);
135+
npy::LoadArrayFromNumpy(model_root + "/data.npy", tshape, input_int32_t);
133136
std::cout << "Loading a int32 data and cast to byte array: "
134137
<< input.size() << " " << input_int32_t.size() << "\n";
135138
memcpy(input.data(), input_int32_t.data(), input.size());
@@ -251,57 +254,58 @@ void test_thread() {
251254

252255
int test_models(int device_type = 0) {
253256
std::cout << device_type << " DDDDDD" << std::endl;
254-
auto model_roots = {
255-
"/data/std_out/yolo_tfm",
256-
"/data/std_out/null",
257-
"/data/std_out/resnet50_mxg",
258-
"/data/std_out/ssd_512_mobilenet1.0_voc_tfm",
259-
"/data/std_out/resnet18_v1_tfm",
260-
"/data/std_out/resnet50_v2",
261-
"/data/std_out/qd10_resnet20_v2",
262-
"/data/std_out/trec",
263-
// "/data/new_cvm/yolo3_darknet53_voc/data",
264-
"/data/lz_model_storage/dcnet_mnist_v1/data",
265-
"/data/lz_model_storage/mobilenetv1.0_imagenet/data",
266-
"/data/lz_model_storage/resnet50_v1_imagenet/data",
267-
"/data/lz_model_storage/animal10/data",
268-
"/data/lz_model_storage/resnet50_v2/data",
269-
"/data/lz_model_storage/vgg16_gcv/data",
270-
"/data/lz_model_storage/sentiment_trec/data",
271-
"/data/lz_model_storage/vgg19_gcv/data",
272-
"/data/lz_model_storage/squeezenet_gcv1.1/data",
273-
"/data/lz_model_storage/squeezenet_gcv1.0/data",
257+
std::string model_root = "/data1/";
258+
auto model_dirs = {
259+
"std_out/yolo_tfm",
260+
"std_out/null",
261+
"std_out/resnet50_mxg",
262+
"std_out/ssd_512_mobilenet1.0_voc_tfm",
263+
"std_out/resnet18_v1_tfm",
264+
"std_out/resnet50_v2",
265+
"std_out/qd10_resnet20_v2",
266+
"std_out/trec",
267+
// "new_cvm/yolo3_darknet53_voc/data",
268+
"lz_model_storage/dcnet_mnist_v1/data",
269+
"lz_model_storage/mobilenetv1.0_imagenet/data",
270+
"lz_model_storage/resnet50_v1_imagenet/data",
271+
"lz_model_storage/animal10/data",
272+
"lz_model_storage/resnet50_v2/data",
273+
"lz_model_storage/vgg16_gcv/data",
274+
"lz_model_storage/sentiment_trec/data",
275+
"lz_model_storage/vgg19_gcv/data",
276+
"lz_model_storage/squeezenet_gcv1.1/data",
277+
"lz_model_storage/squeezenet_gcv1.0/data",
274278
// invalid has strange attribute in operator elemwise_add.
275-
// "/data/lz_model_storage/octconv_resnet26_0.250/data",
276-
"/data/std_out/resnet50_mxg/",
277-
"/data/std_out/resnet50_v2",
278-
"/data/std_out/qd10_resnet20_v2",
279-
"/data/std_out/random_3_0/",
280-
"/data/std_out/random_3_1/",
281-
"/data/std_out/random_3_2/",
282-
"/data/std_out/random_3_3/",
283-
"/data/std_out/random_3_4/",
284-
"/data/std_out/random_3_5/",
285-
"/data/std_out/random_4_0/",
286-
"/data/std_out/random_4_1/",
287-
// "/data/std_out/random_4_2/",
288-
// "/data/std_out/random_4_3/",
289-
// "/data/std_out/random_4_4/",
290-
"/data/std_out/random_4_5/",
291-
"/data/std_out/random_4_6/",
292-
"/data/std_out/random_4_7/",
293-
"/data/std_out/random_4_8/",
294-
"/data/std_out/random_4_9/",
295-
"/data/std_out/log2",
279+
// "lz_model_storage/octconv_resnet26_0.250/data",
280+
"std_out/resnet50_mxg/",
281+
"std_out/resnet50_v2",
282+
"std_out/qd10_resnet20_v2",
283+
"std_out/random_3_0/",
284+
"std_out/random_3_1/",
285+
"std_out/random_3_2/",
286+
"std_out/random_3_3/",
287+
"std_out/random_3_4/",
288+
"std_out/random_3_5/",
289+
"std_out/random_4_0/",
290+
"std_out/random_4_1/",
291+
// "std_out/random_4_2/",
292+
// "std_out/random_4_3/",
293+
// "std_out/random_4_4/",
294+
"std_out/random_4_5/",
295+
"std_out/random_4_6/",
296+
"std_out/random_4_7/",
297+
"std_out/random_4_8/",
298+
"std_out/random_4_9/",
299+
"std_out/log2",
296300
//"./tests/3145ad19228c1cd2d051314e72f26c1ce77b7f02/",
297-
"/data/std_out/lr_attr",
298-
// "/data/std_out/non_in",
299-
"/data/std_out/shufflenet",
300-
"/data/std_out/ssd",
301-
"/data/std_out/ssd_512_mobilenet1.0_coco_tfm/",
301+
"std_out/lr_attr",
302+
// "std_out/non_in",
303+
"std_out/shufflenet",
304+
"std_out/ssd",
305+
"std_out/ssd_512_mobilenet1.0_coco_tfm/",
302306
};
303-
for (auto model_root : model_roots) {
304-
auto ret = run_LIF(model_root, device_type);
307+
for (auto dir : model_dirs) {
308+
auto ret = run_LIF(model_root + dir, device_type);
305309
if (ret == -1) return -1;
306310
}
307311
return 0;

0 commit comments

Comments
 (0)