fix conv3x3 coder bug

This commit is contained in:
chengyuanwang 2021-06-15 09:11:32 +08:00
parent ba3ba27442
commit 20f0425bb4
4 changed files with 17 additions and 60 deletions

View File

@ -1,56 +0,0 @@
cmake_minimum_required(VERSION 3.14)
project(micro)
option(MSLITE_ENABLE_TESTCASES "if build testcase" off)
option(PLATFORM_ARM32 "build operator for android arm 32" off)
option(PLATFORM_ARM64 "build operator for android arm 64" off)
string(REPLACE "/mindspore/lite/micro" "" TOP_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(NNACL_DIR ${TOP_DIR}/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl)
include_directories(${CMAKE_BINARY_DIR})
include(${TOP_DIR}/cmake/utils.cmake)
include(${TOP_DIR}/cmake/dependency_utils.cmake)
include(${TOP_DIR}/cmake/dependency_securec.cmake)
if(NOT PLATFORM_ARM64 AND NOT PLATFORM_ARM32)
set(BUILD_LITE ON)
include(${TOP_DIR}/cmake/external_libs/glog.cmake)
### flatbuffer
include(${TOP_DIR}/cmake/external_libs/flatbuffers.cmake)
file(GLOB FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../schema/*.fbs)
ms_build_flatbuffers_lite(FBS_FILES
${CMAKE_CURRENT_SOURCE_DIR}/../schema/
fbs_src
${CMAKE_BINARY_DIR}/schema
""
)
ms_build_flatbuffers_lite(FBS_FILES
${CMAKE_CURRENT_SOURCE_DIR}/../schema/
fbs_inner_src
${CMAKE_BINARY_DIR}/schema/inner
"inner"
)
endif()
set(CMAKE_CXX_STANDARD 17)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
MESSAGE("******Micro Debug********")
set(CMAKE_C_FLAGS "-Wall -Werror -ftrapv -DDebug -g -fvisibility=default ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wall -Werror -ftrapv -DDebug -g -fvisibility=default ${CMAKE_CXX_FLAGS}")
else()
MESSAGE(" ******Micro Release********")
set(CMAKE_C_FLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -Wall -Werror \
-fstack-protector-all -Wno-attributes -Wno-deprecated-declarations -Wno-missing-braces ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -Wall -Werror \
-fstack-protector-all -Wno-attributes -Wno-deprecated-declarations \
-Wno-missing-braces -Wno-overloaded-virtual ${CMAKE_CXX_FLAGS}")
endif()
if(NOT WIN32)
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,relro,-z,now -Wl,-z,noexecstack -fPIC -pie ${CMAKE_EXE_LINKER_FLAGS}")
endif()
add_subdirectory(coder)
if(MSLITE_ENABLE_TESTCASES AND NOT PLATFORM_ARM64 AND NOT PLATFORM_ARM32)
add_subdirectory(test)
endif()

View File

@ -146,6 +146,20 @@ int Conv2D3x3Int8Coder::DoCode(CoderContext *const context) {
"conv3x3_run_int8_wrapper.c",
});
}
if (target_ == kARM32A) {
Collect(context, {}, {},
{
"IndirectGemmInt16to32_8x4.S",
"MatmulInt8Opt.S",
});
} else if (target_ == kARM64) {
Collect(context, {}, {},
{
"PreSum4x16Int8Peroc.S",
"PreSum4x16Int8Pert.S",
"MatmulInt8Opt.S",
});
}
nnacl::NNaclInt8Serializer code;
code.precision(kPrecision);
// call the op function
@ -166,8 +180,7 @@ int Conv2D3x3Int8Coder::DoCode(CoderContext *const context) {
code.CodeFunction(kParallelLaunch, "Conv3x3Int8Run", kRunArgsAddr, gThreadNum);
} else {
code.CodeFunction("Conv3x3Int8", c8_input_, transformed_filter_addr_, new_bias_addr_, output_tensor_, tile_buffer_,
block_unit_buffer_, tmp_dst_buffer_, tmp_out_, kDefaultTaskId, "&conv_param_", kLhsScale,
kRhsScale);
block_unit_buffer_, tmp_dst_buffer_, tmp_out_, kDefaultTaskId, "&conv_param_");
}
code.CodeFunction("PackNC4HW4ToNHWCInt8", tmp_out_, output_tensor_, conv_param_->output_batch_,
conv_param_->output_h_ * conv_param_->output_w_, conv_param_->output_channel_);

View File

@ -16,7 +16,7 @@
#include "wrapper/int8/conv3x3_run_int8_wrapper.h"
int Conv3x3Int8Run(void *cdata, int task_id, float lhs_scale, float rhs_scale) {
int Conv3x3Int8Run(void *cdata, int task_id) {
Conv3x3Int8Args *args = (Conv3x3Int8Args *)cdata;
Conv3x3Int8(args->input_data, args->transed_weight, args->bias_data, args->output_data, args->tile_buffer,
args->block_unit_buffer, args->tmp_dst_buffer, args->tmp_out, task_id, args->conv_param);

View File

@ -33,6 +33,6 @@ typedef struct {
ConvParameter *conv_param;
} Conv3x3Int8Args;
int Conv3x3Int8Run(void *cdata, int task_id, float lhs_scale, float rhs_scale);
int Conv3x3Int8Run(void *cdata, int task_id);
#endif // MINDSPORE_LITE_MICRO_INT8_CONV3x3_WRAPPER_INT8_WRAPPER_H_