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
[NNAdapter][EEasyTechNPU] Init support for EEasyTechNPU #8960
Conversation
Thanks for your contribution! |
lite/backends/nnadapter/nnadapter/src/driver/eeasytech_npu/CMakeLists.txt
Show resolved
Hide resolved
lite/backends/nnadapter/nnadapter/src/driver/eeasytech_npu/CMakeLists.txt
Show resolved
Hide resolved
input_tensor = converter->ConvertOperand(input_operand); | ||
} | ||
auto output_tensor = converter->ConvertOperand(output_operand); | ||
auto new_scale_operand = converter->GetOperand(scale_operand); |
There was a problem hiding this comment.
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的销毁一起销毁、
There was a problem hiding this comment.
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
lite/backends/nnadapter/nnadapter/src/driver/eeasytech_npu/converter/converter.cc
Show resolved
Hide resolved
lite/backends/nnadapter/nnadapter/src/driver/eeasytech_npu/converter/converter.cc
Show resolved
Hide resolved
lite/backends/nnadapter/nnadapter/src/driver/eeasytech_npu/converter/converter.cc
Outdated
Show resolved
Hide resolved
lite/backends/nnadapter/nnadapter/src/driver/eeasytech_npu/converter/converter.cc
Outdated
Show resolved
Hide resolved
// 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是否可以去掉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已删除,在新commit中修复
lite/backends/nnadapter/nnadapter/src/driver/eeasytech_npu/converter/resize_linear.cc
Show resolved
Hide resolved
lite/backends/nnadapter/nnadapter/src/driver/eeasytech_npu/converter/resize_nearest.cc
Show resolved
Hide resolved
lite/backends/nnadapter/nnadapter/src/driver/eeasytech_npu/converter/split.cc
Outdated
Show resolved
Hide resolved
#add_library(eznpu_ddk SHARED IMPORTED GLOBAL) | ||
#set_property(TARGET eznpu_ddk PROPERTY IMPORTED_LOCATION libeznpu_ddk.so) | ||
|
||
set(${DEVICE_NAME}_deps eznpu_ddk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
根据其它硬件的最新版dependencies.cmake改下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在新commit中修复
lite/backends/nnadapter/nnadapter/src/driver/eeasytech_npu/utility.h
Outdated
Show resolved
Hide resolved
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 "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
还是没改回来, 是全部要改,可以参考下
Paddle-Lite/lite/backends/nnadapter/nnadapter/src/driver/rockchip_npu/CMakeLists.txt
Line 18 in 59e1dea
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") |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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)); 就行了
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,已经和亿智相关同学确认,为全大写EEASYTECH,在新commit中修复
test=develop
test=develop
test=develop
test=develop
test=develop
test=develop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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