Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Commit

Permalink
Rename lib name (#724)
Browse files Browse the repository at this point in the history
  • Loading branch information
primenumber authored Feb 14, 2020
1 parent 32df2a6 commit da605d6
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 55 deletions.
8 changes: 4 additions & 4 deletions .buildkite/inference-benchmark-pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ set -euf
# test cases to run inference
# "<buildkite agent-type> <model filename>"
TEST_CASES=(
"de10nano lib/lib_arm.so"
"de10nano lib/lib_fpga.so"
"de10nano lib/libdlk_arm.so"
"de10nano lib/libdlk_fpga.so"

"jetson-nano minimal_graph_with_shape.pb"
"jetson-tx2 minimal_graph_with_shape.pb"
"jetson-xavier minimal_graph_with_shape.pb"

"raspberry-pi lib/lib_aarch64.so"
"raspberry-pi lib/libdlk_aarch64.so"
)

# Generate setup step
Expand Down Expand Up @@ -62,7 +62,7 @@ for TEST_CASE in "${TEST_CASES[@]}" ; do
EOS

# Generate commands to run inference (with and without "sudo")
if [ "${AGENT}" = "de10nano" ] && [ "${MODEL}" = "lib/lib_fpga.so" ] ; then
if [ "${AGENT}" = "de10nano" ] && [ "${MODEL}" = "lib/libdlk_fpga.so" ] ; then
cat <<EOS
sudo python run.py -i ../../inference_test_data/raw_image.png -c ../models/meta.yaml -m ../models/${MODEL}
sudo chown -R buildkite-agent:buildkite-agent output
Expand Down
14 changes: 7 additions & 7 deletions blueoil/cmd/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ def strip_binary(output):

if output in {"lm_x86.elf", "lm_x86_avx.elf"}:
subprocess.run(("strip", output))
elif output in {"lib_x86.so", "lib_x86_avx.so"}:
elif output in {"libdlk_x86.so", "libdlk_x86_avx.so"}:
subprocess.run(("strip", "-x", "--strip-unneeded", output))
elif output in {"lm_arm.elf", "lm_fpga.elf"}:
subprocess.run(("arm-linux-gnueabihf-strip", output))
elif output in {"lib_arm.so", "lib_fpga.so"}:
elif output in {"libdlk_arm.so", "libdlk_fpga.so"}:
subprocess.run(("arm-linux-gnueabihf-strip", "-x", "--strip-unneeded", output))


Expand All @@ -105,11 +105,11 @@ def make_all(project_dir, output_dir):
["lm_arm", "lm_arm.elf"],
["lm_fpga", "lm_fpga.elf"],
["lm_aarch64", "lm_aarch64.elf"],
["lib_x86", "lib_x86.so"],
["lib_x86_avx", "lib_x86_avx.so"],
["lib_arm", "lib_arm.so"],
["lib_fpga", "lib_fpga.so"],
["lib_aarch64", "lib_aarch64.so"],
["lib_x86", "libdlk_x86.so"],
["lib_x86_avx", "libdlk_x86_avx.so"],
["lib_arm", "libdlk_arm.so"],
["lib_fpga", "libdlk_fpga.so"],
["lib_aarch64", "libdlk_aarch64.so"],
["ar_x86", "libdlk_x86.a"],
["ar_x86_avx", "libdlk_x86_avx.a"],
["ar_arm", "libdlk_arm.a"],
Expand Down
2 changes: 1 addition & 1 deletion dlk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ If you need to run the generated binary on FPGA, please follow Custom project ge
>> PYTHONPATH=python/dlk python python/dlk/scripts/generate_project.py -i examples/classification/lmnet_quantize_cifar10/minimal_graph_with_shape.pb -o tmp/ -p classification
>> cd tmp/classification.prj
>> make lib_x86 -j 4
>> PYTHONPATH=python/dlk python utils/run_test.py -i <path to input image>/raw_image.png -l <path to generated library>/lib_x86.so -e <path to expected output>/xxx_output\:0.npy
>> PYTHONPATH=python/dlk python utils/run_test.py -i <path to input image>/raw_image.png -l <path to generated library>/libdlk_x86.so -e <path to expected output>/xxx_output\:0.npy
```
Here the npy file `xxx_output\:0.npy` starts with a certain number, followed by "_output".

Expand Down
2 changes: 1 addition & 1 deletion dlk/python/dlk/templates/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ target_compile_definitions(lm PUBLIC -DFUNC_TIME_MEASUREMENT)
add_library(lib SHARED ${SRC_LIB_ALL})
add_dlk_target_compile_properties(lib)
set_target_properties(lib PROPERTIES PREFIX "")
set_target_properties(lib PROPERTIES SUFFIX "_${CMAKE_SYSTEM_PROCESSOR}${FPGA_SUFFIX}.so")
set_target_properties(lib PROPERTIES SUFFIX "dlk_${CMAKE_SYSTEM_PROCESSOR}${FPGA_SUFFIX}.so")
set_target_properties(lib PROPERTIES CXX_VISIBILITY_PRESET hidden)

#
Expand Down
17 changes: 12 additions & 5 deletions dlk/python/dlk/templates/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -135,25 +135,32 @@ lm_fpga: CXX = arm-linux-gnueabihf-g++
lm_fpga: FLAGS += $(INCLUDES) -std=c++14 -O3 -DUSE_NEON -DRUN_ON_FPGA -DUSE_PNG -DAARCH32 -mcpu=cortex-a9 -mfpu=neon -mthumb -pthread -g -fopenmp -DFUNC_TIME_MEASUREMENT
lm_fpga: CXXFLAGS +=

.PHONY: lib_x86 lib_x86_avx lib_aarch64 lib_arm lib_fpga

lib_x86: CXX = g++
lib_x86: FLAGS += $(INCLUDES) -O3 -std=c++14 -fPIC -fvisibility=hidden -pthread -g
lib_x86: CXXFLAGS +=
lib_x86: NAME = x86

lib_x86_avx: CXX = g++
lib_x86_avx: FLAGS += $(INCLUDES) -O3 -std=c++14 -fPIC -fvisibility=hidden -DUSE_AVX -mavx2 -mfma -pthread -g -fopenmp
lib_x86_avx: CXXFLAGS +=
lib_x86_avx: NAME = x86_avx

lib_aarch64: CXX = aarch64-linux-gnu-g++
lib_aarch64: FLAGS += $(INCLUDES) -O3 -std=c++14 -fPIC -fvisibility=hidden -DUSE_NEON -pthread -g
lib_aarch64: CXXFLAGS +=
lib_aarch64: NAME = aarch64

lib_arm: CXX = arm-linux-gnueabihf-g++
lib_arm: FLAGS += $(INCLUDES) -O3 -std=c++14 -fPIC -DUSE_NEON -DAARCH32 -mcpu=cortex-a9 -mfpu=neon -mthumb -fvisibility=hidden -pthread -g -fopenmp
lib_arm: CXXFLAGS +=
lib_arm: NAME = arm

lib_fpga: CXX = arm-linux-gnueabihf-g++
lib_fpga: FLAGS += $(INCLUDES) -O3 -std=c++14 -fPIC -DUSE_NEON -DRUN_ON_FPGA -DAARCH32 -mcpu=cortex-a9 -mfpu=neon -mthumb -fvisibility=hidden -pthread -g -fopenmp
lib_fpga: CXXFLAGS +=
lib_fpga: NAME = fpga

ar_x86: AR = ar
ar_x86: CXX = g++
Expand Down Expand Up @@ -202,19 +209,19 @@ $(TARGETS_X86_AVX): $(OBJ) $(LIB_X86_AVX_OBJ)
$(CXX) $(FLAGS) $(OBJ) $(LIB_X86_AVX_OBJ) -o $@.elf $(CXXFLAGS) -pthread -ldl

$(LIBS_X86): $(LIB_OBJ) $(LIB_X86_OBJ)
$(CXX) $(FLAGS) $(LIB_OBJ) $(LIB_X86_OBJ) -o $@.so $(CXXFLAGS) -shared -pthread -ldl
$(CXX) $(FLAGS) $(LIB_OBJ) $(LIB_X86_OBJ) -o libdlk_$(NAME).so $(CXXFLAGS) -shared -pthread -ldl

$(LIBS_X86_AVX): $(LIB_OBJ) $(LIB_X86_AVX_OBJ)
$(CXX) $(FLAGS) $(LIB_OBJ) $(LIB_X86_AVX_OBJ) -o $@.so $(CXXFLAGS) -shared -pthread -ldl
$(CXX) $(FLAGS) $(LIB_OBJ) $(LIB_X86_AVX_OBJ) -o libdlk_$(NAME).so $(CXXFLAGS) -shared -pthread -ldl

$(LIBS_AARCH64): $(LIB_OBJ) $(LIB_AARCH64_OBJ)
$(CXX) $(FLAGS) $(LIB_OBJ) $(LIB_AARCH64_OBJ) -o $@.so $(CXXFLAGS) -shared -pthread -ldl
$(CXX) $(FLAGS) $(LIB_OBJ) $(LIB_AARCH64_OBJ) -o libdlk_$(NAME).so $(CXXFLAGS) -shared -pthread -ldl

$(LIBS_ARM): $(LIB_OBJ) $(LIB_ARM_OBJ)
$(CXX) $(FLAGS) $(LIB_OBJ) $(LIB_ARM_OBJ) -o $@.so $(CXXFLAGS) -shared -pthread -ldl
$(CXX) $(FLAGS) $(LIB_OBJ) $(LIB_ARM_OBJ) -o libdlk_$(NAME).so $(CXXFLAGS) -shared -pthread -ldl

$(LIBS_FPGA): $(LIB_OBJ) $(LIB_FPGA_OBJ)
$(CXX) $(FLAGS) $(LIB_OBJ) $(LIB_FPGA_OBJ) -o $@.so $(CXXFLAGS) -shared -pthread -ldl
$(CXX) $(FLAGS) $(LIB_OBJ) $(LIB_FPGA_OBJ) -o libdlk_$(NAME).so $(CXXFLAGS) -shared -pthread -ldl

$(ARS_X86): $(LIB_OBJ) $(LIB_X86_OBJ)
$(AR) $(LDFLAGS) libdlk_$(NAME).a $(LIB_OBJ) $(LIB_X86_OBJ)
Expand Down
2 changes: 1 addition & 1 deletion dlk/tests/test_code_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def codegen_cpu(self,
cache_dma=cache_dma,
)

lib_name = 'lib_' + cpu_name
lib_name = 'libdlk_' + cpu_name
project_dir = os.path.join(output_path, project_name + '.prj')
generated_lib = os.path.join(project_dir, lib_name + '.so')
npy_targz = os.path.join(input_dir_path, expected_output_set_name + '.tar.gz')
Expand Down
6 changes: 3 additions & 3 deletions docs/dlk/auto_script.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ You'll see the following files.
* lm_x86.elf
* lm_arm.elf
* lm_fpga.elf
* lib_x86.so
* lib_arm.so
* lib_fpga.so
* libdlk_x86.so
* libdlk_arm.so
* libdlk_fpga.so
* <FPGA_DIR>/preloader-mkpimage.bin
* <FPGA_DIR>/soc_system.rbf

Expand Down
10 changes: 5 additions & 5 deletions docs/dlk/shared_library.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ make lib_fpga

These commands will generate the following files:
```
lib_x86.so
lib_arm.so
lib_fpga.so
libdlk_x86.so
libdlk_arm.so
libdlk_fpga.so
```

After generating the shared librariues, you can use them from, for example, Python and C++.
Expand Down Expand Up @@ -60,7 +60,7 @@ In above sample code `utils/run_inference.py`, you can run the graph with an inp
The result would be like below.

```
> PYTHONPATH=python/dlk python utils/run_inference.py input_image.png ./lib_x86.so
> PYTHONPATH=python/dlk python utils/run_inference.py input_image.png ./libdlk_x86.so
Output: [[0.10000502 0.10004324 0.09995745 0.10000631 0.10003947 0.09993229 0.10000196 0.09998367 0.1000008 0.10002969]]
```

Expand All @@ -78,7 +78,7 @@ For example, there is `expected.npy` that is the output tensor data you expect f
When you run it with the input image and the library, the result would be like below.

```
> PYTHONPATH=python/dlk python utils/run_test.py -i input_image.png -l ./lib_x86.so -e expected.npy
> PYTHONPATH=python/dlk python utils/run_test.py -i input_image.png -l ./libdlk_x86.so -e expected.npy
Output:
[[0.10000502 0.10004324 0.09995745 0.10000631 0.10003947 0.09993229 0.10000196 0.09998367 0.1000008 0.10002969]]
Test: 100.000% of the output values are correct
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorial/image_cls.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ output
│   └── soc_system.dtb
├── models
│   ├── lib (include trained model library)
│   │   ├── lib_arm.so
│   │   ├── lib_fpga.so
│   │   └── lib_x86.so
│   │   ├── libdlk_arm.so
│   │   ├── libdlk_fpga.so
│   │   └── libdlk_x86.so
│   └── meta.yaml (model configuration)
├── python
│   ├── lmnet (include pre-process/post-process)
Expand Down Expand Up @@ -181,7 +181,7 @@ output
$ sudo pip install -r requirements.txt # only the first time
$ python run.py \
-i {inference image path} \
-m ../models/lib/lib_x86.so \
-m ../models/lib/libdlk_x86.so \
-c ../models/meta.yaml

- Check inference result. Should look like the example below.
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorial/image_det.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ output
│   └── soc_system.dtb
├── models
│   ├── lib (include trained model library)
│   │   ├── lib_arm.so
│   │   ├── lib_fpga.so
│   │   └── lib_x86.so
│   │   ├── libdlk_arm.so
│   │   ├── libdlk_fpga.so
│   │   └── libdlk_x86.so
│   └── meta.yaml (model configuration)
├── python
│   ├── lmnet (include pre-process/post-process)
Expand Down Expand Up @@ -157,7 +157,7 @@ output
$ sudo pip install -r requirements.txt # for the first time only
$ python run.py \
-i {inference image path} \
-m ../models/lib/lib_x86.so \
-m ../models/lib/libdlk_x86.so \
-c ../models/meta.yaml
```

Expand Down
10 changes: 5 additions & 5 deletions docs/tutorial/image_keypoint_detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ output
│   └── soc_system.rbf
├── models
│   ├── lib
│   │   ├── lib_aarch64.so
│   │   ├── lib_arm.so
│   │   ├── libdlk_aarch64.so
│   │   ├── libdlk_arm.so
│   │   ├── libdlk_aarch64.a
│   │   ├── libdlk_arm.a
│   │   ├── libdlk_fpga.a
│   │   ├── libdlk_x86.a
│   │   ├── lib_fpga.so
│   │   ├── lib_x86.so
│   │   ├── libdlk_fpga.so
│   │   ├── libdlk_x86.so
│   │   ├── lm_aarch64.elf
│   │   ├── lm_arm.elf
│   │   ├── lm_fpga.elf
Expand Down Expand Up @@ -183,7 +183,7 @@ output
$ sudo pip install -r requirements.txt # for the first time only
$ python run.py \
-i {inference image path} \
-m ../models/lib/lib_x86.so \
-m ../models/lib/libdlk_x86.so \
-c ../models/meta.yaml
```

Expand Down
8 changes: 4 additions & 4 deletions docs/tutorial/image_seg.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ output
│   └── soc_system.dtb
├── models
│   ├── lib (include trained model library)
│   │   ├── lib_arm.so
│   │   ├── lib_fpga.so
│   │   └── lib_x86.so
│   │   ├── libdlk_arm.so
│   │   ├── libdlk_fpga.so
│   │   └── libdlk_x86.so
│   └── meta.yaml (model configuration)
├── python
│   ├── lmnet (include pre-process/post-process)
Expand Down Expand Up @@ -182,7 +182,7 @@ output
$ sudo pip install -r requirements.txt # for the first time only
$ python run.py \
-i {inference image path} \
-m ../models/lib/lib_x86.so \
-m ../models/lib/libdlk_x86.so \
-c ../models/meta.yaml
```

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial/run_fpga.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ demo
│ └── preloader-mkpimage.bin
├── models
│   ├── lib
│   │   └── lib_fpga.so
│   │   └── libdlk_fpga.so
│   └── meta.yaml
└── python
   ├── lmnet
Expand All @@ -49,7 +49,7 @@ Explore into the `demo/python` directory, and execute the following commands on
$ export LC_ALL=C # for the first time only
$ sudo pip install -r requirements.txt # for the first time only
$ python usb_camera_demo.py \
-m ../models/lib/lib_fpga.so \
-m ../models/lib/libdlk_fpga.so \
-c ../models/meta.yaml

Press [ESC], to stop the demo.
4 changes: 2 additions & 2 deletions output_template/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

```
$ pip install -r requirements.txt
$ python run.py -i [your image file] -c ../models/meta.yaml -m ../models/lib/lib_fpga.so
$ python run.py -i [your image file] -c ../models/meta.yaml -m ../models/lib/libdlk_fpga.so
```
## Prerequisites
```
Expand Down Expand Up @@ -44,7 +44,7 @@ $ python -c "import cv2; print(cv2.__version__)"

```
$ pip install -r requirements.txt
$ python usb_camera_demo.py -c ../models/meta.yaml -m ../models/lib/lib_fpga.so
$ python usb_camera_demo.py -c ../models/meta.yaml -m ../models/lib/libdlk_fpga.so
```


Expand Down
2 changes: 1 addition & 1 deletion output_template/python/motion_jpeg_server_from_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def run(model, config_file, port=80):
Inference Model filename
(-l is deprecated please use -m instead)
""",
default="../models/lib/lib_fpga.so",
default="../models/lib/libdlk_fpga.so",
)
@click.option(
"-c",
Expand Down
2 changes: 1 addition & 1 deletion output_template/python/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def run_prediction(input_image, model, config_file, trial=1):
Inference Model filename
(-l is deprecated please use -m instead)
""",
default="../models/lib/lib_fpga.so",
default="../models/lib/libdlk_fpga.so",
)
@click.option(
"-c",
Expand Down
2 changes: 1 addition & 1 deletion output_template/python/usb_camera_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def run(model, config_file):
Inference Model filename
(-l is deprecated please use -m instead)
""",
default="../models/lib/lib_fpga.so",
default="../models/lib/libdlk_fpga.so",
)
@click.option(
"-c",
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ def run_all_steps(dirs, config_file):
'models',
'lib',
)
assert os.path.exists(os.path.join(lib_dir, 'lib_aarch64.so'))
assert os.path.exists(os.path.join(lib_dir, 'lib_arm.so'))
assert os.path.exists(os.path.join(lib_dir, 'lib_fpga.so'))
assert os.path.exists(os.path.join(lib_dir, 'lib_x86.so'))
assert os.path.exists(os.path.join(lib_dir, 'libdlk_aarch64.so'))
assert os.path.exists(os.path.join(lib_dir, 'libdlk_arm.so'))
assert os.path.exists(os.path.join(lib_dir, 'libdlk_fpga.so'))
assert os.path.exists(os.path.join(lib_dir, 'libdlk_x86.so'))
assert os.path.exists(os.path.join(lib_dir, 'lm_aarch64.elf'))
assert os.path.exists(os.path.join(lib_dir, 'lm_arm.elf'))
assert os.path.exists(os.path.join(lib_dir, 'lm_fpga.elf'))
Expand Down

0 comments on commit da605d6

Please sign in to comment.