forked from mindspore-Ecosystem/mindspore
fix fixbotengine-cxx issue
This commit is contained in:
parent
475386e338
commit
d58bfa3a9e
|
@ -19,8 +19,7 @@
|
|||
#include "coder/opcoders/op_coder.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
static constexpr size_t kDefaultMemAlignSize = 8;
|
||||
constexpr auto kDefaultMemAlignSize = 8;
|
||||
|
||||
static size_t AlignMemorySize(size_t size) {
|
||||
return ((size + kDefaultMemAlignSize - 1) / kDefaultMemAlignSize) * kDefaultMemAlignSize;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "coder/generator/component/component.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
class CoderFlags : public virtual FlagParser {
|
||||
public:
|
||||
CoderFlags() {
|
||||
|
@ -220,5 +219,4 @@ int RunCoder(int argc, const char **argv) {
|
|||
MS_LOG(INFO) << "end of Coder";
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -28,5 +28,4 @@ CoderContext::CoderContext() {
|
|||
void CoderContext::AppendCode(const std::string &codeBlock) { this->code_blocks_.emplace_back(codeBlock); }
|
||||
|
||||
void CoderContext::AppendInitCode(const std::string &codeBlock) { this->initialContent_.push_back(codeBlock); }
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include <memory>
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
void CodeCMakeNetLibrary(std::ofstream &ofs, const std::unique_ptr<CoderContext> &ctx, const Configurator *config) {
|
||||
ofs << "include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include/)\n";
|
||||
if (config->target() == kARM32M) {
|
||||
|
@ -60,5 +59,4 @@ void CodeCMakeNetLibrary(std::ofstream &ofs, const std::unique_ptr<CoderContext>
|
|||
" )\n"
|
||||
"add_library(net STATIC ${NET_SRC})\n";
|
||||
}
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -276,5 +276,4 @@ void CodeInferenceState(std::ofstream &ofs) {
|
|||
<< "void "
|
||||
<< "Inference();\n\n";
|
||||
}
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#include "coder/generator/component/const_blocks/benchmark.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
const char *benchmark_source = R"RAW(
|
||||
const char benchmark_source[] = R"RAW(
|
||||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
|
@ -225,5 +224,6 @@ int main(int argc, const char **argv) {
|
|||
}
|
||||
return lite::RET_OK;
|
||||
}
|
||||
|
||||
)RAW";
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
extern const char *benchmark_source;
|
||||
extern const char benchmark_source[];
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#include "coder/generator/component/const_blocks/cmake_lists.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
const char *bench_cmake_lists_txt = R"RAW(
|
||||
const char bench_cmake_lists_txt[] = R"RAW(
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(benchmark)
|
||||
|
||||
|
@ -77,9 +76,10 @@ set(SRC_FILES
|
|||
)
|
||||
add_executable(benchmark ${SRC_FILES})
|
||||
target_link_libraries(benchmark net -lm -pthread)
|
||||
|
||||
)RAW";
|
||||
|
||||
const char *src_cmake_lists_txt = R"RAW(
|
||||
const char src_cmake_lists_txt[] = R"RAW(
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(net)
|
||||
|
||||
|
@ -178,6 +178,6 @@ function(create_library)
|
|||
endfunction(create_library)
|
||||
string(CONCAT library_name "lib" net ".a")
|
||||
create_library()
|
||||
)RAW";
|
||||
|
||||
)RAW";
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
extern const char *bench_cmake_lists_txt;
|
||||
extern const char *src_cmake_lists_txt;
|
||||
extern const char bench_cmake_lists_txt[];
|
||||
extern const char src_cmake_lists_txt[];
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#include "coder/generator/component/const_blocks/debug_utils.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
const char *debug_utils_h = R"RAW(
|
||||
const char debug_utils_h[] = R"RAW(
|
||||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
|
@ -94,7 +93,7 @@ void PrintTensorData(MicroTensor *tensor);
|
|||
|
||||
)RAW";
|
||||
|
||||
const char *debug_utils_c = R"RAW(
|
||||
const char debug_utils_c[] = R"RAW(
|
||||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
|
@ -300,5 +299,4 @@ void PrintTensor(MicroTensor *tensor, FILE *output_file, const char *is_input) {
|
|||
}
|
||||
|
||||
)RAW";
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
extern const char *debug_utils_h;
|
||||
extern const char *debug_utils_c;
|
||||
extern const char debug_utils_h[];
|
||||
extern const char debug_utils_c[];
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#include "coder/generator/component/const_blocks/license.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
const char *g_hwLicense = R"RAW(
|
||||
const char g_hwLicense[] = R"RAW(
|
||||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
|
@ -36,5 +35,4 @@ const char *g_hwLicense = R"RAW(
|
|||
*/
|
||||
|
||||
)RAW";
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
extern const char *g_hwLicense;
|
||||
extern const char g_hwLicense[];
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#include "coder/generator/component/const_blocks/load_input.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
const char *load_input_h = R"RAW(
|
||||
const char load_input_h[] = R"RAW(
|
||||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
|
@ -56,7 +55,7 @@ int ReadInputsFile(char *path, void **buffers, const int *inputs_size, int input
|
|||
|
||||
)RAW";
|
||||
|
||||
const char *load_input_c = R"RAW(
|
||||
const char load_input_c[] = R"RAW(
|
||||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
|
@ -152,5 +151,4 @@ int ReadInputsFile(char *path, void **buffers, const int *inputs_size, int input
|
|||
}
|
||||
|
||||
)RAW";
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
extern const char *load_input_h;
|
||||
extern const char *load_input_c;
|
||||
extern const char load_input_h[];
|
||||
extern const char load_input_c[];
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#include "coder/generator/component/const_blocks/mmodel.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
const char *model_header = R"RAW(
|
||||
const char model_header[] = R"RAW(
|
||||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
|
@ -82,6 +81,6 @@ Model *Model::Import(const char *model_buf, size_t size) {
|
|||
}
|
||||
} // namespace mindspore::lite
|
||||
#endif // MINDSPORE_LITE_LIBRARY_SOURCE_MODEL_H_
|
||||
)RAW";
|
||||
|
||||
)RAW";
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
extern const char *model_header;
|
||||
extern const char model_header[];
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#include "coder/generator/component/const_blocks/msession.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
const char *session_header = R"RAW(
|
||||
const char session_header[] = R"RAW(
|
||||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
|
@ -103,9 +102,10 @@ class LiteSession : public session::LiteSession {
|
|||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_LITE_MICRO_LIBRARY_SOURCE_SESSION_H_
|
||||
|
||||
)RAW";
|
||||
|
||||
const char *session_source = R"RAW(
|
||||
const char session_source[] = R"RAW(
|
||||
int LiteSession::RunGraph(const KernelCallBack &before, const KernelCallBack &after) {
|
||||
const void *inputs_data[inputs_.size()];
|
||||
for (size_t i = 0; i < inputs_.size(); ++i) {
|
||||
|
@ -167,6 +167,6 @@ mindspore::tensor::MSTensor *LiteSession::GetOutputByTensorName(const String &te
|
|||
return nullptr;
|
||||
}
|
||||
} // namespace lite
|
||||
)RAW";
|
||||
|
||||
)RAW";
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
extern const char *session_header;
|
||||
|
||||
extern const char *session_source;
|
||||
extern const char session_header[];
|
||||
extern const char session_source[];
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#include "coder/generator/component/const_blocks/mtensor.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
const char *tensor_header = R"RAW(
|
||||
const char tensor_header[] = R"RAW(
|
||||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
|
@ -86,9 +85,10 @@ class MTensor : public mindspore::tensor::MSTensor {
|
|||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_LITE_MICRO_LIBRARY_SOURCE_TENSOR_H_
|
||||
|
||||
)RAW";
|
||||
|
||||
const char *tensor_source = R"RAW(
|
||||
const char tensor_source[] = R"RAW(
|
||||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
|
@ -171,6 +171,6 @@ void *MTensor::MutableData() {
|
|||
}
|
||||
} // namespace lite
|
||||
} // namespace mindspore
|
||||
)RAW";
|
||||
|
||||
)RAW";
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
extern const char *tensor_header;
|
||||
extern const char *tensor_source;
|
||||
extern const char tensor_header[];
|
||||
extern const char tensor_source[];
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#include "coder/generator/component/const_blocks/thread_pool.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
const char *thread_header = R"RAW(
|
||||
const char thread_header[] = R"RAW(
|
||||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
|
@ -57,6 +56,6 @@ void ClearThreadPool();
|
|||
#endif
|
||||
|
||||
#endif // MINDSPORE_LITE_MICRO_CODER_THREAD_WRAPPER_H
|
||||
)RAW";
|
||||
|
||||
)RAW";
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
extern const char *thread_header;
|
||||
extern const char thread_header[];
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
using mindspore::schema::PrimitiveType_BatchNorm;
|
||||
|
||||
namespace mindspore::lite::micro::nnacl {
|
||||
|
||||
int BatchNormInt8Coder::Prepare(CoderContext *const context) {
|
||||
std::vector<int> input_shapes = input_tensor_->shape();
|
||||
size_t n_dim = input_shapes.size();
|
||||
|
|
|
@ -42,14 +42,14 @@ int ConcatInt8Coder::Prepare(CoderContext *const context) {
|
|||
"Null pointer reference: quant_concat_parm_->in_quant_args_.");
|
||||
for (int i = 0; i < static_cast<int>(input_num); i++) {
|
||||
auto *input_tensor = input_tensors().at(i);
|
||||
auto quant_args = input_tensor->quant_params();
|
||||
concat_param_->quant_arg_.in_args_[i].scale_ = quant_args.at(0).scale;
|
||||
concat_param_->quant_arg_.in_args_[i].zp_ = quant_args.at(0).zeroPoint;
|
||||
auto in_quant_args = input_tensor->quant_params();
|
||||
concat_param_->quant_arg_.in_args_[i].scale_ = in_quant_args.at(0).scale;
|
||||
concat_param_->quant_arg_.in_args_[i].zp_ = in_quant_args.at(0).zeroPoint;
|
||||
}
|
||||
|
||||
auto quant_args = output_tensor_->quant_params();
|
||||
concat_param_->quant_arg_.out_args_.scale_ = quant_args.at(0).scale;
|
||||
concat_param_->quant_arg_.out_args_.zp_ = quant_args.at(0).zeroPoint;
|
||||
auto out_quant_args = output_tensor_->quant_params();
|
||||
concat_param_->quant_arg_.out_args_.scale_ = out_quant_args.at(0).scale;
|
||||
concat_param_->quant_arg_.out_args_.zp_ = out_quant_args.at(0).zeroPoint;
|
||||
|
||||
concat_param_->quant_arg_.output_activation_min_ = std::numeric_limits<int8_t>::min();
|
||||
concat_param_->quant_arg_.output_activation_max_ = std::numeric_limits<int8_t>::max();
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "coder/opcoders/serializers/nnacl_serializer/nnacl_int8_serializer.h"
|
||||
|
||||
namespace mindspore::lite::micro::nnacl {
|
||||
|
||||
int Conv2D1x1Int8Coder::Prepare(CoderContext *const context) {
|
||||
matmul_param_ = new (std::nothrow) MatMulParameter();
|
||||
MS_CHECK_PTR(matmul_param_);
|
||||
|
@ -267,5 +266,4 @@ int Conv2D1x1Int8Coder::InitRunBuf() {
|
|||
MS_CHECK_PTR(packed_input_);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
} // namespace mindspore::lite::micro::nnacl
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
using mindspore::schema::PrimitiveType_Conv2DFusion;
|
||||
|
||||
namespace mindspore::lite::micro::nnacl {
|
||||
|
||||
int Conv2DINT8Coder::InitTmpBuffer(CoderContext *const context) {
|
||||
int kernel_plane = conv_param_->kernel_h_ * conv_param_->kernel_w_;
|
||||
int tmp_size;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "nnacl/int8/conv_depthwise_int8.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
int ConvolutionDepthwiseINT8Coder::Prepare(CoderContext *const context) {
|
||||
Conv2DBaseCoder::Init();
|
||||
// init sliding window param
|
||||
|
@ -130,5 +129,4 @@ int ConvolutionDepthwiseINT8Coder::DoCode(CoderContext *const context) {
|
|||
context->AppendCode(code.str());
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
using mindspore::schema::PrimitiveType_Conv2dTransposeFusion;
|
||||
|
||||
namespace mindspore::lite::micro::nnacl {
|
||||
|
||||
int DeconvolutionInt8Coder::Init(CoderContext *const context) {
|
||||
CheckSupportOptimize();
|
||||
MS_CHECK_RET_CODE(SetQuantParam(), "deconv int8 SetQuantParam error!");
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "coder/opcoders/file_collector.h"
|
||||
|
||||
namespace mindspore::lite::micro::nnacl {
|
||||
|
||||
int DivInt8Coder::Prepare(CoderContext *context) {
|
||||
input0 = input_tensors_.at(0);
|
||||
input1 = input_tensors_.at(1);
|
||||
|
@ -74,5 +73,4 @@ int DivInt8Coder::DoCode(CoderContext *const context) {
|
|||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
} // namespace mindspore::lite::micro::nnacl
|
||||
|
|
|
@ -59,5 +59,4 @@ int FullConnectionInt8Coder::DoCode(CoderContext *const context) {
|
|||
|
||||
REG_OPERATOR_CODER(kAllTargets, kNumberTypeInt8, PrimitiveType_FullConnection,
|
||||
CPUOpCoderCreator<FullConnectionInt8Coder>)
|
||||
|
||||
} // namespace mindspore::lite::micro::nnacl
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "coder/opcoders/file_collector.h"
|
||||
#include "coder/opcoders/parallel.h"
|
||||
namespace mindspore::lite::micro::nnacl {
|
||||
|
||||
int MatMulBaseInt8Coder::ReSize(CoderContext *const context) {
|
||||
ResizeParameter();
|
||||
if (InitTmpBuffer() != RET_OK) {
|
||||
|
|
|
@ -55,5 +55,4 @@ int MatMulInt8Coder::DoCode(CoderContext *const context) {
|
|||
}
|
||||
|
||||
REG_OPERATOR_CODER(kAllTargets, kNumberTypeInt8, PrimitiveType_MatMul, CPUOpCoderCreator<MatMulInt8Coder>)
|
||||
|
||||
} // namespace mindspore::lite::micro::nnacl
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
using mindspore::schema::PrimitiveType_AvgPoolFusion;
|
||||
using mindspore::schema::PrimitiveType_MaxPoolFusion;
|
||||
namespace mindspore::lite::micro::nnacl {
|
||||
|
||||
int PoolingInt8Coder::DoCode(CoderContext *const context) {
|
||||
// attribute
|
||||
auto *pooling_parameter = reinterpret_cast<PoolingParameter *>(parameter_);
|
||||
|
|
|
@ -238,5 +238,4 @@ int ReduceInt8Coder::DoCode(CoderContext *const context) {
|
|||
}
|
||||
|
||||
REG_OPERATOR_CODER(kAllTargets, kNumberTypeInt8, PrimitiveType_ReduceFusion, CPUOpCoderCreator<ReduceInt8Coder>)
|
||||
|
||||
} // namespace mindspore::lite::micro::nnacl
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "include/errorcode.h"
|
||||
|
||||
namespace mindspore::lite::micro::nnacl {
|
||||
|
||||
int ReluxInt8Coder::Prepare(CoderContext *const context) {
|
||||
MS_CHECK_PTR(parameter_);
|
||||
type_ = (reinterpret_cast<ActivationParameter *>(parameter_))->type_;
|
||||
|
@ -59,5 +58,4 @@ int ReluxInt8Coder::DoCode(CoderContext *const context) {
|
|||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
} // namespace mindspore::lite::micro::nnacl
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
using mindspore::schema::PrimitiveType_Reshape;
|
||||
|
||||
namespace mindspore::lite::micro::nnacl {
|
||||
|
||||
int ReshapeInt8Coder::DoCode(CoderContext *const context) {
|
||||
Tensor *input = OperatorCoder::input_tensors().at(kInputIndex);
|
||||
Tensor *output = OperatorCoder::output_tensors().at(kOutputIndex);
|
||||
|
|
|
@ -23,11 +23,12 @@
|
|||
#include "coder/opcoders/serializers/nnacl_serializer/nnacl_int8_serializer.h"
|
||||
|
||||
namespace mindspore::lite::micro::nnacl {
|
||||
constexpr auto int8_range = 256;
|
||||
|
||||
void CalculateTableList(int8_t *table, const float input_scale, const int32_t input_zp) {
|
||||
int32_t min_value = std::numeric_limits<int8_t>::min();
|
||||
int32_t max_value = std::numeric_limits<int8_t>::max();
|
||||
const float output_scale = 1.0f / 256;
|
||||
const float output_scale = 1.0f / int8_range;
|
||||
const int32_t output_zp = -128;
|
||||
|
||||
for (int i = min_value; i < max_value; ++i) {
|
||||
|
@ -41,7 +42,6 @@ void CalculateTableList(int8_t *table, const float input_scale, const int32_t in
|
|||
}
|
||||
|
||||
int SigmodInt8Coder::Prepare(CoderContext *const context) {
|
||||
size_t int8_range = 256;
|
||||
table_list_ = static_cast<int8_t *>(allocator_->Malloc(kNumberTypeInt8, int8_range, kOfflinePackWeight));
|
||||
MS_CHECK_PTR(table_list_);
|
||||
|
||||
|
@ -49,8 +49,8 @@ int SigmodInt8Coder::Prepare(CoderContext *const context) {
|
|||
const int32_t input_zp = input_tensor_->quant_params().at(0).zeroPoint;
|
||||
const float output_scale = output_tensor_->quant_params().at(0).scale;
|
||||
const int32_t output_zp = output_tensor_->quant_params().at(0).zeroPoint;
|
||||
if (output_scale != (1.0f / 256) || output_zp != -128) {
|
||||
MS_LOG(ERROR) << "Output scale is : " << output_scale << ", should be 1/256. Output zp is : " << output_zp
|
||||
if (output_scale != (1.0f / int8_range) || output_zp != -128) {
|
||||
MS_LOG(ERROR) << "Output scale is : " << output_scale << ", should be 1/int8_range. Output zp is : " << output_zp
|
||||
<< ", should be -128.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
@ -76,5 +76,4 @@ int SigmodInt8Coder::DoCode(CoderContext *const context) {
|
|||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
} // namespace mindspore::lite::micro::nnacl
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
#include "coder/opcoders/nnacl/int8/softmax_int8_coder.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <limits>
|
||||
#include "schema/inner/ops_generated.h"
|
||||
#include "nnacl/softmax_parameter.h"
|
||||
|
@ -52,7 +51,8 @@ int SoftMaxInt8Coder::Prepare(CoderContext *const context) {
|
|||
exp_data_ = static_cast<int *>(allocator_->Malloc(kNumberTypeInt32, exp_data_size_, kWorkspace));
|
||||
MS_CHECK_PTR(exp_data_);
|
||||
int inner_size = 1;
|
||||
MS_CHECK_TRUE(softmax_param_->n_dim_ < 5, "n_dim should be less than the length of maximum value of input_shape");
|
||||
MS_CHECK_TRUE(softmax_param_->n_dim_ <= static_cast<int>(std::extent<decltype(softmax_param_->input_shape_)>::value),
|
||||
"n_dim should be less than the length of maximum value of input_shape");
|
||||
for (int i = softmax_param_->axis_ + 1; i < softmax_param_->n_dim_; i++) {
|
||||
inner_size *= softmax_param_->input_shape_[i];
|
||||
}
|
||||
|
@ -68,7 +68,8 @@ int SoftMaxInt8Coder::DoCode(CoderContext *const context) {
|
|||
for (int i = 0; i < softmax_param_->axis_; i++) {
|
||||
outter_size *= softmax_param_->input_shape_[i];
|
||||
}
|
||||
MS_CHECK_TRUE(softmax_param_->n_dim_ < 5, "n_dim should be less than the length of maximum value of input_shape");
|
||||
MS_CHECK_TRUE(softmax_param_->n_dim_ <= static_cast<int>(std::extent<decltype(softmax_param_->input_shape_)>::value),
|
||||
"n_dim should be less than the length of maximum value of input_shape");
|
||||
Collect(context,
|
||||
{
|
||||
"nnacl/int8/softmax_int8.h",
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
using mindspore::schema::PrimitiveType_SubFusion;
|
||||
|
||||
namespace mindspore::lite::micro::nnacl {
|
||||
|
||||
int SubInt8Coder::Prepare(CoderContext *const context) {
|
||||
input0 = input_tensors_.at(0);
|
||||
input1 = input_tensors_.at(1);
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "coder/opcoders/parallel.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
OperatorCoder::~OperatorCoder() {
|
||||
node_ = nullptr;
|
||||
if (parameter_ != nullptr) {
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "coder/opcoders/parallel.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
std::unique_ptr<OperatorCoder> OpCoderBuilder::build() {
|
||||
MS_CHECK_PTR_RET_NULL(node_->primitive_);
|
||||
int primitive_type = GetPrimitiveType(node_->primitive_);
|
||||
|
@ -108,5 +107,4 @@ OpCoderBuilder &OpCoderBuilder::support_parallel(bool parallel) {
|
|||
}
|
||||
|
||||
void OpCoderBuilder::Reset() {}
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <string>
|
||||
#include "coder/utils/type_cast.h"
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
bool CoderKey::operator<(const CoderKey rhs) const {
|
||||
return std::tie(this->target_, this->data_type_, this->op_type_) <
|
||||
std::tie(rhs.target_, rhs.data_type_, rhs.op_type_);
|
||||
|
@ -67,5 +66,4 @@ OpCoderRegister::OpCoderRegister(Target target, TypeId data_type, schema::Primit
|
|||
const CoderCreatorFunc &creatorFunc) {
|
||||
OpCoderFactory::GetInstance()->RegistOpCoder(target, data_type, operator_type, creatorFunc);
|
||||
}
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "nnacl/pooling_parameter.h"
|
||||
|
||||
namespace mindspore::lite::micro::nnacl {
|
||||
|
||||
void NNaclFp32Serializer::CodeStruct(const std::string &name, const PoolingParameter &pooling_parameter) {
|
||||
CodeBaseStruct("PoolingParameter", name,
|
||||
// Primitive parameter
|
||||
|
|
|
@ -231,5 +231,4 @@ void NNaclInt8Serializer::CodeStruct(const std::string &name, const ReluXQuantAr
|
|||
relu_quant_arg.input_multiplier_, relu_quant_arg.left_shift_, relu_quant_arg.right_shift_,
|
||||
relu_quant_arg.quantized_output_min, relu_quant_arg.quantized_output_max);
|
||||
}
|
||||
|
||||
} // namespace mindspore::lite::micro::nnacl
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "coder/opcoders/serializers/nnacl_serializer/nnacl_stream_utils.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
std::ostream &operator<<(std::ostream &code, const ::QuantArg &quant_arg) {
|
||||
code << "{" << static_cast<float>(quant_arg.scale_) << ", " << quant_arg.zp_ << "}";
|
||||
return code;
|
||||
|
@ -86,5 +85,4 @@ std::ostream &operator<<(std::ostream &code, DataOrder data_order) {
|
|||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "coder/opcoders/nnacl/dequant/de_quant.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
CoderSession::CoderSession() { allocator_ = MemoryAllocator::GetInstance(); }
|
||||
|
||||
void CoderSession::EndCode() {
|
||||
|
@ -323,5 +322,4 @@ std::shared_ptr<CoderSession> CreateCoderSession() {
|
|||
}
|
||||
|
||||
CoderSession::~CoderSession() { allocator_->Free(); }
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "src/common/prim_util.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
std::set<OperatorCoder *> FindInferenceOpcoders(OperatorCoder *edge) {
|
||||
std::set<OperatorCoder *> subgraph;
|
||||
std::queue<OperatorCoder *> to_visit;
|
||||
|
@ -94,5 +93,4 @@ int Train::TransformGraphForTrain(CoderContext *context, const std::vector<std::
|
|||
context->set_train_blocks(train_blocks);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
} // namespace mindspore::lite::micro
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "src/common/log_adapter.h"
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
constexpr _mode_t kMicroDirMode = 0777;
|
||||
#else
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include <string>
|
||||
|
||||
namespace mindspore::lite::micro {
|
||||
|
||||
std::string EnumNameDataType(TypeId type) {
|
||||
switch (type) {
|
||||
case kNumberTypeInt:
|
||||
|
|
Loading…
Reference in New Issue