Code Build
Table 5-1 describes the parameters of the Makefile.
Parameter |
Description |
---|---|
ASCEND_PATH |
Installation directory of the ATC and OPP . For example: ASCEND_PATH := /home/HwHiAiUser/Ascend/ascend-toolkit/latest/xxx-linux_gccx.x.x
|
LOCAL_DIR |
Local directory. For example: LOCAL_DIR := ./ |
ATC_INCLUDE_DIR |
Path of the Ascend Graph API header file. For example: ATC_INCLUDE_DIR := $(ASCEND_PATH)/atc/include |
OPP_INCLUDE_DIR |
Path of the header file of the operator prototype definition. For example: OPP_INCLUDE_DIR := $(ASCEND_PATH)/opp/op_proto/built-in/inc |
LOCAL_MODULE_NAME |
Name of the generated executable file. For example: LOCAL_MODULE_NAME := ir_build |
CC |
Compiler. For example: CC := g++ |
CFLAGS |
Build options. For example: CFLAGS := -std=c++11 -g -Wall |
SRCS |
Source code. For example: SRCS := $(wildcard $(LOCAL_DIR)/main.cpp) |
INCLUDES |
Header files to be included. To include more header files, append to the existing lines. Do not delete the original lines. For example: INCLUDES := -I $(ASCEND_PATH)/opp/op_proto/built-in/inc \ -I $(ATC_INCLUDE_DIR)/graph \ -I $(ATC_INCLUDE_DIR)/ge \ -I $(ASCEND_PATH)/atc/include \ If the network contains a custom operator, include the header file of the custom operator prototype definition. |
LIBS |
Library to be linked with. To add more library files, append to the existing lines. Do not delete the original lines. For example: LIBS := -L ${ASCEND_PATH}/atc/lib64/stub \ -lgraph \ -lge_compiler \ CAUTION:
Do not link with other .so files in the ATC and OPP software packages. Otherwise, compatibility problems may occur during subsequent version upgrade. |
Makefile example:
ASCEND_PATH := /home/HwHiAiUser/Ascend/ascend-toolkit/latest/xxx-linux_gccx.x.x
LOCAL_DIR := ./
ATC_INCLUDE_DIR := $(ASCEND_PATH)/atc/include
OPP_INCLUDE_DIR := $(ASCEND_PATH)/opp/op_proto/built-in/inc
LOCAL_MODULE_NAME := ir_build
CC := g++
CFLAGS := -std=c++11 -g -Wall
SRCS := $(wildcard $(LOCAL_DIR)/main.cpp)
INCLUDES := -I $(ASCEND_PATH)/opp/op_proto/built-in/inc \
-I $(ATC_INCLUDE_DIR)/graph \
-I $(ATC_INCLUDE_DIR)/ge \
-I $(ASCEND_PATH)/atc/include \
LIBS := -L ${ASCEND_PATH}/atc/lib64/stub \
-lgraph \
-lge_compiler \
ir_build:
mkdir -p out
$(CC) $(SRCS) $(INCLUDES) $(LIBS) $(CFLAGS) -o ./out/$(LOCAL_MODULE_NAME)
clean:
rm -rf out
With the created Makefile, you can run the make clean and make ir_build commands in sequence.