forked from mindspore-Ecosystem/mindspore
modify static check
This commit is contained in:
parent
2d6c07a367
commit
9ef4c1b9cc
|
@ -54,7 +54,14 @@ STATUS TensorQuantPass::Run(schema::MetaGraphT *graph) {
|
||||||
tensor->quantParams.emplace_back(weightQauntParam.release());
|
tensor->quantParams.emplace_back(weightQauntParam.release());
|
||||||
}
|
}
|
||||||
tensor->dataType = TypeId::kNumberTypeInt8;
|
tensor->dataType = TypeId::kNumberTypeInt8;
|
||||||
::memcpy(tensor->data.data(), qDatas.data(), wShapeSize);
|
tensor->data.clear();
|
||||||
|
tensor->data.resize(wShapeSize * sizeof(int8_t));
|
||||||
|
auto ret =
|
||||||
|
memcpy_s(tensor->data.data(), wShapeSize * sizeof(int8_t), qDatas.data(), wShapeSize * sizeof(int8_t));
|
||||||
|
if (ret != EOK) {
|
||||||
|
MS_LOG(ERROR) << "memcpy_s failed: " << ret;
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
} else if (quantParam->dstDtype == TypeId::kNumberTypeInt32) {
|
} else if (quantParam->dstDtype == TypeId::kNumberTypeInt32) {
|
||||||
// quant bias data
|
// quant bias data
|
||||||
auto bShapeSize = GetShapeSize(*(tensor.get()));
|
auto bShapeSize = GetShapeSize(*(tensor.get()));
|
||||||
|
|
|
@ -98,8 +98,14 @@ STATUS AwareQuantizer::DoQuantize() {
|
||||||
tensor->quantParams.clear();
|
tensor->quantParams.clear();
|
||||||
tensor->quantParams.emplace_back(weightQauntParam.release());
|
tensor->quantParams.emplace_back(weightQauntParam.release());
|
||||||
}
|
}
|
||||||
|
tensor->data.clear();
|
||||||
::memcpy(tensor->data.data(), qDatas.data(), wShapeSize);
|
tensor->data.resize(wShapeSize * sizeof(int8_t));
|
||||||
|
auto ret =
|
||||||
|
memcpy_s(tensor->data.data(), wShapeSize * sizeof(int8_t), qDatas.data(), wShapeSize * sizeof(int8_t));
|
||||||
|
if (ret != EOK) {
|
||||||
|
MS_LOG(ERROR) << "memcpy_s failed: " << ret;
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
} else if (quantParam->dstDtype == TypeId::kNumberTypeInt32) {
|
} else if (quantParam->dstDtype == TypeId::kNumberTypeInt32) {
|
||||||
// quant bias data
|
// quant bias data
|
||||||
auto bShapeSize = GetShapeSize(*(tensor.get()));
|
auto bShapeSize = GetShapeSize(*(tensor.get()));
|
||||||
|
|
|
@ -216,6 +216,7 @@ int LinearCalcer::Calc(MetaGraphT *graph, const CNodeT &node) {
|
||||||
class CalcConcat : public QuantParamCalcer {
|
class CalcConcat : public QuantParamCalcer {
|
||||||
public:
|
public:
|
||||||
CalcConcat() = default;
|
CalcConcat() = default;
|
||||||
|
~CalcConcat() override = default;
|
||||||
|
|
||||||
int Calc(MetaGraphT *graph, const CNodeT &node) override {
|
int Calc(MetaGraphT *graph, const CNodeT &node) override {
|
||||||
MS_ASSERT(node.outputIndex.size() == 1);
|
MS_ASSERT(node.outputIndex.size() == 1);
|
||||||
|
@ -280,6 +281,7 @@ class CalcConcat : public QuantParamCalcer {
|
||||||
class CalcAdd : public QuantParamCalcer {
|
class CalcAdd : public QuantParamCalcer {
|
||||||
public:
|
public:
|
||||||
CalcAdd() = default;
|
CalcAdd() = default;
|
||||||
|
~CalcAdd() override = default;
|
||||||
|
|
||||||
int Calc(MetaGraphT *graph, const CNodeT &node) override {
|
int Calc(MetaGraphT *graph, const CNodeT &node) override {
|
||||||
MS_ASSERT(node.inputIndex.size() == 2);
|
MS_ASSERT(node.inputIndex.size() == 2);
|
||||||
|
@ -357,6 +359,7 @@ class CalcAdd : public QuantParamCalcer {
|
||||||
class CalcRealDiv : public QuantParamCalcer {
|
class CalcRealDiv : public QuantParamCalcer {
|
||||||
public:
|
public:
|
||||||
CalcRealDiv() = default;
|
CalcRealDiv() = default;
|
||||||
|
~CalcRealDiv() override = default;
|
||||||
|
|
||||||
int Calc(MetaGraphT *graph, const CNodeT &node) override {
|
int Calc(MetaGraphT *graph, const CNodeT &node) override {
|
||||||
MS_ASSERT(node.inputIndex.size() == 2);
|
MS_ASSERT(node.inputIndex.size() == 2);
|
||||||
|
@ -424,6 +427,7 @@ class CalcRealDiv : public QuantParamCalcer {
|
||||||
class CalcToSet : public QuantParamCalcer {
|
class CalcToSet : public QuantParamCalcer {
|
||||||
public:
|
public:
|
||||||
CalcToSet(float min, float max) : min(min), max(max) {}
|
CalcToSet(float min, float max) : min(min), max(max) {}
|
||||||
|
~CalcToSet() override = default;
|
||||||
|
|
||||||
int Calc(MetaGraphT *graph, const CNodeT &node) override {
|
int Calc(MetaGraphT *graph, const CNodeT &node) override {
|
||||||
MS_ASSERT(node.inputIndex.size() == 1);
|
MS_ASSERT(node.inputIndex.size() == 1);
|
||||||
|
@ -468,6 +472,7 @@ class CalcToSet : public QuantParamCalcer {
|
||||||
class CalcActivation : public QuantParamCalcer {
|
class CalcActivation : public QuantParamCalcer {
|
||||||
public:
|
public:
|
||||||
CalcActivation() = default;
|
CalcActivation() = default;
|
||||||
|
~CalcActivation() override = default;
|
||||||
|
|
||||||
int Calc(MetaGraphT *subGraph, const CNodeT &node) override {
|
int Calc(MetaGraphT *subGraph, const CNodeT &node) override {
|
||||||
MS_ASSERT(node.inputIndex.size() == 1);
|
MS_ASSERT(node.inputIndex.size() == 1);
|
||||||
|
|
|
@ -1323,7 +1323,11 @@ STATUS PostTrainingQuantizer::BiasCorrection(FuncGraphPtr func_graph) {
|
||||||
MS_LOG(ERROR) << "new char[] failed";
|
MS_LOG(ERROR) << "new char[] failed";
|
||||||
return RET_MEMORY_FAILED;
|
return RET_MEMORY_FAILED;
|
||||||
}
|
}
|
||||||
std::memcpy(tensor_data, bias_diff.data(), size);
|
ret = ::memcpy_s(tensor_data, size * sizeof(char), bias_diff.data(), size * sizeof(char));
|
||||||
|
if (ret != EOK) {
|
||||||
|
MS_LOG(ERROR) << "memcpy_s error: " << ret;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
param_value->set_tensor_addr(tensor_data);
|
param_value->set_tensor_addr(tensor_data);
|
||||||
param_value->set_tensor_size(size);
|
param_value->set_tensor_size(size);
|
||||||
parameter->set_default_param(param_value);
|
parameter->set_default_param(param_value);
|
||||||
|
|
Loading…
Reference in New Issue