forked from mindspore-Ecosystem/mindspore
fix dts bug
This commit is contained in:
parent
53f64c1ff7
commit
70001a71ea
|
@ -75,6 +75,7 @@ Tensor::~Tensor() {
|
|||
} else {
|
||||
free(this->data_);
|
||||
}
|
||||
this->data_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace mindspore {
|
|||
namespace predict {
|
||||
constexpr int kDefaultBigCount = 2;
|
||||
constexpr int kDefaultMidCount = 2;
|
||||
constexpr uint32_t kDefaultSpinCount = 300000;
|
||||
constexpr int kSmallCpuNum = 4;
|
||||
constexpr int kBigMidCpuNum = 4;
|
||||
constexpr int kDefaultThreadNum = 1;
|
||||
|
@ -97,6 +98,11 @@ void LiteThreadBind::InitSortedCpuId() {
|
|||
#else
|
||||
numCores = static_cast<int>(std::thread::hardware_concurrency());
|
||||
#endif // MS_COMPILE_IOS
|
||||
if (numCores < 0) {
|
||||
MS_LOG(ERROR) << "get numCores return invalid value: " << numCores;
|
||||
sortedCpuIds.clear();
|
||||
return;
|
||||
}
|
||||
if (numCores < kBigMidCpuNum) {
|
||||
bigCore = 0;
|
||||
midCore = numCores;
|
||||
|
@ -259,6 +265,7 @@ void ThreadPool::AddNewThread(int newNums) {
|
|||
auto queue = std::make_shared<LiteQueue>();
|
||||
threadList.emplace_back([this, i, active, queue]() {
|
||||
ThreadPoolTask *task = nullptr;
|
||||
uint32_t spin_count = 0;
|
||||
while (!exitRun) {
|
||||
while (*active) {
|
||||
if (queue->Dequeue(&task)) {
|
||||
|
@ -267,6 +274,15 @@ void ThreadPool::AddNewThread(int newNums) {
|
|||
errorInfo.emplace_back(std::make_pair(i + 1, std::make_pair(false, ret)));
|
||||
}
|
||||
queue->taskSize--;
|
||||
spin_count = 0;
|
||||
} else {
|
||||
++spin_count;
|
||||
}
|
||||
if (spin_count == kDefaultSpinCount) {
|
||||
*(activateList[i]) = false;
|
||||
--curThreadRunNums;
|
||||
spin_count = 0;
|
||||
break;
|
||||
}
|
||||
std::this_thread::yield();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ add_library(caffe_parser_mid OBJECT
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/caffe_power_parser.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/caffe_prelu_parser.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/caffe_relu_parser.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/caffe_relu6_parser.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/caffe_reshape_parser.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/caffe_scale_parser.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/caffe_sigmoid_parser.cc
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* Copyright 2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include "mindspore/lite/tools/converter/parser/caffe/caffe_relu6_parser.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace lite {
|
||||
STATUS CaffeRelu6Parser::Parse(const caffe::LayerParameter &proto, const caffe::LayerParameter &weight,
|
||||
schema::CNodeT *op, std::vector<schema::TensorT *> *weightVec) {
|
||||
std::unique_ptr<schema::ActivationT> attr(new schema::ActivationT());
|
||||
attr->type = schema::ActivationType_RELU6;
|
||||
// relu: negative_slope = 0, no parameter;
|
||||
// leakyrelu: negative_slope != 0;
|
||||
if (proto.has_relu_param() && proto.relu_param().has_negative_slope()) {
|
||||
float negative_slope = proto.relu_param().negative_slope();
|
||||
if (0 != negative_slope) {
|
||||
attr->type = schema::ActivationType_LEAKY_RELU;
|
||||
attr->alpha = negative_slope;
|
||||
}
|
||||
}
|
||||
op->primitive = std::make_unique<schema::PrimitiveT>();
|
||||
op->primitive->value.value = attr.release();
|
||||
op->primitive->value.type = schema::PrimitiveType_Activation;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
CaffeNodeRegistrar g_caffeRelu6Parser("ReLU6", new CaffeRelu6Parser());
|
||||
} // namespace lite
|
||||
} // namespace mindspore
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* Copyright 2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MINDSPORE_CCSRC_TOOLS_LITE_CONVERTER_PARSER_CAFFE_CAFFE_RELU6_PARSER_H_
|
||||
#define MINDSPORE_CCSRC_TOOLS_LITE_CONVERTER_PARSER_CAFFE_CAFFE_RELU6_PARSER_H_
|
||||
|
||||
#include <vector>
|
||||
#include "mindspore/lite/tools/converter/parser/caffe/caffe_node_parser.h"
|
||||
#include "mindspore/lite/tools/converter/parser/caffe/caffe_node_parser_registry.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace lite {
|
||||
class CaffeRelu6Parser : public CaffeNodeParser {
|
||||
public:
|
||||
CaffeRelu6Parser() : CaffeNodeParser("relu6") {}
|
||||
|
||||
STATUS Parse(const caffe::LayerParameter &proto, const caffe::LayerParameter &weight, schema::CNodeT *op,
|
||||
std::vector<schema::TensorT *> *weightVec) override;
|
||||
};
|
||||
} // namespace lite
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CCSRC_TOOLS_LITE_CONVERTER_PARSER_CAFFE_CAFFE_RELU_PARSER_H_
|
|
@ -53,6 +53,9 @@ STATUS OnnxPoolParser::Parse(const onnx::GraphProto &onnx_graph,
|
|||
} else if (pool_type == "GlobalAveragePool") {
|
||||
attr->poolingMode = schema::PoolMode_MEAN_POOLING;
|
||||
attr->global = true;
|
||||
} else if (pool_type == "Int8AveragePool") {
|
||||
attr->poolingMode = schema::PoolMode_MEAN_POOLING;
|
||||
attr->global = false;
|
||||
} else {
|
||||
MS_LOG(ERROR) << "Pooling param`s PoolingMode is not MAX either AVE. MindSpore support MAX and AVE only.";
|
||||
return RET_ERROR;
|
||||
|
@ -105,5 +108,6 @@ OnnxNodeRegistrar g_onnxMaxPoolParser("MaxPool", new OnnxPoolParser());
|
|||
OnnxNodeRegistrar g_onnxAveragePoolParser("AveragePool", new OnnxPoolParser());
|
||||
OnnxNodeRegistrar g_onnxGlobalAveragePoolParser("GlobalAveragePool", new OnnxPoolParser());
|
||||
OnnxNodeRegistrar g_onnxGlobalMaxPoolParser("GlobalMaxPool", new OnnxPoolParser());
|
||||
OnnxNodeRegistrar g_onnxInt8AveragePoolParser("Int8AveragePool", new OnnxPoolParser());
|
||||
} // namespace lite
|
||||
} // namespace mindspore
|
||||
|
|
Loading…
Reference in New Issue