Skip to content

Commit ef0bfec

Browse files
Hakim7267JaccovG
authored andcommitted
run cifar per data type
1 parent 7c48e3b commit ef0bfec

File tree

3 files changed

+53
-37
lines changed

3 files changed

+53
-37
lines changed

examples/example_cifar10_caffe/CMakeLists.txt

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@ file(GLOB temp
1212
../auxiliary/*.cc
1313
../auxiliary/*.c
1414
)
15-
add_executable(example_cifar10_caffe
16-
cifar10_coefficients_hwcn_small.c
17-
cifar10_model_hwcn.c
18-
ml_api_cifar10_caffe_main.c
19-
${temp}
20-
)
21-
22-
target_link_libraries(example_cifar10_caffe PUBLIC mli)
23-
24-
target_include_directories(example_cifar10_caffe PRIVATE
25-
../../examples/auxiliary
26-
)
2715

2816
if (ARC)
2917
set(EXAMPLE_FLAGS
@@ -47,24 +35,43 @@ else()
4735
set(EXAMPLE_FLAGS)
4836
endif()
4937

50-
target_compile_options(example_cifar10_caffe PRIVATE
51-
${MLI_PLATFORM_COMPILE_OPTIONS}
52-
${EXAMPLE_FLAGS}
53-
)
38+
function(ADD_DATA_TYPE DATA_TYPE BIT_DEPTH)
39+
set(TARGET example_cifar10_caffe_${DATA_TYPE})
40+
add_executable(${TARGET}
41+
cifar10_coefficients_hwcn_small.c
42+
cifar10_model_hwcn.c
43+
ml_api_cifar10_caffe_main.c
44+
${temp}
45+
)
46+
target_link_libraries(${TARGET} PUBLIC mli)
5447

55-
target_link_options(example_cifar10_caffe PRIVATE
56-
${MLI_PLATFORM_LINK_OPTIONS}
57-
${EXAMPLE_FLAGS}
58-
)
48+
target_include_directories(${TARGET} PRIVATE
49+
../../examples/auxiliary
50+
)
51+
target_compile_options(${TARGET} PRIVATE
52+
${MLI_PLATFORM_COMPILE_OPTIONS}
53+
${EXAMPLE_FLAGS}
54+
)
55+
target_compile_definitions(${TARGET} PRIVATE
56+
MODEL_BIT_DEPTH=${BIT_DEPTH})
57+
target_link_options(${TARGET} PRIVATE
58+
${MLI_PLATFORM_LINK_OPTIONS}
59+
${EXAMPLE_FLAGS}
60+
)
61+
if (ARC)
62+
target_link_options(${TARGET} PRIVATE
63+
-m
64+
-Coutput=./elf_files/${TARGET}.map
65+
)
66+
endif()
5967

60-
if (ARC)
61-
target_link_options(example_cifar10_caffe PRIVATE
62-
-m
63-
-Coutput=./elf_files/example_cifar10_caffe.map
64-
)
65-
endif()
68+
set_target_properties(${TARGET}
69+
PROPERTIES
70+
RUNTIME_OUTPUT_DIRECTORY "./elf_files$<0:>"
71+
)
72+
endfunction()
73+
74+
ADD_DATA_TYPE(FX16 16)
75+
ADD_DATA_TYPE(SA8 8)
76+
ADD_DATA_TYPE(FX16_FX8_FX8 816)
6677

67-
set_target_properties(example_cifar10_caffe
68-
PROPERTIES
69-
RUNTIME_OUTPUT_DIRECTORY "./elf_files$<0:>"
70-
)

examples/example_cifar10_caffe/Makefile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,25 @@ PUBLIC_DIR = ../..
1515
include $(PUBLIC_DIR)/make/rules.mk
1616

1717
BUILD_SUBDIR = examples$(PS)example_cifar10_caffe
18-
BUILD_TARGET = example_cifar10_caffe
18+
19+
20+
TYPES = \
21+
FX16 \
22+
SA8 \
23+
FX16_FX8_FX8
24+
25+
RUN_TARGETS = $(patsubst %,run_%,$(TYPES))
1926

2027
app: build
2128

22-
run: app
29+
run: run_FX16
30+
31+
$(RUN_TARGETS): run_%: app
2332
ifndef TCF_FILE
2433
$(BUILD_DIR)$(PS)$(BUILD_SUBDIR)$(PS)elf_files$(PS)example_cifar10_caffe $(RUN_ARGS)
2534
else
26-
mdb $(BUILD_DIR)$(PS)$(BUILD_SUBDIR)$(PS)elf_files$(PS)example_cifar10_caffe.elf \
35+
mdb $(BUILD_DIR)$(PS)$(BUILD_SUBDIR)$(PS)elf_files$(PS)example_cifar10_caffe_$*.elf \
2736
-cl -nsim -cmd=run -off=cr_for_more -cmd=exit -tcf=$(TCF_FILE) -- $(RUN_ARGS)
2837
endif
2938

30-
.PHONY: app run
39+
.PHONY: app $(RUN_TARGETS)

examples/example_cifar10_caffe/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,15 @@ For this reason you can build and check application with 8 and 16 bit depth of N
144144

145145
* 16 bit depth of coefficients and data (FX16) (default):
146146

147-
gmake TCF_FILE=../../hw/em9d.tcf EXT_CFLAGS="-DMODEL_BIT_DEPTH=16"
147+
gmake run_FX16 TCF_FILE=../../hw/em9d.tcf
148148

149149
* 8 bit depth of coefficients and data (SA8):
150150

151-
gmake TCF_FILE=../../hw/em9d.tcf EXT_CFLAGS="-DMODEL_BIT_DEPTH=8"
151+
gmake run_SA8 TCF_FILE=../../hw/em9d.tcf
152152

153153
* 8x16: 8 bit depth of coefficients and 16 bit depth of data (FX8 weights and FX16 data):
154154

155-
gmake TCF_FILE=../../hw/em9d.tcf EXT_CFLAGS="-DMODEL_BIT_DEPTH=816"
155+
gmake run_FX16_FX8_FX8 TCF_FILE=../../hw/em9d.tcf
156156

157157
Example application may be used in three modes:
158158
1. **Built-in input processing.** Uses only hard-coded vector for the single input model inference.

0 commit comments

Comments
 (0)