codex clean
This commit is contained in:
parent
69eeedbfdd
commit
b5f0ed6201
|
@ -67,3 +67,6 @@
|
|||
"mindspore/mindspore/lite/examples/quick_start_c/main.c" "readability/casting"
|
||||
"mindspore/mindspore/lite/examples/quick_start_c/main.c" "runtime/threadsafe_fn"
|
||||
"mindspore/mindspore/lite/examples/quick_start_micro" "readability/casting"
|
||||
"mindspore/mindspore/core/mindrt/include/async/try.h" "runtime/explicit"
|
||||
"mindspore/mindspore/core/mindrt/include/async/failure.h" "runtime/explicit"
|
||||
"mindspore/mindspore/core/mindrt/include/async/defer.h" "runtime/explicit"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -18,6 +18,8 @@
|
|||
#define MINDSPORE_CORE_MINDRT_INCLUDE_ASYNC_DEFER_H
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "async/async.h"
|
||||
#include "async/option.h"
|
||||
|
|
|
@ -208,14 +208,14 @@ int QuantDTypeCastCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Scale error error_code[" << ret << "]";
|
||||
if (in_tensors_[0]->data_type() == TypeId::kNumberTypeInt8 &&
|
||||
out_tensors_[0]->data_type() == TypeId::kNumberTypeInt8) {
|
||||
delete (float32_ptr_);
|
||||
delete[](float32_ptr_);
|
||||
float32_ptr_ = nullptr;
|
||||
}
|
||||
return RET_ERROR;
|
||||
}
|
||||
if (in_tensors_[0]->data_type() == TypeId::kNumberTypeInt8 &&
|
||||
out_tensors_[0]->data_type() == TypeId::kNumberTypeInt8) {
|
||||
delete (float32_ptr_);
|
||||
delete[](float32_ptr_);
|
||||
float32_ptr_ = nullptr;
|
||||
}
|
||||
return RET_OK;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,6 +24,15 @@
|
|||
#define DOWN_DIV(x, y) ((x) / (y))
|
||||
#define DOWN_ROUND(x, y) ((x) / (y) * (y))
|
||||
|
||||
#define kNHWC_N 0
|
||||
#define kNHWC_H 1
|
||||
#define kNHWC_W 2
|
||||
#define kNHWC_C 3
|
||||
#define kNCHW_N 0
|
||||
#define kNCHW_C 1
|
||||
#define kNCHW_H 2
|
||||
#define kNCHW_W 3
|
||||
|
||||
#define SIZE_MUL_OVERFLOW(x, y) (((x) == 0) ? false : (SIZE_MAX / (x)) < (y))
|
||||
#define INT_MUL_OVERFLOW(x, y) \
|
||||
(((x) == 0) ? false \
|
||||
|
|
|
@ -24,6 +24,11 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace dpico {
|
||||
namespace {
|
||||
#ifdef _WIN32
|
||||
constexpr size_t kMaxPathLen = 1024;
|
||||
#endif
|
||||
} // namespace
|
||||
int CreateDir(std::string *file_path) { // support multi-level directory generated.
|
||||
if (file_path == nullptr) {
|
||||
MS_LOG(ERROR) << "file_path is nullptr.";
|
||||
|
@ -74,7 +79,7 @@ std::string RealPath(const char *path) {
|
|||
return "";
|
||||
}
|
||||
#ifdef _WIN32
|
||||
char *real_path = _fullpath(resolved_path.get(), path, 1024);
|
||||
char *real_path = _fullpath(resolved_path.get(), path, kMaxPathLen);
|
||||
#else
|
||||
char *real_path = realpath(path, resolved_path.get());
|
||||
#endif
|
||||
|
|
|
@ -105,9 +105,11 @@ STATUS SetResizeDataInfo(const CNodePtr &cnode, const PrimitivePtr &prim, mapper
|
|||
auto data = reinterpret_cast<int32_t *>(tensor_info->data_c());
|
||||
MS_CHECK_TRUE_MSG(data != nullptr, RET_ERROR, "data is nullptr.");
|
||||
if (input_format == Format::NCHW) {
|
||||
size_vec = {static_cast<int32_t>(input_shape.at(0)), static_cast<int32_t>(input_shape.at(1)), *data, *(data + 1)};
|
||||
size_vec = {static_cast<int32_t>(input_shape.at(0)), static_cast<int32_t>(input_shape.at(kNCHW_C)), *data,
|
||||
*(data + 1)};
|
||||
} else {
|
||||
size_vec = {static_cast<int32_t>(input_shape.at(0)), *data, *(data + 1), static_cast<int32_t>(input_shape.at(3))};
|
||||
size_vec = {static_cast<int32_t>(input_shape.at(0)), *data, *(data + 1),
|
||||
static_cast<int32_t>(input_shape.at(kNHWC_C))};
|
||||
}
|
||||
resize_operator->SetSizeVec(size_vec);
|
||||
} else if (tensor_info->data_type() == kNumberTypeFloat32 || tensor_info->data_type() == kNumberTypeFloat) {
|
||||
|
|
|
@ -215,13 +215,13 @@ STATUS CaffeModelParser::InitOriginModel(const std::string &model_file, const st
|
|||
return RET_INPUT_PARAM_INVALID;
|
||||
}
|
||||
|
||||
status = ReadProtoFromText((const char *)model_file.c_str(), &caffe_model_);
|
||||
status = ReadProtoFromText(model_file, &caffe_model_);
|
||||
if (status != RET_OK) {
|
||||
MS_LOG(ERROR) << "Read prototxt file failed, model path: " << model_file;
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
status = ReadProtoFromBinaryFile((const char *)weight_file.c_str(), &caffe_weight_);
|
||||
status = ReadProtoFromBinaryFile(weight_file, &caffe_weight_);
|
||||
if (status != RET_OK) {
|
||||
MS_LOG(ERROR) << "Read caffemodel file failed, model path: " << weight_file;
|
||||
return RET_ERROR;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -322,12 +322,13 @@ bool ReadProtoFromCodedInputStream(google::protobuf::io::CodedInputStream *coded
|
|||
return proto->ParseFromCodedStream(coded_stream);
|
||||
}
|
||||
|
||||
STATUS ReadProtoFromText(const char *file, google::protobuf::Message *message) {
|
||||
if (file == nullptr || message == nullptr) {
|
||||
STATUS ReadProtoFromText(const std::string &file, google::protobuf::Message *message) {
|
||||
if (message == nullptr) {
|
||||
MS_LOG(ERROR) << "message is nullptr.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
std::string realPath = dpico::RealPath(file);
|
||||
std::string realPath = dpico::RealPath(file.c_str());
|
||||
if (realPath.empty()) {
|
||||
MS_LOG(ERROR) << "Proto file path " << file << " is not valid";
|
||||
return RET_ERROR;
|
||||
|
@ -352,12 +353,13 @@ STATUS ReadProtoFromText(const char *file, google::protobuf::Message *message) {
|
|||
return RET_OK;
|
||||
}
|
||||
|
||||
STATUS ReadProtoFromBinaryFile(const char *file, google::protobuf::Message *message) {
|
||||
if (file == nullptr || message == nullptr) {
|
||||
STATUS ReadProtoFromBinaryFile(const std::string &file, google::protobuf::Message *message) {
|
||||
if (message == nullptr) {
|
||||
MS_LOG(ERROR) << "message is nullptr.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
std::string realPath = dpico::RealPath(file);
|
||||
std::string realPath = dpico::RealPath(file.c_str());
|
||||
if (realPath.empty()) {
|
||||
MS_LOG(ERROR) << "Binary proto file path " << file << " is not valid";
|
||||
return RET_ERROR;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,8 +36,8 @@ int UnifyConvWeightFormat(const api::FuncGraphPtr &graph, const CNodePtr &cnode,
|
|||
mindspore::Format dst_format, std::set<AnfNodePtr> *has_visited);
|
||||
bool ReadProtoFromCodedInputStream(google::protobuf::io::CodedInputStream *coded_stream,
|
||||
google::protobuf::Message *proto);
|
||||
int ReadProtoFromText(const char *file, google::protobuf::Message *message);
|
||||
int ReadProtoFromBinaryFile(const char *file, google::protobuf::Message *message);
|
||||
int ReadProtoFromText(const std::string &file, google::protobuf::Message *message);
|
||||
int ReadProtoFromBinaryFile(const std::string &file, google::protobuf::Message *message);
|
||||
STATUS ValidateFileStr(const std::string &modelFile, const std::string &fileType);
|
||||
} // namespace lite
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -72,7 +72,8 @@ std::string CalibDataGenerator::GetInputShapesStr(const AnfNodePtrList &graph_in
|
|||
return "";
|
||||
}
|
||||
if (shape_vector.size() == kDims4) { // transform nchw to nhwc
|
||||
shape_vector = std::vector<int64_t>{shape_vector[0], shape_vector[2], shape_vector[3], shape_vector[1]};
|
||||
shape_vector = std::vector<int64_t>{shape_vector[kNCHW_N], shape_vector[kNCHW_H], shape_vector[kNCHW_W],
|
||||
shape_vector[kNCHW_C]};
|
||||
}
|
||||
for (size_t i = 0; i < shape_vector.size(); i++) {
|
||||
auto dim = shape_vector.at(i);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,6 +33,7 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace dpico {
|
||||
enum DumpMode : int { kDumpInputOutput = 0, kDumpInput = 1, kDumpOutput = 2 };
|
||||
struct OpAttr {
|
||||
std::string data_type;
|
||||
size_t input_output_idx;
|
||||
|
|
|
@ -34,6 +34,7 @@ using mindspore::lite::RET_OK;
|
|||
namespace mindspore {
|
||||
namespace dpico {
|
||||
namespace {
|
||||
const int kMaxRoiFrameCnt = 300;
|
||||
const std::map<mapper::OpDataType, TypeId> kDataTypeMap = {
|
||||
{mapper::OpDataType::OP_DTYPE_S8, kNumberTypeInt8}, {mapper::OpDataType::OP_DTYPE_U8, kNumberTypeUInt8},
|
||||
{mapper::OpDataType::OP_DTYPE_S16, kNumberTypeInt16}, {mapper::OpDataType::OP_DTYPE_U16, kNumberTypeUInt16},
|
||||
|
@ -243,7 +244,7 @@ STATUS CustomOpCreator::SetCustomAttrs(const Subgraph &subgraph, const api::Func
|
|||
|
||||
// add max_roi_fram_cnt attr
|
||||
if (subgraph.om_net_type == OmNetType::kRoi) {
|
||||
auto max_roi_frame_cnt_str = std::to_string(300);
|
||||
auto max_roi_frame_cnt_str = std::to_string(kMaxRoiFrameCnt);
|
||||
std::vector<uint8_t> max_roi_frame_cnt_value(max_roi_frame_cnt_str.begin(), max_roi_frame_cnt_str.end());
|
||||
custom_attrs.insert(std::make_pair("max_roi_frame_cnt", max_roi_frame_cnt_value));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -338,7 +338,7 @@ STATUS DpicoPass::DataPrepare(const api::FuncGraphPtr &func_graph, bool *use_ori
|
|||
MS_LOG(DEBUG) << "required tensors are all graph inputs, which do not need to dump data.";
|
||||
return RET_OK;
|
||||
}
|
||||
int dump_level = param_to_cnode.empty() ? 2 : 0;
|
||||
int dump_level = param_to_cnode.empty() ? kDumpOutput : kDumpInputOutput;
|
||||
auto calib_data_generator = std::make_shared<CalibDataGenerator>(dump_level, param_to_cnode);
|
||||
MS_CHECK_TRUE_MSG(calib_data_generator != nullptr, RET_ERROR, "new calib generator failed.");
|
||||
if (calib_data_generator->Run(graph_inputs, dump_kernels) != RET_OK &&
|
||||
|
|
Loading…
Reference in New Issue