Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NNAdapter][EEasyTechNPU] Init support for EEasyTechNPU #8960

Merged
merged 6 commits into from May 12, 2022
Merged

[NNAdapter][EEasyTechNPU] Init support for EEasyTechNPU #8960

merged 6 commits into from May 12, 2022

Conversation

yingshengBD
Copy link
Collaborator

init support for eeasytechNPU
SoC: eeasytech 806/810,506/510,206/210
cotain OPs:add, mul, sub, avg_pool, max_pool, bn, conv2d, flatten, reshape, fc, hard-swish, sigmoid, tanh, split, concat, interp_bilinear, interp_nearest, relu, relu6, transpose

@paddle-bot-old
Copy link

Thanks for your contribution!

@yingshengBD yingshengBD changed the title init support for eeasytechNPU [NNAdapter][EEasyTechNPU]init support for eeasytechNPU Apr 27, 2022
input_tensor = converter->ConvertOperand(input_operand);
}
auto output_tensor = converter->ConvertOperand(output_operand);
auto new_scale_operand = converter->GetOperand(scale_operand);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以去掉GetOperand和ClearOperands接口,直接使用临时变量存储转换后的bias 、scale数据,然后再调用AddXXXConstantTensor就行了,如果eeasy ddk只支持引用buffer,可以在Converter维护一个std::vector<std::vector<int8_t>> buffers_; 在完成模型生成后,随着Converter的销毁一起销毁、

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在新commit中修复,使用AddVariableTensor和AddConstantTensor将BN转换成mul和add

// Convert a NNAdapter model to eznn graph and tensors
int Apply(core::Model* model);
// Mapping a eznn tensor to a NNAdapter operand
std::string GetTensorName(core::Operand* operand);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是否可以去掉

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已删除,在新commit中修复

#add_library(eznpu_ddk SHARED IMPORTED GLOBAL)
#set_property(TARGET eznpu_ddk PROPERTY IMPORTED_LOCATION libeznpu_ddk.so)

set(${DEVICE_NAME}_deps eznpu_ddk)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

根据其它硬件的最新版dependencies.cmake改下

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在新commit中修复

@yingshengBD yingshengBD requested a review from liyancas as a code owner May 7, 2022 12:51
Comment on lines 18 to 30
add_definitions(-DNNADAPTER_DEVICE_SYMBOL=${NNADAPTER_DEVICE_SYMBOL_PREFIX}${DEVICE_NAME})

include(dependencies.cmake)

include_directories(.)
aux_source_directory(converter CONVERTERS)
aux_source_directory(optimizer OPTIMIZERS)
set(SRCS utility.cc ${OPTIMIZERS} ${CONVERTERS} engine.cc driver.cc)
set(DEPS ${NNADAPTER_OPERATIONS} ${NNADAPTER_UTILITIES} nnadapter_optimizer_convert_quantization_symm_to_asymm nnadapter_optimizer_fuse_matmul_add_into_fully_connected ${${DEVICE_NAME}_deps})

add_library(${DEVICE_NAME} SHARED ${SRCS})
target_link_libraries(${DEVICE_NAME} "-Wl,--start-group" ${DEPS} "-Wl,--end-group")
set(NNADAPTER_DEVICES ${NNADAPTER_DEVICES} ${DEVICE_NAME} CACHE INTERNAL "")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还是没改回来, 是全部要改,可以参考下

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Os -fvisibility=hidden -fvisibility-inlines-hidden -fexceptions -fasynchronous-unwind-tables -funwind-tables -Wl,--allow-shlib-undefined")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在新commit中修复


int ConvertElementwise(Converter* converter, core::Operation* operation) {
ELEMENTWISE_OPERATION_EXTRACT_INPUTS_OUTPUTS
// Convert to eeasynpu tensors and operators
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

空一行吧

int ConvertResizeNearest(Converter *converter, core::Operation *operation) {
RESIZE_NEAREST_OPERATION_EXTRACT_INPUTS_OUTPUTS
NNADAPTER_CHECK_EQ(IsOperandWithDynamicShape(input_operand), false);
// Convert to eeasynpu tensors and node
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

空一行?

int ConvertResizeLinear(Converter *converter, core::Operation *operation) {
RESIZE_LINEAR_OPERATION_EXTRACT_INPUTS_OUTPUTS
NNADAPTER_CHECK_EQ(IsOperandWithDynamicShape(input_operand), false);
// Convert to eeasynpu tensors and node
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

空一行?所有converter 的 // Convert to eeasynpu tensors and node 前面都空一行吧


int ConvertResizeLinear(Converter *converter, core::Operation *operation) {
RESIZE_LINEAR_OPERATION_EXTRACT_INPUTS_OUTPUTS
NNADAPTER_CHECK_EQ(IsOperandWithDynamicShape(input_operand), false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接 NNADAPTER_CHECK(!IsOperandWithDynamicShape(input_operand)); 就行了

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在新commit中修复


NNADAPTER_EXPORT nnadapter::driver::Device NNADAPTER_AS_SYM2(DEVICE_NAME) = {
.name = NNADAPTER_AS_STR2(DEVICE_NAME),
.vendor = "Eeasytech",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vendor 名称和亿智确认下吧,使用 EEasyTech 、eeasytech 还是 EEASY-TECH

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯,已经和亿智相关同学确认,为全大写EEASYTECH,在新commit中修复

Copy link
Collaborator

@hong19860320 hong19860320 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hong19860320 hong19860320 changed the title [NNAdapter][EEasyTechNPU]init support for eeasytechNPU [NNAdapter][EEasyTechNPU] Init support for EEasytechNPU May 12, 2022
@hong19860320 hong19860320 changed the title [NNAdapter][EEasyTechNPU] Init support for EEasytechNPU [NNAdapter][EEasyTechNPU] Init support for EEasyTechNPU May 12, 2022
@hong19860320 hong19860320 merged commit e367b05 into PaddlePaddle:develop May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants