forked from mindspore-Ecosystem/mindspore
!4276 fix for code naming specification in mindspore/lite
Merge pull request !4276 from hangq/master
This commit is contained in:
commit
5b4329a771
|
@ -22,41 +22,41 @@
|
|||
#include "include/ms_tensor.h"
|
||||
|
||||
namespace mindspore::lite {
|
||||
/// \brief Allocator defined by MindSpore Lite.
|
||||
/// \brief Allocator defined a memory pool for malloc memory and free memory dynamically.
|
||||
///
|
||||
/// \note List public class and interface for reference.
|
||||
class Allocator;
|
||||
|
||||
/// \brief CpuBindMode defined by MindSpore Lite.
|
||||
/// \brief CpuBindMode defined for holding bind cpu strategy argument.
|
||||
enum CpuBindMode {
|
||||
MID_CPU = -1, /**< bind mid cpu first */
|
||||
MID_CPU = -1, /**< bind middle cpu first */
|
||||
HIGHER_CPU = 1, /**< bind higher cpu first */
|
||||
NO_BIND = 0 /**< no bind */
|
||||
};
|
||||
|
||||
/// \brief DeviceType defined by MindSpore Lite.
|
||||
/// \brief DeviceType defined for holding user's preferred backend.
|
||||
typedef enum {
|
||||
DT_CPU, /**< CPU device type */
|
||||
DT_GPU, /**< GPU device type */
|
||||
DT_NPU /**< NPU device type */
|
||||
} DeviceType;
|
||||
|
||||
/// \brief DeviceContext defined by MindSpore Lite.
|
||||
/// \brief DeviceContext defined for holding DeviceType.
|
||||
typedef struct {
|
||||
DeviceType type; /**< device type */
|
||||
} DeviceContext;
|
||||
|
||||
/// \brief Context defined by MindSpore Lite
|
||||
/// \brief Context defined for holding some environment for runtime.
|
||||
class MS_API Context {
|
||||
public:
|
||||
/// \brief Constructor of MindSpore Lite context using default value for parameters.
|
||||
/// \brief Constructor of MindSpore Lite Context using default value for parameters.
|
||||
///
|
||||
/// \return Instance of MindSpore Lite Context.
|
||||
Context();
|
||||
|
||||
/// \brief Constructor of MindSpore Lite Context using input value for parameters.
|
||||
///
|
||||
/// \param[in] thread_num Define the threadNum during the runtime.
|
||||
/// \param[in] thread_num Define the work thread number during the runtime.
|
||||
/// \param[in] allocator Define the allocator for malloc.
|
||||
/// \param[in] device_ctx Define device information during the runtime.
|
||||
Context(int thread_num, std::shared_ptr<Allocator> allocator, DeviceContext device_ctx);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace lite {
|
||||
/// \brief STATUS defined error code in MindSpore Lite.
|
||||
using STATUS = int;
|
||||
|
||||
/* Success */
|
||||
|
@ -33,8 +34,8 @@ constexpr int RET_SUCCESS_EXIT = -5; /**< No error but exit. */
|
|||
constexpr int RET_MEMORY_FAILED = -6; /**< Create memory failed. */
|
||||
|
||||
/* Executor error code, range: [-101,-200] */
|
||||
constexpr int RET_OUT_OF_TENSOR_RANGE = -101; /**< Failed to checking range. */
|
||||
constexpr int RET_INPUT_TENSOR_ERROR = -102; /**< Failed to checking input tensor. */
|
||||
constexpr int RET_OUT_OF_TENSOR_RANGE = -101; /**< Failed to check range. */
|
||||
constexpr int RET_INPUT_TENSOR_ERROR = -102; /**< Failed to check input tensor. */
|
||||
constexpr int RET_REENTRANT_ERROR = -103; /**< Exist executor running. */
|
||||
|
||||
/* Graph error code, range: [-201,-300] */
|
||||
|
|
|
@ -27,15 +27,17 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace session {
|
||||
/// \brief CallBackParam defined input arguments for callBack function.
|
||||
struct CallBackParam {
|
||||
std::string name_callback_param;
|
||||
std::string type_callback_param;
|
||||
std::string name_callback_param; /**< node name argument */
|
||||
std::string type_callback_param; /**< node type argument */
|
||||
};
|
||||
|
||||
/// \brief KernelCallBack defined the function pointer for callBack.
|
||||
using KernelCallBack = std::function<bool(std::vector<tensor::MSTensor *> inputs,
|
||||
std::vector<tensor::MSTensor *> outputs, const CallBackParam &opInfo)>;
|
||||
|
||||
/// \brief LiteSession defined by MindSpore Lite.
|
||||
/// \brief LiteSession defined session in MindSpore Lite for compiling Model and forwarding model.
|
||||
class MS_API LiteSession {
|
||||
public:
|
||||
/// \brief Static method to create a LiteSession pointer.
|
||||
|
@ -48,52 +50,52 @@ class MS_API LiteSession {
|
|||
/// \brief Destructor of MindSpore Lite LiteSession.
|
||||
virtual ~LiteSession() = default;
|
||||
|
||||
/// \brief Try to bind or unbind threads in the thread pool to specified cpu core.
|
||||
/// \brief Try to bind or unbind threads in the thread pool to the specified cpu core.
|
||||
///
|
||||
/// \param[in] if_bind Define weather to bind or unbind threads.
|
||||
/// \param[in] if_bind Define whether to bind or unbind threads.
|
||||
virtual void BindThread(bool if_bind) = 0;
|
||||
|
||||
/// \brief Compile MindSpore lite model.
|
||||
/// \brief Compile MindSpore Lite model.
|
||||
///
|
||||
/// \note CompileGraph should called before RunGraph.
|
||||
///
|
||||
/// \param[in] model Define the model to be compiled.
|
||||
///
|
||||
/// \return ErrorCode of compile graph.
|
||||
/// \return STATUS as an error code of compiling graph, STATUS is defined in errorcode.h.
|
||||
virtual int CompileGraph(lite::Model *model) = 0;
|
||||
|
||||
/// \brief Get input MindSpore Lite MSTensors of model.
|
||||
///
|
||||
/// \return A vector of MindSpore Lite MSTensor.
|
||||
/// \return The vector of MindSpore Lite MSTensor.
|
||||
virtual std::vector<tensor::MSTensor *> GetInputs() const = 0;
|
||||
|
||||
/// \brief Get input MindSpore Lite MSTensors of model by node name.
|
||||
///
|
||||
/// \param[in] node_name Define node name.
|
||||
///
|
||||
/// \return A vector of MindSpore Lite MSTensor.
|
||||
/// \return The vector of MindSpore Lite MSTensor.
|
||||
virtual std::vector<tensor::MSTensor *> GetInputsByName(const std::string &node_name) const = 0;
|
||||
|
||||
/// \brief Run session with callback.
|
||||
///
|
||||
/// \param[in] before Define a call_back_function called before running each node
|
||||
/// \param[in] after Define a call_back_function called after running each node
|
||||
/// \param[in] before Define a call_back_function called before running each node.
|
||||
/// \param[in] after Define a call_back_function called after running each node.
|
||||
///
|
||||
/// \note RunGraph should called after CompileGraph.
|
||||
///
|
||||
/// \return ErrorCode of run graph.
|
||||
/// \return STATUS as an error code of running graph, STATUS is defined in errorcode.h.
|
||||
virtual int RunGraph(const KernelCallBack &before = nullptr, const KernelCallBack &after = nullptr) = 0;
|
||||
|
||||
/// \brief Get output MindSpore Lite MSTensors of model.
|
||||
///
|
||||
/// \return A map of output node name and MindSpore Lite MSTensor.
|
||||
/// \return The map of output node name and MindSpore Lite MSTensor.
|
||||
virtual std::unordered_map<std::string, std::vector<mindspore::tensor::MSTensor *>> GetOutputs() const = 0;
|
||||
|
||||
/// \brief Get output MindSpore Lite MSTensors of model by node name.
|
||||
///
|
||||
/// \param[in] node_name Define node name.
|
||||
///
|
||||
/// \return A vector of MindSpore Lite MSTensor.
|
||||
/// \return The vector of MindSpore Lite MSTensor.
|
||||
virtual std::vector<tensor::MSTensor *> GetOutputsByName(const std::string &node_name) const = 0;
|
||||
};
|
||||
} // namespace session
|
||||
|
|
|
@ -25,24 +25,24 @@
|
|||
namespace mindspore {
|
||||
#define MS_API __attribute__((visibility("default")))
|
||||
|
||||
/// \brief ModelImpl defined by MindSpore Lite.
|
||||
/// \brief ModelImpl defined the implement class of Model in MindSpore Lite.
|
||||
///
|
||||
/// \note List public class and interface for reference.
|
||||
class ModelImpl;
|
||||
|
||||
namespace lite {
|
||||
/// \brief Primitive defined by MindSpore Lite.
|
||||
/// \brief Primitive defined as prototype of operator.
|
||||
///
|
||||
/// \note List public class and interface for reference.
|
||||
class Primitive;
|
||||
|
||||
/// \brief Model defined by MindSpore Lite.
|
||||
/// \brief Model defined model in MindSpore Lite for managing graph.
|
||||
class MS_API Model {
|
||||
public:
|
||||
/// \brief Static method to create a Model pointer.
|
||||
///
|
||||
/// \param[in] model_buf Define the buffer read from a model file.
|
||||
/// \param[in] size Define bytes numbers of model buffer.
|
||||
/// \param[in] size Define bytes number of model buffer.
|
||||
///
|
||||
/// \return Pointer of MindSpore Lite Model.
|
||||
static Model *Import(const char *model_buf, size_t size);
|
||||
|
@ -59,17 +59,17 @@ class MS_API Model {
|
|||
///
|
||||
/// \param[in] name Define name of primitive to be returned.
|
||||
///
|
||||
/// \return A pointer of MindSpore Lite Primitive.
|
||||
/// \return the pointer of MindSpore Lite Primitive.
|
||||
lite::Primitive *GetOp(const std::string &name) const;
|
||||
|
||||
/// \brief Get MindSpore Lite MetaGraph.
|
||||
/// \brief Get graph defined in flatbuffers.
|
||||
///
|
||||
/// \return A pointer of MindSpore Lite MetaGraph.
|
||||
/// \return the pointer of graph defined in flatbuffers.
|
||||
const schema::MetaGraph *GetMetaGraph() const;
|
||||
|
||||
/// \brief Get MindSpore Lite ModelImpl.
|
||||
///
|
||||
/// \return A pointer of MindSpore Lite ModelImpl.
|
||||
/// \return the pointer of MindSpore Lite ModelImpl.
|
||||
ModelImpl *model_impl();
|
||||
|
||||
/// \brief Free MetaGraph in MindSpore Lite Model.
|
||||
|
@ -84,7 +84,7 @@ class MS_API ModelBuilder {
|
|||
public:
|
||||
/// \brief OutEdge defined by MindSpore Lite.
|
||||
struct OutEdge {
|
||||
std::string nodeId; /**< Id of a node linked by this edge */
|
||||
std::string nodeId; /**< ID of a node linked by this edge */
|
||||
size_t outEdgeIndex; /**< Index of this edge */
|
||||
};
|
||||
|
||||
|
@ -101,12 +101,12 @@ class MS_API ModelBuilder {
|
|||
/// \param[in] op Define the primitive to be added.
|
||||
/// \param[in] inputs Define input edge of primitive to be added.
|
||||
///
|
||||
/// \return Id of the primitive added.
|
||||
/// \return ID of the primitive added.
|
||||
virtual std::string AddOp(const lite::Primitive &op, const std::vector<OutEdge> &inputs) = 0;
|
||||
|
||||
/// \brief Finish constructing the model.
|
||||
///
|
||||
/// \return A pointer of MindSpore Lite Model.
|
||||
/// \return the pointer of MindSpore Lite Model.
|
||||
virtual Model *Construct();
|
||||
};
|
||||
} // namespace lite
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
namespace mindspore {
|
||||
#define MS_API __attribute__((visibility("default")))
|
||||
namespace tensor {
|
||||
/// \brief MSTensor defined by MindSpore Lite.
|
||||
/// \brief MSTensor defined tensor in MindSpore Lite.
|
||||
class MS_API MSTensor {
|
||||
public:
|
||||
/// \brief Constructor of MindSpore Lite MSTensor.
|
||||
|
@ -41,7 +41,7 @@ class MS_API MSTensor {
|
|||
/// \note TypeId is defined in mindspore/mindspore/core/ir/dtype/type_id.h. Only number types in TypeId enum is
|
||||
/// suitable for MSTensor.
|
||||
///
|
||||
/// \return A pointer of MSTensor.
|
||||
/// \return the pointer of MSTensor.
|
||||
static MSTensor *CreateTensor(TypeId data_type, const std::vector<int> &shape);
|
||||
|
||||
/// \brief Destructor of MindSpore Lite Model.
|
||||
|
@ -69,7 +69,7 @@ class MS_API MSTensor {
|
|||
|
||||
/// \brief Set shape for the MindSpore Lite MSTensor.
|
||||
///
|
||||
/// \param[in] shape Define A vector of int as shape to be set into the MindSpore Lite MSTensor.
|
||||
/// \param[in] shape Define a vector of int as shape to be set into the MindSpore Lite MSTensor.
|
||||
///
|
||||
/// \return size of shape of the MindSpore Lite MSTensor after set.
|
||||
virtual size_t set_shape(const std::vector<int> &shape) = 0;
|
||||
|
@ -96,15 +96,13 @@ class MS_API MSTensor {
|
|||
/// \return Byte size of data in MSTensor.
|
||||
virtual size_t Size() const = 0;
|
||||
|
||||
/// \brief Get pointer of data in MSTensor.
|
||||
/// \brief Get the pointer of data in MSTensor.
|
||||
///
|
||||
/// \note The data pointer can be used to both write or read data in MSTensor.
|
||||
///
|
||||
/// \return A pointer points to data in MSTensor.
|
||||
/// \return the pointer points to data in MSTensor.
|
||||
virtual void *MutableData() const = 0;
|
||||
};
|
||||
|
||||
using MultiTensor = std::vector<std::vector<std::shared_ptr<tensor::MSTensor>>>;
|
||||
} // namespace tensor
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_INCLUDE_MS_TENSOR_H_
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
#include "src/common/ms_tensor_utils.h"
|
||||
|
||||
namespace mindspore::lite {
|
||||
int Executor::Run(std::vector<tensor::Tensor *> &inputs, std::vector<tensor::Tensor *> &outputs,
|
||||
int Executor::Run(std::vector<tensor::Tensor *> &in_tensors, std::vector<tensor::Tensor *> &out_tensors,
|
||||
std::vector<kernel::LiteKernel *> &kernels, Allocator *allocator,
|
||||
const session::KernelCallBack &before, const session::KernelCallBack &after) {
|
||||
MS_ASSERT(nullptr != allocator);
|
||||
for (auto &inTensor : inputs) {
|
||||
for (auto &inTensor : in_tensors) {
|
||||
if (inTensor == nullptr) {
|
||||
MS_LOG(ERROR) << "Graph input tensor is nullptr";
|
||||
return RET_ERROR;
|
||||
|
@ -39,31 +39,31 @@ int Executor::Run(std::vector<tensor::Tensor *> &inputs, std::vector<tensor::Ten
|
|||
MS_ASSERT(nullptr != kernel);
|
||||
|
||||
if (before != nullptr) {
|
||||
if (!before(PackToMSTensors(kernel->GetInputs()), PackToMSTensors(kernel->GetOutputs()),
|
||||
{kernel->Name(), kernel->type_str()})) {
|
||||
MS_LOG(ERROR) << "run kernel before_callback failed, name: " << kernel->Name();
|
||||
if (!before(PackToMSTensors(kernel->in_tensors()), PackToMSTensors(kernel->out_tensors()),
|
||||
{kernel->name(), kernel->type_str()})) {
|
||||
MS_LOG(ERROR) << "run kernel before_callback failed, name: " << kernel->name();
|
||||
}
|
||||
}
|
||||
auto ret = kernel->Run();
|
||||
if (0 != ret) {
|
||||
MS_LOG(ERROR) << "run kernel failed, name: " << kernel->Name();
|
||||
MS_LOG(ERROR) << "run kernel failed, name: " << kernel->name();
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (after != nullptr) {
|
||||
if (!after(PackToMSTensors(kernel->GetInputs()), PackToMSTensors(kernel->GetOutputs()),
|
||||
{kernel->Name(), kernel->type_str()})) {
|
||||
MS_LOG(ERROR) << "run kernel after_callback failed, name: " << kernel->Name();
|
||||
if (!after(PackToMSTensors(kernel->in_tensors()), PackToMSTensors(kernel->out_tensors()),
|
||||
{kernel->name(), kernel->type_str()})) {
|
||||
MS_LOG(ERROR) << "run kernel after_callback failed, name: " << kernel->name();
|
||||
}
|
||||
}
|
||||
for (auto input_kernel : kernel->GetInKernels()) {
|
||||
for (auto input_kernel : kernel->in_kernels()) {
|
||||
MS_ASSERT(input_kernel != nullptr);
|
||||
if (input_kernel->is_model_output()) {
|
||||
continue;
|
||||
}
|
||||
ret = input_kernel->DecOutTensorRefCount();
|
||||
if (0 != ret) {
|
||||
MS_LOG(WARNING) << "DecOutTensorRefCount for kernel" << kernel->Name() << " failed";
|
||||
MS_LOG(WARNING) << "DecOutTensorRefCount for kernel" << kernel->name() << " failed";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class Executor {
|
|||
|
||||
int Prepare(std::vector<kernel::LiteKernel *> &kernels) { return 0; }
|
||||
|
||||
int Run(std::vector<tensor::Tensor *> &inputs, std::vector<tensor::Tensor *> &outputs,
|
||||
int Run(std::vector<tensor::Tensor *> &in_tensors, std::vector<tensor::Tensor *> &out_tensors,
|
||||
std::vector<kernel::LiteKernel *> &kernels, Allocator *allocator = nullptr,
|
||||
const session::KernelCallBack &before = nullptr, const session::KernelCallBack &after = nullptr);
|
||||
|
||||
|
@ -39,9 +39,6 @@ class Executor {
|
|||
int TransformTensorLayoutUint8(tensor::Tensor *tensor, schema::Format dst_format, Allocator *allocator = nullptr);
|
||||
|
||||
int TransformTensorLayout(tensor::Tensor *tensor, schema::Format dst_format, Allocator *allocator = nullptr);
|
||||
|
||||
protected:
|
||||
Context *context = nullptr;
|
||||
};
|
||||
|
||||
} // namespace mindspore::lite
|
||||
|
|
|
@ -33,8 +33,8 @@ KernelFactory *KernelFactory::GetInstance() {
|
|||
return &instance;
|
||||
}
|
||||
|
||||
LiteKernel *KernelFactory::GetKernel(const std::vector<tensor::Tensor *> &inputs,
|
||||
const std::vector<tensor::Tensor *> &outputs, const lite::Primitive *primitive,
|
||||
LiteKernel *KernelFactory::GetKernel(const std::vector<tensor::Tensor *> &in_tensors,
|
||||
const std::vector<tensor::Tensor *> &out_tensors, const lite::Primitive *primitive,
|
||||
const Context *ctx, const kernel::KernelKey &key) {
|
||||
MS_EXCEPTION_IF_NULL(primitive);
|
||||
MS_EXCEPTION_IF_NULL(ctx);
|
||||
|
@ -45,7 +45,7 @@ LiteKernel *KernelFactory::GetKernel(const std::vector<tensor::Tensor *> &inputs
|
|||
}
|
||||
auto creator = KernelRegistry::GetInstance()->GetCreator(key);
|
||||
if (creator != nullptr) {
|
||||
auto kernel = creator(inputs, outputs, parameter, ctx, key, primitive);
|
||||
auto kernel = creator(in_tensors, out_tensors, parameter, ctx, key, primitive);
|
||||
return kernel;
|
||||
}
|
||||
return nullptr;
|
||||
|
|
|
@ -31,8 +31,8 @@ class KernelFactory {
|
|||
virtual ~KernelFactory();
|
||||
|
||||
static KernelFactory *GetInstance();
|
||||
kernel::LiteKernel *GetKernel(const std::vector<tensor::Tensor *> &inputs,
|
||||
const std::vector<tensor::Tensor *> &outputs, const lite::Primitive *primitive,
|
||||
kernel::LiteKernel *GetKernel(const std::vector<tensor::Tensor *> &in_tensors,
|
||||
const std::vector<tensor::Tensor *> &out_tensors, const lite::Primitive *primitive,
|
||||
const Context *ctx, const kernel::KernelKey &key);
|
||||
};
|
||||
} // namespace mindspore::lite
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
namespace mindspore::kernel {
|
||||
void LiteKernel::InitOutTensorRefCount() {
|
||||
for (auto *tensor : this->outputs_) {
|
||||
tensor->SetRefCount(this->out_kernel_.size());
|
||||
for (auto *tensor : this->out_tensors_) {
|
||||
tensor->SetRefCount(this->out_kernels_.size());
|
||||
}
|
||||
}
|
||||
|
||||
int LiteKernel::DecOutTensorRefCount() {
|
||||
for (auto *tensor : this->outputs_) {
|
||||
for (auto *tensor : this->out_tensors_) {
|
||||
tensor->decRefCount();
|
||||
if (0 >= tensor->RefCount()) {
|
||||
auto ret = tensor->FreeData();
|
||||
|
@ -43,7 +43,7 @@ std::vector<kernel::LiteKernel *> LiteKernelUtil::SubgraphInputKernels(
|
|||
const std::vector<kernel::LiteKernel *> &kernels) {
|
||||
std::vector<kernel::LiteKernel *> input_kernels;
|
||||
for (const auto kernel : kernels) {
|
||||
for (auto input : kernel->GetInKernels()) {
|
||||
for (auto input : kernel->in_kernels()) {
|
||||
auto iter = std::find(kernels.begin(), kernels.end(), input);
|
||||
if (iter == kernels.end()) {
|
||||
input_kernels.emplace_back(input);
|
||||
|
@ -57,7 +57,7 @@ std::vector<kernel::LiteKernel *> LiteKernelUtil::SubgraphOutputKernels(
|
|||
const std::vector<kernel::LiteKernel *> &kernels) {
|
||||
std::vector<kernel::LiteKernel *> output_kernels;
|
||||
for (const auto kernel : kernels) {
|
||||
for (const auto output : kernel->GetOutKernels()) {
|
||||
for (const auto output : kernel->out_kernels()) {
|
||||
auto iter = std::find(kernels.begin(), kernels.end(), output);
|
||||
if (iter == kernels.end()) {
|
||||
output_kernels.emplace_back(output);
|
||||
|
@ -72,11 +72,11 @@ std::vector<lite::tensor::Tensor *> LiteKernelUtil::SubgraphInputTensors(
|
|||
std::vector<lite::tensor::Tensor *> input_tensors;
|
||||
std::vector<lite::tensor::Tensor *> all_output_tensors;
|
||||
for (const auto &kernel : kernels) {
|
||||
all_output_tensors.insert(all_output_tensors.end(), kernel->GetOutputs().begin(), kernel->GetOutputs().end());
|
||||
all_output_tensors.insert(all_output_tensors.end(), kernel->out_tensors().begin(), kernel->out_tensors().end());
|
||||
}
|
||||
std::vector<kernel::LiteKernel *> input_kernels = SubgraphInputKernels(kernels);
|
||||
for (const auto &kernel : input_kernels) {
|
||||
for (const auto &tensor : kernel->GetInputs()) {
|
||||
for (const auto &tensor : kernel->in_tensors()) {
|
||||
auto iter = std::find(all_output_tensors.begin(), all_output_tensors.end(), tensor);
|
||||
if (iter == all_output_tensors.end() && tensor->Data() == nullptr) {
|
||||
input_tensors.emplace_back(tensor);
|
||||
|
@ -91,11 +91,11 @@ std::vector<lite::tensor::Tensor *> LiteKernelUtil::SubgraphOutputTensors(
|
|||
std::vector<lite::tensor::Tensor *> output_tensors;
|
||||
std::vector<lite::tensor::Tensor *> all_input_tensors;
|
||||
for (const auto &kernel : kernels) {
|
||||
all_input_tensors.insert(all_input_tensors.end(), kernel->GetInputs().begin(), kernel->GetInputs().end());
|
||||
all_input_tensors.insert(all_input_tensors.end(), kernel->in_tensors().begin(), kernel->in_tensors().end());
|
||||
}
|
||||
std::vector<kernel::LiteKernel *> output_kernels = SubgraphOutputKernels(kernels);
|
||||
for (const auto &kernel : output_kernels) {
|
||||
for (const auto &tensor : kernel->GetOutputs()) {
|
||||
for (const auto &tensor : kernel->out_tensors()) {
|
||||
auto iter = std::find(all_input_tensors.begin(), all_input_tensors.end(), tensor);
|
||||
if (iter == all_input_tensors.end()) {
|
||||
output_tensors.emplace_back(tensor);
|
||||
|
@ -111,13 +111,13 @@ void LiteKernelUtil::TopologicalSortKernels(std::vector<kernel::LiteKernel *> &k
|
|||
if (search_kernel == kernel) {
|
||||
continue;
|
||||
}
|
||||
for (auto *tensor : kernel->GetInputs()) {
|
||||
if (lite::IsContain(search_kernel->GetOutputs(), tensor)) {
|
||||
for (auto *tensor : kernel->in_tensors()) {
|
||||
if (lite::IsContain(search_kernel->out_tensors(), tensor)) {
|
||||
kernel->AddInKernel(search_kernel);
|
||||
}
|
||||
}
|
||||
for (auto *tensor : kernel->GetOutputs()) {
|
||||
if (lite::IsContain(search_kernel->GetInputs(), tensor)) {
|
||||
for (auto *tensor : kernel->out_tensors()) {
|
||||
if (lite::IsContain(search_kernel->in_tensors(), tensor)) {
|
||||
kernel->AddOutKernel(search_kernel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,102 +57,109 @@ struct KernelKey {
|
|||
class LiteKernel {
|
||||
public:
|
||||
LiteKernel() = default;
|
||||
explicit LiteKernel(OpParameter *parameter, const std::vector<lite::tensor::Tensor *> &inputs,
|
||||
const std::vector<lite::tensor::Tensor *> &outputs, const lite::Context *ctx,
|
||||
explicit LiteKernel(OpParameter *parameter, const std::vector<lite::tensor::Tensor *> &in_tensors,
|
||||
const std::vector<lite::tensor::Tensor *> &out_tensors, const lite::Context *ctx,
|
||||
const lite::Primitive *primitive)
|
||||
: opParameter(parameter), inputs_(inputs), outputs_(outputs), primitive_(primitive), context_(ctx) {
|
||||
if (opParameter && ctx) {
|
||||
opParameter->thread_num_ = ctx->thread_num_;
|
||||
: op_parameter_(parameter),
|
||||
in_tensors_(in_tensors),
|
||||
out_tensors_(out_tensors),
|
||||
primitive_(primitive),
|
||||
context_(ctx) {
|
||||
if (op_parameter_ && ctx) {
|
||||
op_parameter_->thread_num_ = ctx->thread_num_;
|
||||
}
|
||||
this->in_kernel_.clear();
|
||||
this->out_kernel_.clear();
|
||||
this->in_kernels_.clear();
|
||||
this->out_kernels_.clear();
|
||||
}
|
||||
|
||||
virtual ~LiteKernel() { delete opParameter; }
|
||||
virtual ~LiteKernel() { delete op_parameter_; }
|
||||
|
||||
virtual int Prepare() {
|
||||
if (!InferShapeDone()) {
|
||||
(const_cast<lite::Primitive *>(primitive_))->InferShape(inputs_, outputs_);
|
||||
if (need_reinit) {
|
||||
(const_cast<lite::Primitive *>(primitive_))->InferShape(in_tensors_, out_tensors_);
|
||||
if (need_reinit_) {
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
auto &outputs = this->GetOutputs();
|
||||
auto &outputs = this->out_tensors();
|
||||
for (auto *output : outputs) {
|
||||
MS_ASSERT(output != nullptr);
|
||||
output->MallocData();
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
virtual int Init() { return -1; }
|
||||
|
||||
virtual int ReSize() { return -1; }
|
||||
|
||||
virtual int Run() { return -1; }
|
||||
|
||||
std::string Name() { return this->name; }
|
||||
virtual void train() { train_mode = true; }
|
||||
virtual bool is_train() { return train_mode == true; }
|
||||
virtual void eval() { train_mode = false; }
|
||||
virtual bool is_eval() { return train_mode == false; }
|
||||
void set_name(const std::string &name) { this->name = name; }
|
||||
std::string name() { return this->name_; }
|
||||
|
||||
virtual void train() { train_mode_ = true; }
|
||||
|
||||
virtual bool is_train() { return train_mode_; }
|
||||
|
||||
virtual void eval() { train_mode_ = false; }
|
||||
|
||||
virtual bool is_eval() { return !train_mode_; }
|
||||
|
||||
void set_name(const std::string &name) { this->name_ = name; }
|
||||
|
||||
void set_is_model_output(bool is_model_output) { this->is_model_output_ = is_model_output; }
|
||||
|
||||
bool is_model_output() { return this->is_model_output_; }
|
||||
bool is_model_output() const { return this->is_model_output_; }
|
||||
|
||||
schema::PrimitiveType type() { return (schema::PrimitiveType)this->opParameter->type_; }
|
||||
|
||||
std::string type_str() {
|
||||
return this->opParameter ? schema::EnumNamePrimitiveType((schema::PrimitiveType)this->opParameter->type_)
|
||||
: "ERROR:undefined primitive!";
|
||||
schema::PrimitiveType Type() {
|
||||
return (this->op_parameter_ != nullptr) ? schema::PrimitiveType(this->op_parameter_->type_)
|
||||
: schema::PrimitiveType_NONE;
|
||||
}
|
||||
|
||||
void SetInputs(const std::vector<lite::tensor::Tensor *> &inputs) { this->inputs_ = inputs; }
|
||||
std::string type_str() { return schema::EnumNamePrimitiveType(this->Type()); }
|
||||
|
||||
void SetOutputs(const std::vector<lite::tensor::Tensor *> &outputs) { this->outputs_ = outputs; }
|
||||
void set_in_tensors(const std::vector<lite::tensor::Tensor *> &in_tensors) { this->in_tensors_ = in_tensors; }
|
||||
|
||||
std::vector<lite::tensor::Tensor *> &GetInputs() { return this->inputs_; }
|
||||
void set_out_tensors(const std::vector<lite::tensor::Tensor *> &out_tensors) { this->out_tensors_ = out_tensors; }
|
||||
|
||||
std::vector<lite::tensor::Tensor *> &GetOutputs() { return this->outputs_; }
|
||||
std::vector<lite::tensor::Tensor *> &in_tensors() { return this->in_tensors_; }
|
||||
|
||||
void AddInKernel(LiteKernel *kernel) { this->in_kernel_.emplace_back(kernel); }
|
||||
std::vector<lite::tensor::Tensor *> &out_tensors() { return this->out_tensors_; }
|
||||
|
||||
void AddOutKernel(LiteKernel *kernel) { this->out_kernel_.emplace_back(kernel); }
|
||||
void AddInKernel(LiteKernel *kernel) { this->in_kernels_.emplace_back(kernel); }
|
||||
|
||||
std::vector<LiteKernel *> &GetInKernels() { return this->in_kernel_; }
|
||||
void AddOutKernel(LiteKernel *kernel) { this->out_kernels_.emplace_back(kernel); }
|
||||
|
||||
std::vector<LiteKernel *> &GetOutKernels() { return this->out_kernel_; }
|
||||
std::vector<LiteKernel *> &in_kernels() { return this->in_kernels_; }
|
||||
|
||||
std::vector<LiteKernel *> &out_kernels() { return this->out_kernels_; }
|
||||
|
||||
void InitOutTensorRefCount();
|
||||
|
||||
int DecOutTensorRefCount();
|
||||
|
||||
const KernelKey Desc() const { return desc; }
|
||||
KernelKey desc() const { return desc_; }
|
||||
|
||||
void set_desc(const KernelKey kernel_key) { desc = kernel_key; }
|
||||
void set_desc(const KernelKey kernel_key) { desc_ = kernel_key; }
|
||||
|
||||
void SetNeedReInit() { need_reinit = true; }
|
||||
void set_need_reinit() { need_reinit_ = true; }
|
||||
|
||||
protected:
|
||||
bool InferShapeDone() {
|
||||
if (primitive_ != nullptr && !primitive_->GetInferFlag()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool InferShapeDone() { return !(primitive_ != nullptr && !primitive_->GetInferFlag()) && true; }
|
||||
|
||||
KernelKey desc;
|
||||
std::string name;
|
||||
OpParameter *opParameter = nullptr;
|
||||
KernelKey desc_;
|
||||
std::string name_;
|
||||
OpParameter *op_parameter_ = nullptr;
|
||||
const lite::Primitive *primitive_ = nullptr;
|
||||
const lite::Context *context_ = nullptr;
|
||||
// tensor will free in ~lite_session()
|
||||
std::vector<lite::tensor::Tensor *> inputs_;
|
||||
std::vector<lite::tensor::Tensor *> outputs_;
|
||||
std::vector<LiteKernel *> in_kernel_;
|
||||
std::vector<LiteKernel *> out_kernel_;
|
||||
bool train_mode = false;
|
||||
bool need_reinit = false;
|
||||
std::vector<lite::tensor::Tensor *> in_tensors_;
|
||||
std::vector<lite::tensor::Tensor *> out_tensors_;
|
||||
std::vector<LiteKernel *> in_kernels_;
|
||||
std::vector<LiteKernel *> out_kernels_;
|
||||
bool train_mode_ = false;
|
||||
bool need_reinit_ = false;
|
||||
bool is_model_output_ = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -74,46 +74,46 @@ int LiteSession::ConvertTensors(const lite::Model *model) {
|
|||
}
|
||||
}
|
||||
|
||||
this->tensors.emplace_back(dstTensor);
|
||||
this->tensors_.emplace_back(dstTensor);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void LiteSession::InitGraphInputTensors(const lite::Model *model) {
|
||||
auto meta_graph = model->GetMetaGraph();
|
||||
MS_ASSERT(this->inputs.empty());
|
||||
MS_ASSERT(this->inputs_.empty());
|
||||
MS_ASSERT(meta_graph != nullptr);
|
||||
for (size_t i = 0; i < meta_graph->inputIndex()->size(); i++) {
|
||||
auto in_tensor_idx = size_t(meta_graph->inputIndex()->GetAs<uint32_t>(i));
|
||||
MS_ASSERT(in_tensor_idx < this->tensors.size());
|
||||
auto *in_tensor = this->tensors.at(in_tensor_idx);
|
||||
MS_ASSERT(in_tensor_idx < this->tensors_.size());
|
||||
auto *in_tensor = this->tensors_.at(in_tensor_idx);
|
||||
MS_ASSERT(in_tensor != nullptr);
|
||||
this->inputs.emplace_back(in_tensor);
|
||||
this->inputs_.emplace_back(in_tensor);
|
||||
}
|
||||
}
|
||||
|
||||
void LiteSession::InitGraphOutputTensors(const lite::Model *model) {
|
||||
auto meta_graph = model->GetMetaGraph();
|
||||
MS_ASSERT(this->outputs.empty());
|
||||
MS_ASSERT(this->outputs_.empty());
|
||||
MS_ASSERT(meta_graph != nullptr);
|
||||
for (size_t i = 0; i < meta_graph->outputIndex()->size(); i++) {
|
||||
auto out_tensor_idx = size_t(meta_graph->outputIndex()->GetAs<uint32_t>(i));
|
||||
MS_ASSERT(out_tensor_idx < this->tensors.size());
|
||||
auto *out_tensor = this->tensors.at(out_tensor_idx);
|
||||
MS_ASSERT(out_tensor_idx < this->tensors_.size());
|
||||
auto *out_tensor = this->tensors_.at(out_tensor_idx);
|
||||
MS_ASSERT(out_tensor != nullptr);
|
||||
this->outputs.emplace_back(out_tensor);
|
||||
this->outputs_.emplace_back(out_tensor);
|
||||
}
|
||||
}
|
||||
|
||||
void LiteSession::InitGraphInputMap(const lite::Model *model) {
|
||||
auto meta_graph = model->GetMetaGraph();
|
||||
MS_ASSERT(this->input_map.empty());
|
||||
MS_ASSERT(this->input_map_.empty());
|
||||
MS_ASSERT(meta_graph != nullptr);
|
||||
auto graph_input_node_indexes = GetGraphInputNodes(meta_graph);
|
||||
for (auto in_node_index : graph_input_node_indexes) {
|
||||
auto *in_node = meta_graph->nodes()->GetAs<schema::CNode>(in_node_index);
|
||||
MS_ASSERT(nullptr != in_node);
|
||||
MS_ASSERT(this->input_map.find(in_node->name()->str()) == this->input_map.end());
|
||||
MS_ASSERT(this->input_map_.find(in_node->name()->str()) == this->input_map_.end());
|
||||
for (size_t i = 0; i < in_node->inputIndex()->size(); i++) {
|
||||
auto in_tensor_index = size_t(in_node->inputIndex()->GetAs<uint32_t>(i));
|
||||
bool is_graph_input = false;
|
||||
|
@ -126,25 +126,25 @@ void LiteSession::InitGraphInputMap(const lite::Model *model) {
|
|||
if (!is_graph_input) {
|
||||
continue;
|
||||
}
|
||||
MS_ASSERT(in_tensor_index < this->tensors.size());
|
||||
auto *in_tensor = this->tensors.at(in_tensor_index);
|
||||
MS_ASSERT(in_tensor_index < this->tensors_.size());
|
||||
auto *in_tensor = this->tensors_.at(in_tensor_index);
|
||||
MS_ASSERT(in_tensor != nullptr);
|
||||
auto *ms_tensor = new tensor::LiteTensor(in_tensor);
|
||||
MS_ASSERT(nullptr != ms_tensor);
|
||||
this->input_map[in_node->name()->str()].emplace_back(ms_tensor);
|
||||
this->input_map_[in_node->name()->str()].emplace_back(ms_tensor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LiteSession::InitGraphOutputMap(const lite::Model *model) {
|
||||
auto meta_graph = model->GetMetaGraph();
|
||||
MS_ASSERT(this->output_map.empty());
|
||||
MS_ASSERT(this->output_map_.empty());
|
||||
MS_ASSERT(meta_graph != nullptr);
|
||||
auto graph_output_node_indexes = GetGraphOutputNodes(meta_graph);
|
||||
for (auto out_node_index : graph_output_node_indexes) {
|
||||
auto *out_node = meta_graph->nodes()->GetAs<schema::CNode>(out_node_index);
|
||||
MS_ASSERT(nullptr != out_node);
|
||||
MS_ASSERT(this->output_map.find(out_node->name()->str()) == this->output_map.end());
|
||||
MS_ASSERT(this->output_map_.find(out_node->name()->str()) == this->output_map_.end());
|
||||
for (size_t i = 0; i < out_node->outputIndex()->size(); i++) {
|
||||
auto out_tensor_index = size_t(out_node->outputIndex()->GetAs<uint32_t>(i));
|
||||
bool is_graph_output = false;
|
||||
|
@ -157,12 +157,12 @@ void LiteSession::InitGraphOutputMap(const lite::Model *model) {
|
|||
if (!is_graph_output) {
|
||||
continue;
|
||||
}
|
||||
MS_ASSERT(out_tensor_index < this->tensors.size());
|
||||
auto *out_tensor = this->tensors.at(out_tensor_index);
|
||||
MS_ASSERT(out_tensor_index < this->tensors_.size());
|
||||
auto *out_tensor = this->tensors_.at(out_tensor_index);
|
||||
MS_ASSERT(out_tensor != nullptr);
|
||||
auto *ms_tensor = new tensor::LiteTensor(out_tensor);
|
||||
MS_ASSERT(nullptr != ms_tensor);
|
||||
this->output_map[out_node->name()->str()].emplace_back(ms_tensor);
|
||||
this->output_map_[out_node->name()->str()].emplace_back(ms_tensor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ int LiteSession::CompileGraph(Model *model) {
|
|||
|
||||
// scheduler kernels
|
||||
Scheduler scheduler(context_);
|
||||
ret = scheduler.Schedule(model, &tensors, &kernels);
|
||||
ret = scheduler.Schedule(model, &tensors_, &kernels_);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Schedule kernels failed: " << ret;
|
||||
return ret;
|
||||
|
@ -202,7 +202,7 @@ int LiteSession::CompileGraph(Model *model) {
|
|||
|
||||
std::vector<mindspore::tensor::MSTensor *> LiteSession::GetInputs() const {
|
||||
std::vector<mindspore::tensor::MSTensor *> ret;
|
||||
for (auto &iter : this->input_map) {
|
||||
for (auto &iter : this->input_map_) {
|
||||
auto &node_input_tensors = iter.second;
|
||||
for (auto tensor : node_input_tensors) {
|
||||
if (!IsContain(ret, tensor)) {
|
||||
|
@ -219,14 +219,14 @@ int LiteSession::RunGraph(const session::KernelCallBack &before, const session::
|
|||
context_->running_ = true;
|
||||
Executor executor;
|
||||
if (before == nullptr && after == nullptr) {
|
||||
return executor.Run(this->inputs, this->outputs, this->kernels, this->context_->allocator.get());
|
||||
return executor.Run(this->inputs_, this->outputs_, this->kernels_, this->context_->allocator.get());
|
||||
} else {
|
||||
return executor.Run(this->inputs, this->outputs, this->kernels, this->context_->allocator.get(), before, after);
|
||||
return executor.Run(this->inputs_, this->outputs_, this->kernels_, this->context_->allocator.get(), before, after);
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::vector<mindspore::tensor::MSTensor *>> LiteSession::GetOutputs() const {
|
||||
return this->output_map;
|
||||
return this->output_map_;
|
||||
}
|
||||
|
||||
int LiteSession::Init(Context *context) {
|
||||
|
@ -252,46 +252,46 @@ int LiteSession::Init(Context *context) {
|
|||
return RET_OK;
|
||||
}
|
||||
|
||||
void LiteSession::BindThread(bool ifBind) {
|
||||
void LiteSession::BindThread(bool if_bind) {
|
||||
if (this->context_->cpu_bind_mode_ != NO_BIND) {
|
||||
DoAllThreadBind(ifBind, static_cast<int>(this->context_->cpu_bind_mode_));
|
||||
DoAllThreadBind(if_bind, static_cast<int>(this->context_->cpu_bind_mode_));
|
||||
}
|
||||
}
|
||||
|
||||
LiteSession::~LiteSession() {
|
||||
for (auto *tensor : tensors) {
|
||||
for (auto *tensor : tensors_) {
|
||||
// weight data can not be to free, we will free weight data when freeing meta_graph
|
||||
if (tensor->TensorType() == schema::NodeType_ValueNode && !IsContain(this->inputs, tensor)) {
|
||||
if (tensor->TensorType() == schema::NodeType_ValueNode && !IsContain(this->inputs_, tensor)) {
|
||||
tensor->SetData(nullptr);
|
||||
}
|
||||
delete tensor;
|
||||
}
|
||||
// tensor::Tensor * in input_map output_map are freed in tensors
|
||||
for (auto iter : this->input_map) {
|
||||
for (auto iter : this->input_map_) {
|
||||
for (auto *ms_tensor : iter.second) {
|
||||
((tensor::LiteTensor *)ms_tensor)->SetTensorImpl(nullptr);
|
||||
delete ms_tensor;
|
||||
}
|
||||
iter.second.clear();
|
||||
}
|
||||
input_map.clear();
|
||||
for (auto iter : this->output_map) {
|
||||
input_map_.clear();
|
||||
for (auto iter : this->output_map_) {
|
||||
for (auto *ms_tensor : iter.second) {
|
||||
((tensor::LiteTensor *)ms_tensor)->SetTensorImpl(nullptr);
|
||||
delete ms_tensor;
|
||||
}
|
||||
iter.second.clear();
|
||||
}
|
||||
output_map.clear();
|
||||
for (auto *kernel : kernels) {
|
||||
output_map_.clear();
|
||||
for (auto *kernel : kernels_) {
|
||||
delete kernel;
|
||||
}
|
||||
delete this->context_;
|
||||
}
|
||||
|
||||
std::vector<mindspore::tensor::MSTensor *> LiteSession::GetInputsByName(const std::string &name) const {
|
||||
auto ret = input_map.find(name);
|
||||
if (ret == input_map.end()) {
|
||||
auto ret = input_map_.find(name);
|
||||
if (ret == input_map_.end()) {
|
||||
MS_LOG(WARNING) << "Node " << name << " is not an input node";
|
||||
std::vector<mindspore::tensor::MSTensor *> empty_ret;
|
||||
return empty_ret;
|
||||
|
@ -300,8 +300,8 @@ std::vector<mindspore::tensor::MSTensor *> LiteSession::GetInputsByName(const st
|
|||
}
|
||||
|
||||
std::vector<mindspore::tensor::MSTensor *> LiteSession::GetOutputsByName(const std::string &name) const {
|
||||
auto ret = output_map.find(name);
|
||||
if (ret == output_map.end()) {
|
||||
auto ret = output_map_.find(name);
|
||||
if (ret == output_map_.end()) {
|
||||
MS_LOG(WARNING) << "Node " << name << " is not an output node";
|
||||
std::vector<mindspore::tensor::MSTensor *> empty_ret;
|
||||
return empty_ret;
|
||||
|
|
|
@ -38,7 +38,7 @@ class LiteSession : public session::LiteSession {
|
|||
|
||||
int Init(Context *context);
|
||||
|
||||
void BindThread(bool ifBind) override;
|
||||
void BindThread(bool if_bind) override;
|
||||
|
||||
int CompileGraph(Model *model) override;
|
||||
|
||||
|
@ -68,16 +68,16 @@ class LiteSession : public session::LiteSession {
|
|||
|
||||
protected:
|
||||
Context *context_ = nullptr;
|
||||
std::vector<kernel::LiteKernel *> kernels;
|
||||
std::vector<tensor::Tensor *> tensors;
|
||||
std::vector<kernel::LiteKernel *> kernels_;
|
||||
std::vector<tensor::Tensor *> tensors_;
|
||||
// graph input tensors
|
||||
std::vector<tensor::Tensor *> inputs;
|
||||
std::vector<tensor::Tensor *> inputs_;
|
||||
// graph output tensors
|
||||
std::vector<tensor::Tensor *> outputs;
|
||||
std::vector<tensor::Tensor *> outputs_;
|
||||
// graph input node name -- input tensors
|
||||
std::unordered_map<std::string, std::vector<mindspore::tensor::MSTensor *>> input_map;
|
||||
std::unordered_map<std::string, std::vector<mindspore::tensor::MSTensor *>> input_map_;
|
||||
// graph output node name -- output tensors
|
||||
std::unordered_map<std::string, std::vector<mindspore::tensor::MSTensor *>> output_map;
|
||||
std::unordered_map<std::string, std::vector<mindspore::tensor::MSTensor *>> output_map_;
|
||||
};
|
||||
} // namespace lite
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -30,9 +30,7 @@ Model *Model::Import(const char *model_buf, size_t size) {
|
|||
return model;
|
||||
}
|
||||
|
||||
Model::~Model() {
|
||||
delete(this->model_impl_);
|
||||
}
|
||||
Model::~Model() { delete (this->model_impl_); }
|
||||
|
||||
lite::Primitive *Model::GetOp(const std::string &name) const {
|
||||
MS_EXCEPTION_IF_NULL(model_impl_);
|
||||
|
@ -46,7 +44,7 @@ void Model::FreeMetaGraph() {
|
|||
|
||||
const schema::MetaGraph *Model::GetMetaGraph() const {
|
||||
MS_EXCEPTION_IF_NULL(model_impl_);
|
||||
return model_impl_->GetMetaGraph();
|
||||
return model_impl_->meta_graph();
|
||||
}
|
||||
|
||||
ModelImpl *Model::model_impl() {
|
||||
|
|
|
@ -47,8 +47,8 @@ ModelImpl *ModelImpl::Import(const char *model_buf, size_t size) {
|
|||
}
|
||||
|
||||
lite::Primitive *ModelImpl::GetOp(const std::string &name) const {
|
||||
auto iter = ops.find(name);
|
||||
if (iter == ops.end()) {
|
||||
auto iter = ops_.find(name);
|
||||
if (iter == ops_.end()) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return iter->second;
|
||||
|
@ -57,10 +57,10 @@ lite::Primitive *ModelImpl::GetOp(const std::string &name) const {
|
|||
|
||||
ModelImpl::~ModelImpl() {
|
||||
delete[](this->model_buf_);
|
||||
for (auto iter : ops) {
|
||||
for (auto iter : ops_) {
|
||||
delete (iter.second);
|
||||
}
|
||||
ops.clear();
|
||||
ops_.clear();
|
||||
}
|
||||
|
||||
void ModelImpl::FreeMetaGraph() {
|
||||
|
@ -68,168 +68,168 @@ void ModelImpl::FreeMetaGraph() {
|
|||
model_buf_ = nullptr;
|
||||
}
|
||||
|
||||
const schema::MetaGraph *ModelImpl::GetMetaGraph() const { return this->meta_graph; }
|
||||
const schema::MetaGraph *ModelImpl::meta_graph() const { return this->meta_graph_; }
|
||||
|
||||
lite::Primitive *ModelImpl::CopyPrimitive(const schema::Primitive *srcPrim) {
|
||||
MS_EXCEPTION_IF_NULL(srcPrim);
|
||||
auto op_type = srcPrim->value_type();
|
||||
lite::Primitive *ModelImpl::CopyPrimitive(const schema::Primitive *src_prim) {
|
||||
MS_EXCEPTION_IF_NULL(src_prim);
|
||||
auto op_type = src_prim->value_type();
|
||||
switch (op_type) {
|
||||
case schema::PrimitiveType_SoftMax:
|
||||
return new lite::SoftMax(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::SoftMax(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Activation:
|
||||
return new lite::Activation(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Activation(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Conv2D:
|
||||
return new lite::Conv2D(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Conv2D(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_DeConv2D:
|
||||
return new lite::DeConv2D(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::DeConv2D(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Reduce:
|
||||
return new lite::Reduce(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Reduce(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Pooling:
|
||||
return new lite::Pooling(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Pooling(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_DepthwiseConv2D:
|
||||
return new lite::DepthwiseConv2D(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::DepthwiseConv2D(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_FusedBatchNorm:
|
||||
return new lite::FusedBatchNorm(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::FusedBatchNorm(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_BatchNorm:
|
||||
return new lite::BatchNorm(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::BatchNorm(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_FullConnection:
|
||||
return new lite::FullConnection(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::FullConnection(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Power:
|
||||
return new lite::Power(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Power(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Range:
|
||||
return new lite::Range(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Range(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Mul:
|
||||
return new lite::Mul(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Mul(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Add:
|
||||
return new lite::Add(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Add(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Sub:
|
||||
return new lite::Sub(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Sub(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Div:
|
||||
return new lite::Div(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Div(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_BiasAdd:
|
||||
return new lite::BiasAdd(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::BiasAdd(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_ExpandDims:
|
||||
return new lite::ExpandDims(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::ExpandDims(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_ArgMax:
|
||||
return new lite::ArgMax(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::ArgMax(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_ArgMin:
|
||||
return new lite::ArgMin(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::ArgMin(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Cast:
|
||||
return new lite::Cast(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Cast(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Reshape:
|
||||
return new lite::Reshape(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Reshape(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Scale:
|
||||
return new lite::Scale(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Scale(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Eltwise:
|
||||
return new lite::Eltwise(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Eltwise(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Concat:
|
||||
return new lite::Concat(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Concat(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Fill:
|
||||
return new lite::Fill(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Fill(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Transpose:
|
||||
return new lite::Transpose(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Transpose(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Slice:
|
||||
return new lite::Slice(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Slice(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Squeeze:
|
||||
return new lite::Squeeze(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Squeeze(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Nchw2Nhwc:
|
||||
return new lite::Nchw2Nhwc(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Nchw2Nhwc(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Nhwc2Nchw:
|
||||
return new lite::Nhwc2Nchw(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Nhwc2Nchw(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Flatten:
|
||||
return new lite::Flatten(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Flatten(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Mean:
|
||||
return new lite::Mean(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Mean(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Stack:
|
||||
return new lite::Stack(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Stack(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Crop:
|
||||
return new lite::Crop(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Crop(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_SquaredDifference:
|
||||
return new lite::SquaredDifference(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::SquaredDifference(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_AddN:
|
||||
return new lite::AddN(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::AddN(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Abs:
|
||||
return new lite::Abs(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Abs(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Sin:
|
||||
return new lite::Sin(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Sin(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Cos:
|
||||
return new lite::Cos(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Cos(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Log:
|
||||
return new lite::Log(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Log(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Sqrt:
|
||||
return new lite::Sqrt(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Sqrt(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Rsqrt:
|
||||
return new lite::Rsqrt(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Rsqrt(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Square:
|
||||
return new lite::Square(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Square(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Exp:
|
||||
return new lite::Exp(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Exp(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Gather:
|
||||
return new lite::Gather(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Gather(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_GatherNd:
|
||||
return new lite::GatherNd(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::GatherNd(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_LocalResponseNormalization:
|
||||
return new lite::LocalResponseNormalization(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::LocalResponseNormalization(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Maximum:
|
||||
return new lite::Maximum(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Maximum(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Minimum:
|
||||
return new lite::Minimum(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Minimum(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Pad:
|
||||
return new lite::Pad(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Pad(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_StridedSlice:
|
||||
return new lite::StridedSlice(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::StridedSlice(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Prelu:
|
||||
return new lite::Prelu(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Prelu(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Round:
|
||||
return new lite::Round(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Round(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Reverse:
|
||||
return new lite::Reverse(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Reverse(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_ReverseSequence:
|
||||
return new lite::ReverseSequence(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::ReverseSequence(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_LogicalAnd:
|
||||
return new lite::LogicalAnd(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::LogicalAnd(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_LogicalOr:
|
||||
return new lite::LogicalOr(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::LogicalOr(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_LogicalNot:
|
||||
return new lite::LogicalNot(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::LogicalNot(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_FloorDiv:
|
||||
return new lite::FloorDiv(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::FloorDiv(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_FloorMod:
|
||||
return new lite::FloorMod(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::FloorMod(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Equal:
|
||||
return new lite::Equal(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Equal(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_NotEqual:
|
||||
return new lite::NotEqual(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::NotEqual(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Less:
|
||||
return new lite::Less(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Less(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_LessEqual:
|
||||
return new lite::LessEqual(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::LessEqual(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Greater:
|
||||
return new lite::Greater(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Greater(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_GreaterEqual:
|
||||
return new lite::GreaterEqual(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::GreaterEqual(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Floor:
|
||||
return new lite::Floor(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Floor(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Ceil:
|
||||
return new lite::Ceil(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Ceil(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Split:
|
||||
return new lite::Split(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Split(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_OneHot:
|
||||
return new lite::OneHot(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::OneHot(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Resize:
|
||||
return new lite::Resize(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Resize(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_MatMul:
|
||||
return new lite::MatMul(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::MatMul(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_QuantDTypeCast:
|
||||
return new lite::QuantDTypeCast(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::QuantDTypeCast(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_EmbeddingLookup:
|
||||
return new lite::EmbeddingLookup(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::EmbeddingLookup(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Elu:
|
||||
return new lite::Elu(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Elu(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_DeDepthwiseConv2D:
|
||||
return new lite::DeconvDepthwiseConv2D(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::DeconvDepthwiseConv2D(const_cast<schema::Primitive *>(src_prim));
|
||||
case schema::PrimitiveType_Shape:
|
||||
return new lite::Shape(const_cast<schema::Primitive *>(srcPrim));
|
||||
return new lite::Shape(const_cast<schema::Primitive *>(src_prim));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -237,17 +237,17 @@ lite::Primitive *ModelImpl::CopyPrimitive(const schema::Primitive *srcPrim) {
|
|||
}
|
||||
|
||||
int ModelImpl::BuildOps() {
|
||||
if (this->meta_graph == nullptr) {
|
||||
if (this->meta_graph_ == nullptr) {
|
||||
MS_LOG(ERROR) << "mete_graph is nullptr";
|
||||
return -1;
|
||||
}
|
||||
MS_EXCEPTION_IF_NULL(meta_graph->nodes());
|
||||
for (size_t i = 0; i < meta_graph->nodes()->size(); i++) {
|
||||
auto cNode = meta_graph->nodes()->GetAs<schema::CNode>(i);
|
||||
MS_EXCEPTION_IF_NULL(meta_graph_->nodes());
|
||||
for (size_t i = 0; i < meta_graph_->nodes()->size(); i++) {
|
||||
auto cNode = meta_graph_->nodes()->GetAs<schema::CNode>(i);
|
||||
auto name = cNode->name()->str();
|
||||
auto srcPrim = cNode->primitive();
|
||||
|
||||
this->ops[name] = CopyPrimitive(srcPrim);
|
||||
this->ops_[name] = CopyPrimitive(srcPrim);
|
||||
// flatbuffers::FlatBufferBuilder fbb(1024);
|
||||
// schema::Conv2DBuilder conv2DBuilder(fbb);
|
||||
// conv2DBuilder.add_padMode(srcPrim->value_as_Conv2D()->padMode());
|
||||
|
|
|
@ -30,25 +30,24 @@ class ModelImpl {
|
|||
static ModelImpl *Import(const char *model_buf, size_t size);
|
||||
ModelImpl() = default;
|
||||
explicit ModelImpl(const char *model_buf, size_t size) : model_buf_(model_buf), buf_size_(size) {
|
||||
meta_graph = schema::GetMetaGraph(model_buf);
|
||||
meta_graph_ = schema::GetMetaGraph(model_buf);
|
||||
}
|
||||
virtual ~ModelImpl();
|
||||
lite::Primitive *GetOp(const std::string &name) const;
|
||||
const schema::MetaGraph *GetMetaGraph() const;
|
||||
const schema::MetaGraph *meta_graph() const;
|
||||
void FreeMetaGraph();
|
||||
int BuildOps();
|
||||
|
||||
protected:
|
||||
lite::Primitive *CopyPrimitive(const schema::Primitive *srcPrim);
|
||||
lite::Primitive *CopyPrimitive(const schema::Primitive *src_prim);
|
||||
|
||||
protected:
|
||||
const char *model_buf_;
|
||||
size_t buf_size_;
|
||||
const schema::MetaGraph *meta_graph = nullptr;
|
||||
std::map<std::string, lite::Primitive *> ops;
|
||||
const schema::MetaGraph *meta_graph_ = nullptr;
|
||||
std::map<std::string, lite::Primitive *> ops_;
|
||||
};
|
||||
} // namespace lite
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_LITE_INCLUDE_MODEL_H_
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ using mindspore::schema::PrimitiveType_ArgMin;
|
|||
|
||||
namespace mindspore::kernel {
|
||||
int ArgMinMaxBaseCPUKernel::Init() {
|
||||
auto param = reinterpret_cast<ArgMinMaxParameter *>(opParameter);
|
||||
switch (opParameter->type_) {
|
||||
auto param = reinterpret_cast<ArgMinMaxParameter *>(op_parameter_);
|
||||
switch (op_parameter_->type_) {
|
||||
case PrimitiveType_ArgMax:
|
||||
param->get_max_ = true;
|
||||
break;
|
||||
|
@ -42,7 +42,7 @@ int ArgMinMaxBaseCPUKernel::Init() {
|
|||
param->get_max_ = false;
|
||||
break;
|
||||
default:
|
||||
MS_LOG(ERROR) << "Unexpected type " << opParameter->type_;
|
||||
MS_LOG(ERROR) << "Unexpected type " << op_parameter_->type_;
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
|
@ -50,9 +50,9 @@ int ArgMinMaxBaseCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int ArgMinMaxBaseCPUKernel::ReSize() {
|
||||
auto in_shape = inputs_.at(0)->shape();
|
||||
auto in_shape = in_tensors_.at(0)->shape();
|
||||
auto dims_size = in_shape.size();
|
||||
auto param = reinterpret_cast<ArgMinMaxParameter *>(opParameter);
|
||||
auto param = reinterpret_cast<ArgMinMaxParameter *>(op_parameter_);
|
||||
int axis = param->axis_ < 0 ? param->axis_ + dims_size : param->axis_;
|
||||
param->axis_ = axis;
|
||||
param->dims_size_ = dims_size;
|
||||
|
@ -75,25 +75,25 @@ int ArgMinMaxBaseCPUKernel::ReSize() {
|
|||
}
|
||||
}
|
||||
ComputeStrides(in_shape.data(), param->in_strides_, in_shape.size());
|
||||
auto out_shape = outputs_.at(0)->shape();
|
||||
auto out_shape = out_tensors_.at(0)->shape();
|
||||
ComputeStrides(out_shape.data(), param->out_strides_, out_shape.size());
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int ArgMinMaxBaseCPUKernel::Run() {
|
||||
auto input = inputs_.at(0);
|
||||
auto input = in_tensors_.at(0);
|
||||
|
||||
auto input_data = reinterpret_cast<const void *>(inputs_.at(0)->Data());
|
||||
auto output_data = outputs_.at(0)->Data();
|
||||
auto input_data = reinterpret_cast<const void *>(in_tensors_.at(0)->Data());
|
||||
auto output_data = out_tensors_.at(0)->Data();
|
||||
|
||||
auto shape = input->shape().data();
|
||||
auto param = reinterpret_cast<ArgMinMaxParameter *>(opParameter);
|
||||
auto param = reinterpret_cast<ArgMinMaxParameter *>(op_parameter_);
|
||||
ArgMinMax(input_data, output_data, reinterpret_cast<const int *>(shape), param);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void ArgMinMaxBaseCPUKernel::FreeTmpMemory() {
|
||||
auto param = reinterpret_cast<ArgMinMaxParameter *>(opParameter);
|
||||
auto param = reinterpret_cast<ArgMinMaxParameter *>(op_parameter_);
|
||||
if (param->arg_elements_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ using mindspore::schema::PrimitiveType_BatchToSpace;
|
|||
|
||||
namespace mindspore::kernel {
|
||||
int BatchToSpaceBaseCPUKernel::Init() {
|
||||
BatchToSpaceParameter *param = reinterpret_cast<BatchToSpaceParameter *>(this->opParameter);
|
||||
BatchToSpaceParameter *param = reinterpret_cast<BatchToSpaceParameter *>(this->op_parameter_);
|
||||
for (int i = 0; i < BATCH_TO_SPACE_CROPS_SIZE; ++i) {
|
||||
if (param->crops_[i] != 0) {
|
||||
no_crop_ = false;
|
||||
|
@ -40,7 +40,7 @@ int BatchToSpaceBaseCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int BatchToSpaceBaseCPUKernel::ReSize() {
|
||||
if (inputs_[0]->GetFormat() != schema::Format_NHWC) {
|
||||
if (in_tensors_[0]->GetFormat() != schema::Format_NHWC) {
|
||||
MS_LOG(ERROR) << "batch_to_space only support NHWC now!";
|
||||
return RET_FORMAT_ERR;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace mindspore::kernel {
|
|||
int ConcatBaseCPUKernel::Init() { return RET_OK; }
|
||||
|
||||
int ConcatBaseCPUKernel::ReSize() {
|
||||
axis_ = concat_param_->axis_ >= 0 ? concat_param_->axis_ : inputs_.front()->shape().size() + concat_param_->axis_;
|
||||
axis_ = concat_param_->axis_ >= 0 ? concat_param_->axis_ : in_tensors_.front()->shape().size() + concat_param_->axis_;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class ConcatBaseCPUKernel : public LiteKernel {
|
|||
const std::vector<lite::tensor::Tensor *> &outputs, const Context *ctx,
|
||||
const lite::Primitive *primitive)
|
||||
: LiteKernel(parameter, inputs, outputs, ctx, primitive), ctx_(ctx), thread_count_(ctx->thread_num_) {
|
||||
concat_param_ = reinterpret_cast<ConcatParameter *>(opParameter);
|
||||
concat_param_ = reinterpret_cast<ConcatParameter *>(op_parameter_);
|
||||
}
|
||||
|
||||
virtual ~ConcatBaseCPUKernel() = default;
|
||||
|
|
|
@ -77,8 +77,8 @@ void ConvolutionBaseCPUKernel::FreeQuantParam() {
|
|||
}
|
||||
|
||||
int ConvolutionBaseCPUKernel::Init() {
|
||||
auto input = this->inputs_.front();
|
||||
auto output = this->outputs_.front();
|
||||
auto input = this->in_tensors_.front();
|
||||
auto output = this->out_tensors_.front();
|
||||
conv_param_->input_batch_ = input->Batch();
|
||||
conv_param_->input_h_ = input->Height();
|
||||
conv_param_->input_w_ = input->Width();
|
||||
|
@ -118,9 +118,9 @@ int ConvolutionBaseCPUKernel::SetQuantParam() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
}
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto weight_tensor = inputs_.at(kWeightIndex);
|
||||
auto output_tensor = outputs_.at(kOutputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto weight_tensor = in_tensors_.at(kWeightIndex);
|
||||
auto output_tensor = out_tensors_.at(kOutputIndex);
|
||||
auto input_quant_arg = input_tensor->GetQuantParams().front();
|
||||
auto weight_quant_arg = weight_tensor->GetQuantParams().front();
|
||||
auto output_quant_arg = output_tensor->GetQuantParams().front();
|
||||
|
|
|
@ -40,8 +40,8 @@ class ConvolutionBaseCPUKernel : public LiteKernel {
|
|||
const std::vector<lite::tensor::Tensor *> &outputs, const Context *ctx,
|
||||
const lite::Primitive *primitive)
|
||||
: LiteKernel(parameter, inputs, outputs, ctx, primitive), ctx_(ctx), thread_count_(ctx->thread_num_) {
|
||||
opParameter->thread_num_ = ctx->thread_num_;
|
||||
conv_param_ = reinterpret_cast<ConvParameter *>(opParameter);
|
||||
op_parameter_->thread_num_ = ctx->thread_num_;
|
||||
conv_param_ = reinterpret_cast<ConvParameter *>(op_parameter_);
|
||||
}
|
||||
~ConvolutionBaseCPUKernel() override;
|
||||
|
||||
|
|
|
@ -34,27 +34,27 @@ namespace mindspore::kernel {
|
|||
int DepthToSpaceBaseCPUKernel::Init() { return RET_OK; }
|
||||
|
||||
int DepthToSpaceBaseCPUKernel::ReSize() {
|
||||
if (inputs_[0]->GetFormat() != schema::Format_NHWC) {
|
||||
if (in_tensors_[0]->GetFormat() != schema::Format_NHWC) {
|
||||
MS_LOG(ERROR) << "depth_to_space only support NHWC now!";
|
||||
return RET_FORMAT_ERR;
|
||||
}
|
||||
DepthToSpaceParameter *param = reinterpret_cast<DepthToSpaceParameter *>(opParameter);
|
||||
DepthToSpaceParameter *param = reinterpret_cast<DepthToSpaceParameter *>(op_parameter_);
|
||||
if (param->block_size_ <= 0) {
|
||||
MS_LOG(ERROR) << "Input block_size should > 0!";
|
||||
return RET_PARAM_INVALID;
|
||||
}
|
||||
auto shape_size = inputs_[0]->shape().size();
|
||||
auto shape_size = in_tensors_[0]->shape().size();
|
||||
if (shape_size != DIMENSION_4D) {
|
||||
MS_LOG(ERROR) << "Input shape size should be " << DIMENSION_4D;
|
||||
return RET_PARAM_INVALID;
|
||||
}
|
||||
int32_t in_strides[DIMENSION_4D];
|
||||
ComputeStrides(const_cast<int *>(inputs_[0]->shape().data()), in_strides, shape_size);
|
||||
ComputeStrides(const_cast<int *>(in_tensors_[0]->shape().data()), in_strides, shape_size);
|
||||
param->in_stride_dim0_ = in_strides[0];
|
||||
param->in_stride_dim1_ = in_strides[1];
|
||||
param->in_stride_dim2_ = in_strides[2];
|
||||
int32_t out_strides[DIMENSION_4D];
|
||||
ComputeStrides(const_cast<int *>(outputs_[0]->shape().data()), out_strides, shape_size);
|
||||
ComputeStrides(const_cast<int *>(out_tensors_[0]->shape().data()), out_strides, shape_size);
|
||||
param->out_stride_dim0_ = out_strides[0];
|
||||
param->out_stride_dim1_ = out_strides[1];
|
||||
param->out_stride_dim2_ = out_strides[2];
|
||||
|
|
|
@ -31,7 +31,7 @@ class FullconnectionBaseCPUKernel : public LiteKernel {
|
|||
const std::vector<lite::tensor::Tensor *> &outputs, const Context *ctx,
|
||||
const lite::Primitive *primitive)
|
||||
: LiteKernel(parameter, inputs, outputs, ctx, primitive), ctx_(ctx), thread_count_(ctx->thread_num_) {
|
||||
fc_param_ = reinterpret_cast<MatMulParameter *>(opParameter);
|
||||
fc_param_ = reinterpret_cast<MatMulParameter *>(op_parameter_);
|
||||
}
|
||||
~FullconnectionBaseCPUKernel() = default;
|
||||
|
||||
|
|
|
@ -59,4 +59,3 @@ LayoutConvertor LayoutTransform(TypeId data_type, schema::Format src_format, sch
|
|||
}
|
||||
}
|
||||
} // namespace mindspore::kernel
|
||||
|
||||
|
|
|
@ -38,4 +38,3 @@ LayoutConvertor LayoutTransform(TypeId data_type, schema::Format src_format, sch
|
|||
} // namespace mindspore::kernel
|
||||
|
||||
#endif // MINDSPORE_LITE_SRC_RUNTIME_KERNEL_ARM_BASE_LAYOUT_TRANSFORM_H_
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class MatmulBaseCPUKernel : public LiteKernel {
|
|||
const std::vector<lite::tensor::Tensor *> &outputs, const Context *ctx,
|
||||
const lite::Primitive *primitive)
|
||||
: LiteKernel(parameter, inputs, outputs, ctx, primitive), ctx_(ctx), thread_count_(ctx->thread_num_) {
|
||||
params_ = reinterpret_cast<MatMulParameter *>(opParameter);
|
||||
params_ = reinterpret_cast<MatMulParameter *>(op_parameter_);
|
||||
}
|
||||
~MatmulBaseCPUKernel() = default;
|
||||
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
namespace mindspore::kernel {
|
||||
Matrix *TransformMatrixGenerator(int m, int k) {
|
||||
auto matrix = new Matrix;
|
||||
auto aa = malloc(m * k * sizeof(float));
|
||||
auto aa = malloc(m * k * sizeof(float));
|
||||
matrix->SetData(aa);
|
||||
matrix->SetNum(m, k);
|
||||
// matrix->data_ = malloc(m * k * sizeof(float));
|
||||
// matrix->m_ = m;
|
||||
// matrix->k_ = k;
|
||||
// matrix->row_major_ = true;
|
||||
// matrix->data_ = malloc(m * k * sizeof(float));
|
||||
// matrix->m_ = m;
|
||||
// matrix->k_ = k;
|
||||
// matrix->row_major_ = true;
|
||||
return matrix;
|
||||
}
|
||||
|
||||
|
@ -80,4 +80,3 @@ void MatrixMultiply(const float *matrix_a, const float *matrix_b, float *matrix_
|
|||
}
|
||||
}
|
||||
} // namespace mindspore::kernel
|
||||
|
||||
|
|
|
@ -95,4 +95,3 @@ void MatrixMultiply(const float *matrix_a, const float *matrix_b, float *matrix_
|
|||
} // namespace mindspore::kernel
|
||||
|
||||
#endif // MINDSPORE_LITE_SRC_RUNTIME_KERNEL_ARM_BASE_MATRIX_H_
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@ int PoolingBaseCPUKernel::SetQuantParam() {
|
|||
pooling_quant_arg_ = reinterpret_cast<QuantArg **>(malloc(2 * sizeof(QuantArg *)));
|
||||
pooling_quant_arg_[0] = reinterpret_cast<QuantArg *>(malloc(sizeof(QuantArg)));
|
||||
pooling_quant_arg_[1] = reinterpret_cast<QuantArg *>(malloc(sizeof(QuantArg)));
|
||||
auto *input_tensor = inputs_.at(kInputIndex);
|
||||
auto *input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto in_quant_arg = input_tensor->GetQuantParams();
|
||||
auto *out_tensor = outputs_.at(kOutputIndex);
|
||||
auto *out_tensor = out_tensors_.at(kOutputIndex);
|
||||
auto out_quant_arg = out_tensor->GetQuantParams();
|
||||
pooling_quant_arg_[0][0].scale_ = in_quant_arg.front().scale;
|
||||
pooling_quant_arg_[0][0].zp_ = in_quant_arg.front().zeroPoint;
|
||||
|
@ -57,15 +57,15 @@ void PoolingBaseCPUKernel::FreeQuantParam() {
|
|||
|
||||
int PoolingBaseCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
MS_ASSERT(inputs_.size() == 1);
|
||||
MS_ASSERT(outputs_.size() == 1);
|
||||
MS_ASSERT(in_tensors_.size() == 1);
|
||||
MS_ASSERT(out_tensors_.size() == 1);
|
||||
pooling_param_->thread_num_ = thread_count_;
|
||||
MS_ASSERT(this->opParameter != nullptr);
|
||||
auto in_tensor = this->inputs_.front();
|
||||
auto out_tensor = this->outputs_.front();
|
||||
MS_ASSERT(this->op_parameter_ != nullptr);
|
||||
auto in_tensor = this->in_tensors_.front();
|
||||
auto out_tensor = this->out_tensors_.front();
|
||||
MS_ASSERT(in_tensor != nullptr);
|
||||
MS_ASSERT(out_tensor != nullptr);
|
||||
pooling_param_->input_batch_ = in_tensor->Batch();
|
||||
|
|
|
@ -32,7 +32,7 @@ class PoolingBaseCPUKernel : public LiteKernel {
|
|||
const std::vector<lite::tensor::Tensor *> &outputs, const Context *ctx,
|
||||
const lite::Primitive *primitive)
|
||||
: LiteKernel(parameter, inputs, outputs, ctx, primitive), ctx_(ctx), thread_count_(ctx->thread_num_) {
|
||||
pooling_param_ = reinterpret_cast<PoolingParameter *>(opParameter);
|
||||
pooling_param_ = reinterpret_cast<PoolingParameter *>(op_parameter_);
|
||||
}
|
||||
~PoolingBaseCPUKernel() = default;
|
||||
|
||||
|
|
|
@ -27,18 +27,18 @@ using mindspore::lite::RET_OK;
|
|||
using mindspore::schema::PrimitiveType_Prelu;
|
||||
|
||||
namespace mindspore::kernel {
|
||||
int PreluBaseCPUKernel::Init() {return RET_OK;}
|
||||
int PreluBaseCPUKernel::Init() { return RET_OK; }
|
||||
|
||||
kernel::LiteKernel *CpuPreluInt8KernelCreator(const std::vector<lite::tensor::Tensor *> &inputs,
|
||||
const std::vector<lite::tensor::Tensor *> &outputs,
|
||||
OpParameter *opParameter, const Context *ctx,
|
||||
const kernel::KernelKey &desc, const lite::Primitive *primitive) {
|
||||
const std::vector<lite::tensor::Tensor *> &outputs,
|
||||
OpParameter *opParameter, const Context *ctx,
|
||||
const kernel::KernelKey &desc, const lite::Primitive *primitive) {
|
||||
if (opParameter == nullptr) {
|
||||
MS_LOG(ERROR) << "Input opParameter is nullptr!";
|
||||
return nullptr;
|
||||
}
|
||||
MS_ASSERT(desc.type == schema::PrimitiveType_Prelu);
|
||||
auto *kernel = new(std::nothrow) PreluInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive);
|
||||
auto *kernel = new (std::nothrow) PreluInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive);
|
||||
if (kernel == nullptr) {
|
||||
MS_LOG(ERROR) << "new PreluCPUKernel fail!";
|
||||
return nullptr;
|
||||
|
@ -55,4 +55,3 @@ kernel::LiteKernel *CpuPreluInt8KernelCreator(const std::vector<lite::tensor::Te
|
|||
|
||||
REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Prelu, CpuPreluInt8KernelCreator)
|
||||
} // namespace mindspore::kernel
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ class PreluBaseCPUKernel : public LiteKernel {
|
|||
const std::vector<lite::tensor::Tensor *> &outputs, const Context *ctx,
|
||||
const lite::Primitive *primitive)
|
||||
: LiteKernel(parameter, inputs, outputs, ctx, primitive), ctx_(ctx), thread_count_(ctx->thread_num_) {
|
||||
opParameter->thread_num_ = ctx->thread_num_;
|
||||
prelu_param_ = reinterpret_cast<PreluParameter *>(opParameter);
|
||||
op_parameter_->thread_num_ = ctx->thread_num_;
|
||||
prelu_param_ = reinterpret_cast<PreluParameter *>(op_parameter_);
|
||||
}
|
||||
|
||||
~PreluBaseCPUKernel() = default;
|
||||
|
|
|
@ -41,11 +41,11 @@ int PriorBoxCPUKernel::Init() {
|
|||
}
|
||||
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
MS_ASSERT(inputs_.size() == kInputNum);
|
||||
MS_ASSERT(outputs_.size() == kOutputNum);
|
||||
MS_ASSERT(in_tensors_.size() == kInputNum);
|
||||
MS_ASSERT(out_tensors_.size() == kOutputNum);
|
||||
|
||||
auto ret = GeneratePriorBox();
|
||||
|
||||
|
@ -53,11 +53,11 @@ int PriorBoxCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int PriorBoxCPUKernel::GeneratePriorBox() {
|
||||
const int fmap_w = inputs_[0]->Width();
|
||||
const int fmap_h = inputs_[0]->Height();
|
||||
const int fmap_w = in_tensors_[0]->Width();
|
||||
const int fmap_h = in_tensors_[0]->Height();
|
||||
|
||||
const int image_w = prior_box_param_->image_size_w > 0 ? prior_box_param_->image_size_w : inputs_[1]->Width();
|
||||
const int image_h = prior_box_param_->image_size_h > 0 ? prior_box_param_->image_size_h : inputs_[1]->Height();
|
||||
const int image_w = prior_box_param_->image_size_w > 0 ? prior_box_param_->image_size_w : in_tensors_[1]->Width();
|
||||
const int image_h = prior_box_param_->image_size_h > 0 ? prior_box_param_->image_size_h : in_tensors_[1]->Height();
|
||||
|
||||
const float step_w =
|
||||
prior_box_param_->step_w > 0.0f ? prior_box_param_->step_w : static_cast<float>(image_w) / fmap_w;
|
||||
|
@ -128,7 +128,7 @@ int PriorBoxCPUKernel::GeneratePriorBox() {
|
|||
}
|
||||
|
||||
// variance
|
||||
for (auto i = 0; i < outputs_[0]->Height() / PRIOR_BOX_VAR_NUM; i++) {
|
||||
for (auto i = 0; i < out_tensors_[0]->Height() / PRIOR_BOX_VAR_NUM; i++) {
|
||||
for (auto j = 0; j < PRIOR_BOX_VAR_NUM; j++) {
|
||||
output_.emplace_back(prior_box_param_->variances[j]);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ int PriorBoxCPUKernel::GeneratePriorBox() {
|
|||
|
||||
int PriorBoxCPUKernel::PriorBoxImpl(int task_id) {
|
||||
auto src = output_.data();
|
||||
auto output = outputs_.at(0);
|
||||
auto output = out_tensors_.at(0);
|
||||
if (output == nullptr) {
|
||||
return RET_NULL_PTR;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class PriorBoxCPUKernel : public LiteKernel {
|
|||
const std::vector<lite::tensor::Tensor *> &outputs, const Context *ctx,
|
||||
const lite::Primitive *primitive)
|
||||
: LiteKernel(parameter, inputs, outputs, ctx, primitive), ctx_(ctx), thread_count_(ctx->thread_num_) {
|
||||
prior_box_param_ = reinterpret_cast<PriorBoxParameter *>(opParameter);
|
||||
prior_box_param_ = reinterpret_cast<PriorBoxParameter *>(op_parameter_);
|
||||
}
|
||||
~PriorBoxCPUKernel() = default;
|
||||
|
||||
|
|
|
@ -30,17 +30,17 @@ using mindspore::schema::PrimitiveType_QuantDTypeCast;
|
|||
|
||||
namespace mindspore::kernel {
|
||||
int QuantDTypeCastCPUKernel::Init() {
|
||||
if (inputs_.size() != 1) {
|
||||
MS_LOG(ERROR) << "inputs number should be 1, but " << inputs_.size() << " is given.";
|
||||
if (in_tensors_.size() != 1) {
|
||||
MS_LOG(ERROR) << "inputs number should be 1, but " << in_tensors_.size() << " is given.";
|
||||
return RET_PARAM_INVALID;
|
||||
}
|
||||
if (outputs_.size() != 1) {
|
||||
MS_LOG(ERROR) << "outputs number should be 1, but " << inputs_.size() << " is given.";
|
||||
if (out_tensors_.size() != 1) {
|
||||
MS_LOG(ERROR) << "outputs number should be 1, but " << out_tensors_.size() << " is given.";
|
||||
return RET_PARAM_INVALID;
|
||||
}
|
||||
auto in_tensor = inputs_.front();
|
||||
auto out_tensor = outputs_.front();
|
||||
auto param = reinterpret_cast<QuantDTypeCastParameter *>(opParameter);
|
||||
auto in_tensor = in_tensors_.front();
|
||||
auto out_tensor = out_tensors_.front();
|
||||
auto param = reinterpret_cast<QuantDTypeCastParameter *>(op_parameter_);
|
||||
if (param->srcT == kNumberTypeFloat32 && param->dstT == kNumberTypeInt8) {
|
||||
if (in_tensor->data_type() != kNumberTypeFloat32 || out_tensor->data_type() != kNumberTypeInt8) {
|
||||
MS_LOG(ERROR) << "param data type and tensor data type do not match.";
|
||||
|
@ -65,7 +65,7 @@ int QuantDTypeCastCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int QuantDTypeCastCPUKernel::ReSize() {
|
||||
auto in_tensor = inputs_.front();
|
||||
auto in_tensor = in_tensors_.front();
|
||||
num_unit_ = static_cast<int>(in_tensor->DataSize());
|
||||
thread_n_num_ = MSMIN(thread_num_, num_unit_);
|
||||
thread_n_stride_ = UP_DIV(num_unit_, thread_n_num_);
|
||||
|
@ -78,7 +78,7 @@ int QuantDTypeCastCPUKernel::QuantDTypeCast(int task_id) {
|
|||
return RET_OK;
|
||||
}
|
||||
int thread_offset = task_id * thread_n_stride_;
|
||||
auto quant_arg = inputs_.front()->GetQuantParams().front();
|
||||
auto quant_arg = in_tensors_.front()->GetQuantParams().front();
|
||||
int ret;
|
||||
if (inverse_) {
|
||||
ret = DequantizeInt8(int8_ptr_ + thread_offset, float32_ptr_ + thread_offset, quant_arg.scale, quant_arg.zeroPoint,
|
||||
|
@ -111,11 +111,11 @@ int QuantDTypeCastCPUKernel::Run() {
|
|||
return prepare_ret;
|
||||
}
|
||||
if (inverse_) {
|
||||
int8_ptr_ = reinterpret_cast<int8_t *>(inputs_[0]->Data());
|
||||
float32_ptr_ = reinterpret_cast<float *>(outputs_[0]->Data());
|
||||
int8_ptr_ = reinterpret_cast<int8_t *>(in_tensors_[0]->Data());
|
||||
float32_ptr_ = reinterpret_cast<float *>(out_tensors_[0]->Data());
|
||||
} else {
|
||||
float32_ptr_ = reinterpret_cast<float *>(inputs_[0]->Data());
|
||||
int8_ptr_ = reinterpret_cast<int8_t *>(outputs_[0]->Data());
|
||||
float32_ptr_ = reinterpret_cast<float *>(in_tensors_[0]->Data());
|
||||
int8_ptr_ = reinterpret_cast<int8_t *>(out_tensors_[0]->Data());
|
||||
}
|
||||
|
||||
int ret = LiteBackendParallelLaunch(QuantDTypeCastRun, this, thread_n_num_);
|
||||
|
|
|
@ -30,7 +30,7 @@ class ReshapeBaseCPUKernel : public LiteKernel {
|
|||
const std::vector<lite::tensor::Tensor *> &outputs, const Context *ctx,
|
||||
const lite::Primitive *primitive)
|
||||
: LiteKernel(parameter, inputs, outputs, ctx, primitive), ctx_(ctx) {
|
||||
reshape_param_ = reinterpret_cast<ReshapeParameter *>(opParameter);
|
||||
reshape_param_ = reinterpret_cast<ReshapeParameter *>(op_parameter_);
|
||||
}
|
||||
~ReshapeBaseCPUKernel() = default;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ constexpr int kRank = 4;
|
|||
} // namespace
|
||||
|
||||
int ResizeBaseCPUKernel::CheckParameters() {
|
||||
auto parameter = reinterpret_cast<ResizeParameter *>(opParameter);
|
||||
auto parameter = reinterpret_cast<ResizeParameter *>(op_parameter_);
|
||||
if (parameter == nullptr) {
|
||||
MS_LOG(ERROR) << "cast ResizeParameter failed.";
|
||||
return RET_NULL_PTR;
|
||||
|
@ -65,19 +65,19 @@ int ResizeBaseCPUKernel::CheckParameters() {
|
|||
}
|
||||
|
||||
int ResizeBaseCPUKernel::CheckInputsOuputs() {
|
||||
if (inputs_.size() != kInputNum) {
|
||||
MS_LOG(ERROR) << "Resize input num should be " << kInputNum << ", but got " << inputs_.size();
|
||||
if (in_tensors_.size() != kInputNum) {
|
||||
MS_LOG(ERROR) << "Resize input num should be " << kInputNum << ", but got " << in_tensors_.size();
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto input = inputs_.at(0);
|
||||
auto input = in_tensors_.at(0);
|
||||
if (input == nullptr) {
|
||||
return RET_NULL_PTR;
|
||||
}
|
||||
if (outputs_.size() != kOutputNum) {
|
||||
MS_LOG(ERROR) << "Resize output num should be " << kOutputNum << ", but got " << outputs_.size();
|
||||
if (out_tensors_.size() != kOutputNum) {
|
||||
MS_LOG(ERROR) << "Resize output num should be " << kOutputNum << ", but got " << out_tensors_.size();
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto output = outputs_.at(0);
|
||||
auto output = out_tensors_.at(0);
|
||||
if (output == nullptr) {
|
||||
return RET_NULL_PTR;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ int ResizeBaseCPUKernel::Init() {
|
|||
return ret;
|
||||
}
|
||||
|
||||
auto input = inputs_.at(0);
|
||||
auto input = in_tensors_.at(0);
|
||||
auto input_shape = input->shape();
|
||||
if (input_shape.size() != kRank) {
|
||||
MS_LOG(ERROR) << "Resize op support input rank 4, got " << input_shape.size();
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
using mindspore::lite::KernelRegistrar;
|
||||
using mindspore::lite::RET_ERROR;
|
||||
using mindspore::lite::RET_OK;
|
||||
using mindspore::lite::RET_NULL_PTR;
|
||||
using mindspore::lite::RET_OK;
|
||||
using mindspore::schema::PrimitiveType_SoftMax;
|
||||
|
||||
namespace mindspore::kernel {
|
||||
|
@ -40,7 +40,7 @@ int SoftmaxBaseCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int SoftmaxBaseCPUKernel::ReSize() {
|
||||
auto input_tensor = inputs_.front();
|
||||
auto input_tensor = in_tensors_.front();
|
||||
auto in_shape = input_tensor->shape();
|
||||
auto in_dims = in_shape.size();
|
||||
int ele_size = 1;
|
||||
|
|
|
@ -28,7 +28,7 @@ class SoftmaxBaseCPUKernel : public LiteKernel {
|
|||
const std::vector<lite::tensor::Tensor *> &outputs, const lite::Context *ctx,
|
||||
const lite::Primitive *primitive)
|
||||
: LiteKernel(parameter, inputs, outputs, ctx, primitive), ctx_(ctx), thread_count_(ctx->thread_num_) {
|
||||
softmax_param_ = reinterpret_cast<SoftmaxParameter *>(opParameter);
|
||||
softmax_param_ = reinterpret_cast<SoftmaxParameter *>(op_parameter_);
|
||||
}
|
||||
~SoftmaxBaseCPUKernel() = default;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace mindspore::kernel {
|
|||
int SplitBaseCPUKernel::Init() { return RET_OK; }
|
||||
|
||||
int SplitBaseCPUKernel::ReSize() {
|
||||
auto in_tensor = inputs_.front();
|
||||
auto in_tensor = in_tensors_.front();
|
||||
auto input_shape = in_tensor->shape();
|
||||
|
||||
param->strides_[input_shape.size() - 1] = 1;
|
||||
|
@ -61,9 +61,9 @@ int SplitBaseCPUKernel::ReSize() {
|
|||
}
|
||||
|
||||
kernel::LiteKernel *CpuSplitInt8KernelCreator(const std::vector<lite::tensor::Tensor *> &inputs,
|
||||
const std::vector<lite::tensor::Tensor *> &outputs,
|
||||
OpParameter *opParameter, const Context *ctx,
|
||||
const kernel::KernelKey &desc, const lite::Primitive *primitive) {
|
||||
const std::vector<lite::tensor::Tensor *> &outputs,
|
||||
OpParameter *opParameter, const Context *ctx,
|
||||
const kernel::KernelKey &desc, const lite::Primitive *primitive) {
|
||||
if (opParameter == nullptr) {
|
||||
MS_LOG(ERROR) << "Input opParameter is nullptr!";
|
||||
return nullptr;
|
||||
|
@ -85,9 +85,9 @@ kernel::LiteKernel *CpuSplitInt8KernelCreator(const std::vector<lite::tensor::Te
|
|||
}
|
||||
|
||||
kernel::LiteKernel *CpuSplitInt32KernelCreator(const std::vector<lite::tensor::Tensor *> &inputs,
|
||||
const std::vector<lite::tensor::Tensor *> &outputs,
|
||||
OpParameter *opParameter, const Context *ctx,
|
||||
const kernel::KernelKey &desc, const lite::Primitive *primitive) {
|
||||
const std::vector<lite::tensor::Tensor *> &outputs,
|
||||
OpParameter *opParameter, const Context *ctx,
|
||||
const kernel::KernelKey &desc, const lite::Primitive *primitive) {
|
||||
if (opParameter == nullptr) {
|
||||
MS_LOG(ERROR) << "Input opParameter is nullptr!";
|
||||
return nullptr;
|
||||
|
@ -109,9 +109,9 @@ kernel::LiteKernel *CpuSplitInt32KernelCreator(const std::vector<lite::tensor::T
|
|||
}
|
||||
|
||||
kernel::LiteKernel *CpuSplitFp32KernelCreator(const std::vector<lite::tensor::Tensor *> &inputs,
|
||||
const std::vector<lite::tensor::Tensor *> &outputs,
|
||||
OpParameter *opParameter, const Context *ctx,
|
||||
const kernel::KernelKey &desc, const lite::Primitive *primitive) {
|
||||
const std::vector<lite::tensor::Tensor *> &outputs,
|
||||
OpParameter *opParameter, const Context *ctx,
|
||||
const kernel::KernelKey &desc, const lite::Primitive *primitive) {
|
||||
if (opParameter == nullptr) {
|
||||
MS_LOG(ERROR) << "Input opParameter is nullptr!";
|
||||
return nullptr;
|
||||
|
|
|
@ -27,10 +27,10 @@ namespace mindspore::kernel {
|
|||
class SplitBaseCPUKernel : public LiteKernel {
|
||||
public:
|
||||
SplitBaseCPUKernel(OpParameter *parameter, const std::vector<lite::tensor::Tensor *> &inputs,
|
||||
const std::vector<lite::tensor::Tensor *> &outputs, const Context *ctx,
|
||||
const lite::Primitive *primitive)
|
||||
: LiteKernel(parameter, inputs, outputs, ctx, primitive), ctx_(ctx), thread_count_(ctx->thread_num_) {
|
||||
param = reinterpret_cast<SplitParameter *>(opParameter);
|
||||
const std::vector<lite::tensor::Tensor *> &outputs, const Context *ctx,
|
||||
const lite::Primitive *primitive)
|
||||
: LiteKernel(parameter, inputs, outputs, ctx, primitive), ctx_(ctx), thread_count_(ctx->thread_num_) {
|
||||
param = reinterpret_cast<SplitParameter *>(op_parameter_);
|
||||
}
|
||||
~SplitBaseCPUKernel() = default;
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ int StridedSliceCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int StridedSliceCPUKernel::ReSize() {
|
||||
auto input = inputs_.at(0);
|
||||
auto parameter = reinterpret_cast<StridedSliceParameter *>(opParameter);
|
||||
auto input = in_tensors_.at(0);
|
||||
auto parameter = reinterpret_cast<StridedSliceParameter *>(op_parameter_);
|
||||
MS_ASSERT(input);
|
||||
MS_ASSERT(parameter);
|
||||
parameter->data_type = input->data_type() == kNumberTypeInt8 ? kDataTypeInt8 : kDataTypeFloat;
|
||||
|
@ -54,12 +54,12 @@ int StridedSliceCPUKernel::Run() {
|
|||
return ret;
|
||||
}
|
||||
|
||||
auto input = inputs_.at(0);
|
||||
auto output = outputs_.at(0);
|
||||
auto input = in_tensors_.at(0);
|
||||
auto output = out_tensors_.at(0);
|
||||
MS_ASSERT(input);
|
||||
MS_ASSERT(output);
|
||||
|
||||
ret = DoStridedSlice(input->Data(), output->Data(), reinterpret_cast<StridedSliceParameter *>(opParameter));
|
||||
ret = DoStridedSlice(input->Data(), output->Data(), reinterpret_cast<StridedSliceParameter *>(op_parameter_));
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "StridedSlice error error_code[" << ret << "]";
|
||||
return RET_ERROR;
|
||||
|
|
|
@ -63,7 +63,7 @@ int Convolution3x3FP16CPUKernel::InitWeightBias() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
memset(transformed_filter_addr_, 0, transformed_size);
|
||||
float *origin_weight = reinterpret_cast<float *>(inputs_.at(kWeightIndex)->Data());
|
||||
float *origin_weight = reinterpret_cast<float *>(in_tensors_.at(kWeightIndex)->Data());
|
||||
size_t fp16_weight_size = input_channel * output_channel * kernel_h * kernel_w * sizeof(float16_t);
|
||||
fp16_weight_ = reinterpret_cast<float16_t *>(malloc(fp16_weight_size));
|
||||
if (fp16_weight_ == nullptr) {
|
||||
|
@ -85,8 +85,8 @@ int Convolution3x3FP16CPUKernel::InitWeightBias() {
|
|||
}
|
||||
memset(bias_data_, 0, new_bias_size);
|
||||
auto fp16_bias_data = reinterpret_cast<float16_t *>(bias_data_);
|
||||
if (inputs_.size() == kInputSize2) {
|
||||
auto ori_bias_addr = reinterpret_cast<float *>(inputs_.at(kBiasIndex)->Data());
|
||||
if (in_tensors_.size() == kInputSize2) {
|
||||
auto ori_bias_addr = reinterpret_cast<float *>(in_tensors_.at(kBiasIndex)->Data());
|
||||
for (int i = 0; i < output_channel; ++i) {
|
||||
fp16_bias_data[i] = (float16_t)ori_bias_addr[i];
|
||||
}
|
||||
|
@ -131,8 +131,7 @@ int Convolution3x3FP16CPUKernel::InitTmpBuffer() {
|
|||
|
||||
/*=============================tmp_out_============================*/
|
||||
int new_out_plane = UP_DIV(conv_param_->output_h_, C4NUM) * UP_DIV(conv_param_->output_w_, C4NUM) * C4NUM * C4NUM;
|
||||
size_t tmp_out_size =
|
||||
oC8 * C8NUM * conv_param_->output_batch_ * new_out_plane * sizeof(float16_t);
|
||||
size_t tmp_out_size = oC8 * C8NUM * conv_param_->output_batch_ * new_out_plane * sizeof(float16_t);
|
||||
tmp_out_ = reinterpret_cast<float16_t *>(malloc(tmp_out_size));
|
||||
if (tmp_out_ == nullptr) {
|
||||
MS_LOG(ERROR) << "malloc tmp_out_ failed.";
|
||||
|
@ -172,7 +171,7 @@ int Convolution3x3FP16CPUKernel::InitTmpBuffer() {
|
|||
}
|
||||
|
||||
void Convolution3x3FP16CPUKernel::ConfigInputOutput() {
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto input_format = input_tensor->GetFormat();
|
||||
schema::Format execute_format = schema::Format_NHWC4;
|
||||
convert_func_ = LayoutTransformFp16(input_format, execute_format);
|
||||
|
@ -184,7 +183,7 @@ void Convolution3x3FP16CPUKernel::ConfigInputOutput() {
|
|||
|
||||
int Convolution3x3FP16CPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
auto ret = ConvolutionBaseCPUKernel::Init();
|
||||
|
@ -265,7 +264,7 @@ int Convolution3x3FP16CPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto ori_input_data = reinterpret_cast<float *>(input_tensor->Data());
|
||||
for (int i = 0; i < input_tensor->ElementsNum(); ++i) {
|
||||
fp16_input_[i] = (float16_t)ori_input_data[i];
|
||||
|
@ -284,10 +283,10 @@ int Convolution3x3FP16CPUKernel::Run() {
|
|||
}
|
||||
|
||||
// cast fp16 out to fp32 data
|
||||
auto out_tensor = outputs_.at(kOutputIndex);
|
||||
auto out_tensor = out_tensors_.at(kOutputIndex);
|
||||
auto output_addr = reinterpret_cast<float *>(out_tensor->Data());
|
||||
for (int j = 0; j < out_tensor->ElementsNum(); ++j) {
|
||||
output_addr[j] = static_cast<float >(fp16_out_[j]);
|
||||
output_addr[j] = static_cast<float>(fp16_out_[j]);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class Convolution3x3FP16CPUKernel : public ConvolutionBaseCPUKernel {
|
|||
free(fp16_weight_);
|
||||
}
|
||||
if (fp16_out_ != nullptr) {
|
||||
free(fp16_out_);
|
||||
free(fp16_out_);
|
||||
}
|
||||
if (transformed_filter_addr_ != nullptr) {
|
||||
free(transformed_filter_addr_);
|
||||
|
|
|
@ -68,7 +68,7 @@ int ConvolutionDepthwiseFp16CPUKernel::InitBuffer() {
|
|||
int ConvolutionDepthwiseFp16CPUKernel::InitWeightBias() {
|
||||
// init weight: o, h, w, i; o == group, i == 1
|
||||
int OC8 = UP_DIV(conv_param_->output_channel_, C8NUM);
|
||||
auto weight_tensor = inputs_[kWeightIndex];
|
||||
auto weight_tensor = in_tensors_[kWeightIndex];
|
||||
auto origin_weight = reinterpret_cast<float *>(weight_tensor->Data());
|
||||
int pack_weight_size = C8NUM * OC8 * conv_param_->kernel_h_ * conv_param_->kernel_w_;
|
||||
|
||||
|
@ -89,8 +89,8 @@ int ConvolutionDepthwiseFp16CPUKernel::InitWeightBias() {
|
|||
}
|
||||
memset(bias_data_, 0, C8NUM * OC8 * sizeof(float16_t));
|
||||
auto bias_fp16 = reinterpret_cast<float16_t *>(bias_data_);
|
||||
if (inputs_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(inputs_.at(kBiasIndex)->Data());
|
||||
if (in_tensors_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(in_tensors_.at(kBiasIndex)->Data());
|
||||
for (int i = 0; i < conv_param_->output_channel_; i++) {
|
||||
bias_fp16[i] = (float16_t)ori_bias[i];
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ int ConvolutionDepthwiseFp16CPUKernel::InitWeightBias() {
|
|||
|
||||
int ConvolutionDepthwiseFp16CPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
// conv base init
|
||||
|
@ -176,7 +176,7 @@ int ConvolutionDepthwiseFp16CPUKernel::Run() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto input_addr = reinterpret_cast<float *>(input_tensor->Data());
|
||||
// pack input: to nhwc8
|
||||
PackNHWCFp32ToNHWC8Fp16(input_addr, packed_input_, conv_param_->input_batch_,
|
||||
|
@ -188,7 +188,7 @@ int ConvolutionDepthwiseFp16CPUKernel::Run() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
|
||||
auto output_addr = reinterpret_cast<float *>(outputs_.at(kOutputIndex)->Data());
|
||||
auto output_addr = reinterpret_cast<float *>(out_tensors_.at(kOutputIndex)->Data());
|
||||
PackNHWC8Fp16ToNHWCFp32(packed_output_, output_addr, conv_param_->output_batch_,
|
||||
conv_param_->output_h_ * conv_param_->output_w_, conv_param_->output_channel_);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ int ConvolutionFP16CPUKernel::InitWeightBias() {
|
|||
int pack_weight_size = oc8 * ic4 * C8NUM * C4NUM * kernel_plane;
|
||||
|
||||
// init weight
|
||||
float *origin_weight = reinterpret_cast<float *>(inputs_.at(kWeightIndex)->Data());
|
||||
float *origin_weight = reinterpret_cast<float *>(in_tensors_.at(kWeightIndex)->Data());
|
||||
size_t fp16_weight_size = in_channel * out_channel * kernel_h * kernel_w * sizeof(float16_t);
|
||||
fp16_weight_ = reinterpret_cast<float16_t *>(malloc(fp16_weight_size));
|
||||
if (fp16_weight_ == nullptr) {
|
||||
|
@ -70,8 +70,8 @@ int ConvolutionFP16CPUKernel::InitWeightBias() {
|
|||
}
|
||||
memset(bias_data_, 0, oc8 * C8NUM * sizeof(float16_t));
|
||||
auto fp16_bias_data = reinterpret_cast<float16_t *>(bias_data_);
|
||||
if (inputs_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(inputs_.at(kBiasIndex)->Data());
|
||||
if (in_tensors_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(in_tensors_.at(kBiasIndex)->Data());
|
||||
for (int i = 0; i < out_channel; ++i) {
|
||||
fp16_bias_data[i] = (float16_t)ori_bias[i];
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ int ConvolutionFP16CPUKernel::InitTmpBuffer() {
|
|||
}
|
||||
|
||||
void ConvolutionFP16CPUKernel::ConfigInputOutput() {
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto input_format = input_tensor->GetFormat();
|
||||
schema::Format execute_format = schema::Format_NHWC4;
|
||||
convert_func_ = LayoutTransformFp16(input_format, execute_format);
|
||||
|
@ -155,7 +155,7 @@ void ConvolutionFP16CPUKernel::ConfigInputOutput() {
|
|||
|
||||
int ConvolutionFP16CPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
auto ret = ConvolutionBaseCPUKernel::Init();
|
||||
|
@ -229,7 +229,7 @@ int ConvolutionFP16CPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto ori_input_data = reinterpret_cast<float *>(input_tensor->Data());
|
||||
for (int i = 0; i < input_tensor->ElementsNum(); ++i) {
|
||||
fp16_input_[i] = (float16_t)ori_input_data[i];
|
||||
|
@ -248,7 +248,7 @@ int ConvolutionFP16CPUKernel::Run() {
|
|||
}
|
||||
|
||||
// cast fp16 out to fp32 data
|
||||
auto out_tensor = outputs_.at(kOutputIndex);
|
||||
auto out_tensor = out_tensors_.at(kOutputIndex);
|
||||
auto output_addr = reinterpret_cast<float *>(out_tensor->Data());
|
||||
for (int j = 0; j < out_tensor->ElementsNum(); ++j) {
|
||||
output_addr[j] = static_cast<float>(fp16_out_[j]);
|
||||
|
@ -293,8 +293,8 @@ kernel::LiteKernel *CpuConvFp16KernelCreator(const std::vector<lite::tensor::Ten
|
|||
auto ret = kernel->Init();
|
||||
if (ret != RET_OK) {
|
||||
delete kernel;
|
||||
MS_LOG(INFO) << "Init fp16 kernel failed, name: " << opParameter->name_ << ", type: "
|
||||
<< schema::EnumNamePrimitiveType(static_cast<schema::PrimitiveType>(opParameter->type_));
|
||||
MS_LOG(INFO) << "Init fp16 kernel failed, name: " << opParameter->name_
|
||||
<< ", type: " << schema::EnumNamePrimitiveType(static_cast<schema::PrimitiveType>(opParameter->type_));
|
||||
return nullptr;
|
||||
}
|
||||
return kernel;
|
||||
|
|
|
@ -45,14 +45,14 @@ DeconvolutionDepthwiseFp16CPUKernel::~DeconvolutionDepthwiseFp16CPUKernel() {
|
|||
}
|
||||
|
||||
int DeconvolutionDepthwiseFp16CPUKernel::InitSlideParam() {
|
||||
conv_param_->input_batch_ = outputs_.front()->shape().at(kNHWC_N);
|
||||
conv_param_->input_h_ = outputs_.front()->shape().at(kNHWC_H);
|
||||
conv_param_->input_w_ = outputs_.front()->shape().at(kNHWC_W);
|
||||
conv_param_->input_channel_ = outputs_.front()->shape().at(kNHWC_C);
|
||||
conv_param_->output_batch_ = inputs_.front()->shape().at(kNHWC_N);
|
||||
conv_param_->output_h_ = inputs_.front()->shape().at(kNHWC_H);
|
||||
conv_param_->output_w_ = inputs_.front()->shape().at(kNHWC_W);
|
||||
conv_param_->output_channel_ = inputs_.front()->shape().at(kNHWC_C);
|
||||
conv_param_->input_batch_ = out_tensors_.front()->shape().at(kNHWC_N);
|
||||
conv_param_->input_h_ = out_tensors_.front()->shape().at(kNHWC_H);
|
||||
conv_param_->input_w_ = out_tensors_.front()->shape().at(kNHWC_W);
|
||||
conv_param_->input_channel_ = out_tensors_.front()->shape().at(kNHWC_C);
|
||||
conv_param_->output_batch_ = in_tensors_.front()->shape().at(kNHWC_N);
|
||||
conv_param_->output_h_ = in_tensors_.front()->shape().at(kNHWC_H);
|
||||
conv_param_->output_w_ = in_tensors_.front()->shape().at(kNHWC_W);
|
||||
conv_param_->output_channel_ = in_tensors_.front()->shape().at(kNHWC_C);
|
||||
|
||||
// init sliding_ window param
|
||||
InitSlidingParam(sliding_, conv_param_, C8NUM);
|
||||
|
@ -83,7 +83,7 @@ int DeconvolutionDepthwiseFp16CPUKernel::InitBuffer() {
|
|||
int DeconvolutionDepthwiseFp16CPUKernel::InitWeightBias() {
|
||||
// init weight: o, h, w, i; o == group, i == 1
|
||||
int OC8 = UP_DIV(conv_param_->output_channel_, C8NUM);
|
||||
auto weight_tensor = inputs_[kWeightIndex];
|
||||
auto weight_tensor = in_tensors_[kWeightIndex];
|
||||
auto origin_weight = reinterpret_cast<float *>(weight_tensor->Data());
|
||||
int pack_weight_size = C8NUM * OC8 * conv_param_->kernel_h_ * conv_param_->kernel_w_;
|
||||
|
||||
|
@ -103,8 +103,8 @@ int DeconvolutionDepthwiseFp16CPUKernel::InitWeightBias() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
memset(bias_data_, 0, C8NUM * OC8 * sizeof(float16_t));
|
||||
if (inputs_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(inputs_.at(kBiasIndex)->Data());
|
||||
if (in_tensors_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(in_tensors_.at(kBiasIndex)->Data());
|
||||
for (int i = 0; i < conv_param_->output_channel_; i++) {
|
||||
reinterpret_cast<float *>(bias_data_)[i] = (float16_t)ori_bias[i];
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ int DeconvolutionDepthwiseFp16CPUKernel::InitWeightBias() {
|
|||
|
||||
int DeconvolutionDepthwiseFp16CPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
sliding_ = new SlidingWindowParam;
|
||||
|
@ -124,7 +124,7 @@ int DeconvolutionDepthwiseFp16CPUKernel::Init() {
|
|||
// conv base init
|
||||
auto ret = ConvolutionBaseCPUKernel::Init();
|
||||
if (ret != RET_OK) {
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = InitWeightBias();
|
||||
|
@ -189,7 +189,7 @@ int DeconvolutionDepthwiseFp16CPUKernel::Run() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto input_addr = reinterpret_cast<float *>(input_tensor->Data());
|
||||
// pack input: to nhwc8
|
||||
PackNHWCFp32ToNHWC8Fp16(input_addr, packed_input_, conv_param_->input_batch_,
|
||||
|
@ -201,7 +201,7 @@ int DeconvolutionDepthwiseFp16CPUKernel::Run() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
|
||||
auto output_addr = reinterpret_cast<float *>(outputs_.at(kOutputIndex)->Data());
|
||||
auto output_addr = reinterpret_cast<float *>(out_tensors_.at(kOutputIndex)->Data());
|
||||
PackNHWC8Fp16ToNHWCFp32(packed_output_, output_addr, conv_param_->output_batch_,
|
||||
conv_param_->output_h_ * conv_param_->output_w_, conv_param_->output_channel_);
|
||||
return RET_OK;
|
||||
|
|
|
@ -20,20 +20,20 @@
|
|||
|
||||
namespace mindspore::kernel {
|
||||
LayoutConvertor LayoutTransformFp16(schema::Format src_format, schema::Format dst_format) {
|
||||
if (src_format == schema::Format_NHWC && dst_format == schema::Format_NC4HW4) {
|
||||
return PackNHWCToNC4HW4Fp16;
|
||||
} else if (src_format == schema::Format_NHWC && dst_format == schema::Format_NHWC4) {
|
||||
return PackNHWCToNHWC4Fp16;
|
||||
} else if (src_format == schema::Format_NC4HW4 && dst_format == schema::Format_NHWC4) {
|
||||
return PackNC4HW4ToNHWC4Fp16;
|
||||
} else if (src_format == schema::Format_NCHW && dst_format == schema::Format_NC4HW4) {
|
||||
return PackNCHWToNC4HW4Fp16;
|
||||
} else if (src_format == schema::Format_NC4HW4 && dst_format == schema::Format_NHWC) {
|
||||
return PackNC4HW4ToNHWCFp16;
|
||||
} else {
|
||||
MS_LOG(ERROR) << "Unsupported transform from " << schema::EnumNameFormat(src_format) << " to "
|
||||
<< schema::EnumNameFormat(dst_format);
|
||||
return nullptr;
|
||||
}
|
||||
if (src_format == schema::Format_NHWC && dst_format == schema::Format_NC4HW4) {
|
||||
return PackNHWCToNC4HW4Fp16;
|
||||
} else if (src_format == schema::Format_NHWC && dst_format == schema::Format_NHWC4) {
|
||||
return PackNHWCToNHWC4Fp16;
|
||||
} else if (src_format == schema::Format_NC4HW4 && dst_format == schema::Format_NHWC4) {
|
||||
return PackNC4HW4ToNHWC4Fp16;
|
||||
} else if (src_format == schema::Format_NCHW && dst_format == schema::Format_NC4HW4) {
|
||||
return PackNCHWToNC4HW4Fp16;
|
||||
} else if (src_format == schema::Format_NC4HW4 && dst_format == schema::Format_NHWC) {
|
||||
return PackNC4HW4ToNHWCFp16;
|
||||
} else {
|
||||
MS_LOG(ERROR) << "Unsupported transform from " << schema::EnumNameFormat(src_format) << " to "
|
||||
<< schema::EnumNameFormat(dst_format);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
} // namespace mindspore::kernel
|
||||
|
|
|
@ -37,9 +37,9 @@ int ActivationCPUKernel::Init() { return RET_OK; }
|
|||
int ActivationCPUKernel::ReSize() { return RET_OK; }
|
||||
|
||||
int ActivationCPUKernel::DoActivation(int task_id) {
|
||||
auto input_addr = reinterpret_cast<float *>(inputs_.at(0)->Data());
|
||||
auto output_addr = reinterpret_cast<float *>(outputs_.at(0)->Data());
|
||||
auto length = inputs_.at(0)->ElementsNum();
|
||||
auto input_addr = reinterpret_cast<float *>(in_tensors_.at(0)->Data());
|
||||
auto output_addr = reinterpret_cast<float *>(out_tensors_.at(0)->Data());
|
||||
auto length = in_tensors_.at(0)->ElementsNum();
|
||||
|
||||
int stride = UP_DIV(length, thread_count_);
|
||||
int count = MSMIN(stride, length - stride * task_id);
|
||||
|
|
|
@ -43,7 +43,7 @@ int AddNCPUKernel::Init() { return RET_OK; }
|
|||
int AddNCPUKernel::ReSize() { return RET_OK; }
|
||||
|
||||
int AddNCPUKernel::AddNParallelRun(int thread_id) {
|
||||
int count_per_thread = UP_DIV(elements_num_, opParameter->thread_num_);
|
||||
int count_per_thread = UP_DIV(elements_num_, op_parameter_->thread_num_);
|
||||
int count = MSMIN(count_per_thread, elements_num_ - thread_id * count_per_thread);
|
||||
auto stride = count_per_thread * thread_id;
|
||||
auto ret = ElementAdd(in1_addr_ + stride, in2_addr_ + stride, out_addr_ + stride, count);
|
||||
|
@ -60,29 +60,29 @@ int AddNCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << ret;
|
||||
return ret;
|
||||
}
|
||||
elements_num_ = inputs_[0]->ElementsNum();
|
||||
auto input0_data = reinterpret_cast<float *>(inputs_[0]->Data());
|
||||
auto input1_data = reinterpret_cast<float *>(inputs_[1]->Data());
|
||||
auto output_data = reinterpret_cast<float *>(outputs_[0]->Data());
|
||||
if (elements_num_ < opParameter->thread_num_) {
|
||||
elements_num_ = in_tensors_[0]->ElementsNum();
|
||||
auto input0_data = reinterpret_cast<float *>(in_tensors_[0]->Data());
|
||||
auto input1_data = reinterpret_cast<float *>(in_tensors_[1]->Data());
|
||||
auto output_data = reinterpret_cast<float *>(out_tensors_[0]->Data());
|
||||
if (elements_num_ < op_parameter_->thread_num_) {
|
||||
ElementAdd(input0_data, input1_data, output_data, elements_num_);
|
||||
for (int i = 2; i < inputs_.size(); ++i) {
|
||||
ElementAdd(reinterpret_cast<float *>(inputs_[i]->Data()), output_data, output_data, elements_num_);
|
||||
for (int i = 2; i < in_tensors_.size(); ++i) {
|
||||
ElementAdd(reinterpret_cast<float *>(in_tensors_[i]->Data()), output_data, output_data, elements_num_);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
in1_addr_ = input0_data;
|
||||
in2_addr_ = input1_data;
|
||||
out_addr_ = output_data;
|
||||
ret = LiteBackendParallelLaunch(AddNLaunch, this, opParameter->thread_num_);
|
||||
ret = LiteBackendParallelLaunch(AddNLaunch, this, op_parameter_->thread_num_);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "addn launch fail!ret: " << ret;
|
||||
return RET_ERROR;
|
||||
}
|
||||
for (size_t i = 2; i < inputs_.size(); ++i) {
|
||||
in1_addr_ = reinterpret_cast<float *>(inputs_[i]->Data());
|
||||
for (size_t i = 2; i < in_tensors_.size(); ++i) {
|
||||
in1_addr_ = reinterpret_cast<float *>(in_tensors_[i]->Data());
|
||||
in2_addr_ = output_data;
|
||||
ret = LiteBackendParallelLaunch(AddNLaunch, this, opParameter->thread_num_);
|
||||
ret = LiteBackendParallelLaunch(AddNLaunch, this, op_parameter_->thread_num_);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "addn launch fail!ret: " << ret << ", input index: " << i;
|
||||
return RET_ERROR;
|
||||
|
|
|
@ -34,7 +34,7 @@ int ArgMinMaxCPUKernel::Init() {
|
|||
if (ret != RET_OK) {
|
||||
return ret;
|
||||
}
|
||||
auto param = reinterpret_cast<ArgMinMaxParameter *>(opParameter);
|
||||
auto param = reinterpret_cast<ArgMinMaxParameter *>(op_parameter_);
|
||||
param->data_type_ = kNumberTypeFloat32;
|
||||
if (!InferShapeDone()) {
|
||||
return RET_OK;
|
||||
|
|
|
@ -53,7 +53,7 @@ int ArithmeticCPUKernel::Init() {
|
|||
|
||||
int ArithmeticCPUKernel::ReSize() {
|
||||
FreeTileData();
|
||||
auto element_num = outputs_[0]->ElementsNum();
|
||||
auto element_num = out_tensors_[0]->ElementsNum();
|
||||
|
||||
tile_data0_ = new float[element_num];
|
||||
tile_data1_ = new float[element_num];
|
||||
|
@ -61,10 +61,10 @@ int ArithmeticCPUKernel::ReSize() {
|
|||
}
|
||||
|
||||
int ArithmeticCPUKernel::DoArithmetic(int task_id) {
|
||||
auto input0_data = reinterpret_cast<float *>(inputs_[0]->Data());
|
||||
auto input1_data1 = reinterpret_cast<float *>(inputs_[1]->Data());
|
||||
auto output_data = reinterpret_cast<float *>(outputs_[0]->Data());
|
||||
auto element_num = outputs_[0]->ElementsNum();
|
||||
auto input0_data = reinterpret_cast<float *>(in_tensors_[0]->Data());
|
||||
auto input1_data1 = reinterpret_cast<float *>(in_tensors_[1]->Data());
|
||||
auto output_data = reinterpret_cast<float *>(out_tensors_[0]->Data());
|
||||
auto element_num = out_tensors_[0]->ElementsNum();
|
||||
|
||||
MS_ASSERT(thread_count_ != 0);
|
||||
int stride = UP_DIV(element_num, thread_count_);
|
||||
|
@ -107,8 +107,8 @@ int ArithmeticCPUKernel::Run() {
|
|||
return ret;
|
||||
}
|
||||
if (arithmeticParameter_->broadcasting_) {
|
||||
auto input_data0 = reinterpret_cast<float *>(inputs_[0]->Data());
|
||||
auto input_data1 = reinterpret_cast<float *>(inputs_[1]->Data());
|
||||
auto input_data0 = reinterpret_cast<float *>(in_tensors_[0]->Data());
|
||||
auto input_data1 = reinterpret_cast<float *>(in_tensors_[1]->Data());
|
||||
TileDimensions(input_data0, input_data1, tile_data0_, tile_data1_, arithmeticParameter_);
|
||||
}
|
||||
int error_code = LiteBackendParallelLaunch(ArithmeticsRun, this, thread_count_);
|
||||
|
|
|
@ -67,7 +67,7 @@ class ArithmeticCPUKernel : public LiteKernel {
|
|||
}
|
||||
break;
|
||||
case PrimitiveType_Add:
|
||||
switch (arithmeticParameter_->activation_type_) {
|
||||
switch (arithmeticParameter_->activation_type_) {
|
||||
case schema::ActivationType_RELU:
|
||||
arithmetic_run_ = ElementAddRelu;
|
||||
break;
|
||||
|
@ -80,7 +80,7 @@ class ArithmeticCPUKernel : public LiteKernel {
|
|||
}
|
||||
break;
|
||||
case PrimitiveType_Sub:
|
||||
switch (arithmeticParameter_->activation_type_) {
|
||||
switch (arithmeticParameter_->activation_type_) {
|
||||
case schema::ActivationType_RELU:
|
||||
arithmetic_run_ = ElementSubRelu;
|
||||
break;
|
||||
|
@ -93,7 +93,7 @@ class ArithmeticCPUKernel : public LiteKernel {
|
|||
}
|
||||
break;
|
||||
case PrimitiveType_Div:
|
||||
switch (arithmeticParameter_->activation_type_) {
|
||||
switch (arithmeticParameter_->activation_type_) {
|
||||
case schema::ActivationType_RELU:
|
||||
arithmetic_run_ = ElementDivRelu;
|
||||
break;
|
||||
|
|
|
@ -35,7 +35,7 @@ int ArithmeticSelfCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int ArithmeticSelfCPUKernel::ReSize() {
|
||||
data_size_ = inputs_[0]->ElementsNum();
|
||||
data_size_ = in_tensors_[0]->ElementsNum();
|
||||
thread_sz_count_ = MSMIN(thread_count_, data_size_);
|
||||
thread_sz_stride_ = UP_DIV(data_size_, thread_sz_count_);
|
||||
return RET_OK;
|
||||
|
@ -76,8 +76,8 @@ int ArithmeticSelfCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << ret;
|
||||
return ret;
|
||||
}
|
||||
auto input_tensor = inputs_.at(0);
|
||||
auto out_tensor = outputs_.at(0);
|
||||
auto input_tensor = in_tensors_.at(0);
|
||||
auto out_tensor = out_tensors_.at(0);
|
||||
in_ptr_ = reinterpret_cast<float *>(input_tensor->Data());
|
||||
out_ptr_ = reinterpret_cast<float *>(out_tensor->Data());
|
||||
ret = LiteBackendParallelLaunch(ArithmeticSelfRuns, this, thread_sz_count_);
|
||||
|
|
|
@ -35,9 +35,7 @@ int BatchToSpaceCPUKernel::Init() {
|
|||
return ReSize();
|
||||
}
|
||||
|
||||
int BatchToSpaceCPUKernel::ReSize() {
|
||||
return BatchToSpaceBaseCPUKernel::ReSize();
|
||||
}
|
||||
int BatchToSpaceCPUKernel::ReSize() { return BatchToSpaceBaseCPUKernel::ReSize(); }
|
||||
|
||||
int BatchToSpaceCPUKernel::Run() {
|
||||
auto prepare_ret = Prepare();
|
||||
|
@ -45,13 +43,13 @@ int BatchToSpaceCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto input = inputs_[0];
|
||||
auto output = outputs_[0];
|
||||
auto input = in_tensors_[0];
|
||||
auto output = out_tensors_[0];
|
||||
const float *input_data = reinterpret_cast<const float *>(input->Data());
|
||||
float *output_data = reinterpret_cast<float *>(output->Data());
|
||||
auto in_shape = input->shape();
|
||||
auto out_shape = output->shape();
|
||||
BatchToSpaceParameter *param = reinterpret_cast<BatchToSpaceParameter *>(this->opParameter);
|
||||
BatchToSpaceParameter *param = reinterpret_cast<BatchToSpaceParameter *>(this->op_parameter_);
|
||||
|
||||
if (IsNoCrop()) {
|
||||
BatchToSpaceNoCropForNHWC(input_data, output_data, in_shape.data(), out_shape[0], param->block_shape_,
|
||||
|
|
|
@ -39,7 +39,7 @@ BatchnormCPUKernel::~BatchnormCPUKernel() {
|
|||
}
|
||||
|
||||
int BatchnormCPUKernel::InitConstTensor() {
|
||||
auto mean = inputs_[1];
|
||||
auto mean = in_tensors_[1];
|
||||
mean_addr_ = reinterpret_cast<float *>(malloc(mean->ElementsNum() * sizeof(float)));
|
||||
if (mean_addr_ == nullptr) {
|
||||
MS_LOG(ERROR) << "Malloc buffer failed.";
|
||||
|
@ -47,7 +47,7 @@ int BatchnormCPUKernel::InitConstTensor() {
|
|||
}
|
||||
memcpy(mean_addr_, mean->Data(), mean->ElementsNum() * sizeof(float));
|
||||
|
||||
auto variance = inputs_[2];
|
||||
auto variance = in_tensors_[2];
|
||||
var_addr_ = reinterpret_cast<float *>(malloc(variance->ElementsNum() * sizeof(float)));
|
||||
if (var_addr_ == nullptr) {
|
||||
MS_LOG(ERROR) << "Malloc buffer failed.";
|
||||
|
@ -59,11 +59,11 @@ int BatchnormCPUKernel::InitConstTensor() {
|
|||
|
||||
int BatchnormCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
auto input_shapes = inputs_[0]->shape();
|
||||
auto input_shapes = in_tensors_[0]->shape();
|
||||
auto n_dim = input_shapes.size();
|
||||
batchnorm_param_->channel_ = input_shapes[n_dim - 1];
|
||||
batchnorm_param_->unit_ = 1;
|
||||
|
@ -82,7 +82,7 @@ int BatchnormCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int BatchnormCPUKernel::ReSize() {
|
||||
auto input_shapes = inputs_[0]->shape();
|
||||
auto input_shapes = in_tensors_[0]->shape();
|
||||
batchnorm_param_->unit_ = 1;
|
||||
for (int i = 0; i < input_shapes.size() - 1; i++) {
|
||||
batchnorm_param_->unit_ *= input_shapes[i];
|
||||
|
@ -111,8 +111,8 @@ int BatchnormCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail! Ret error code: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
in_addr_ = reinterpret_cast<float *>(inputs_.at(0)->Data());
|
||||
out_addr_ = reinterpret_cast<float *>(outputs_.at(0)->Data());
|
||||
in_addr_ = reinterpret_cast<float *>(in_tensors_.at(0)->Data());
|
||||
out_addr_ = reinterpret_cast<float *>(out_tensors_.at(0)->Data());
|
||||
|
||||
int ret = LiteBackendParallelLaunch(BatchNormRun, this, batchnorm_param_->op_parameter_.thread_num_);
|
||||
if (ret != RET_OK) {
|
||||
|
|
|
@ -29,7 +29,7 @@ using mindspore::schema::PrimitiveType_BiasAdd;
|
|||
|
||||
namespace mindspore::kernel {
|
||||
int BiasCPUKernel::ReSize() {
|
||||
auto dims = inputs_[0]->shape();
|
||||
auto dims = in_tensors_[0]->shape();
|
||||
MS_ASSERT(dims.size() <= 5);
|
||||
bias_param_->ndim_ = dims.size();
|
||||
for (int i = 0; i < bias_param_->ndim_; i++) {
|
||||
|
@ -47,10 +47,10 @@ int BiasCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto in = reinterpret_cast<float *>(inputs_.at(0)->Data());
|
||||
auto bias = reinterpret_cast<float *>(inputs_.at(1)->Data());
|
||||
auto out = reinterpret_cast<float *>(outputs_.at(0)->Data());
|
||||
size_t data_size = inputs_.at(0)->ElementsNum();
|
||||
auto in = reinterpret_cast<float *>(in_tensors_.at(0)->Data());
|
||||
auto bias = reinterpret_cast<float *>(in_tensors_.at(1)->Data());
|
||||
auto out = reinterpret_cast<float *>(out_tensors_.at(0)->Data());
|
||||
size_t data_size = in_tensors_.at(0)->ElementsNum();
|
||||
auto tile_in = new float[data_size];
|
||||
auto tile_bias = new float[data_size];
|
||||
BroadcastAdd(in, bias, tile_in, tile_bias, out, data_size, bias_param_);
|
||||
|
|
|
@ -26,13 +26,13 @@ using mindspore::schema::PrimitiveType_BroadcastTo;
|
|||
|
||||
namespace mindspore::kernel {
|
||||
int BroadcastToCPUKernel::ReSize() {
|
||||
auto input_shape = inputs_[0]->shape();
|
||||
auto input_shape = in_tensors_[0]->shape();
|
||||
for (size_t i = 0; i < input_shape.size(); ++i) {
|
||||
shape_info_.input_shape_[i] = input_shape[i];
|
||||
}
|
||||
|
||||
shape_info_.input_shape_size_ = static_cast<int>(input_shape.size());
|
||||
auto output_shape = outputs_[0]->shape();
|
||||
auto output_shape = out_tensors_[0]->shape();
|
||||
for (size_t i = 0; i < output_shape.size(); ++i) {
|
||||
shape_info_.output_shape_[i] = output_shape[i];
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ int BroadcastToCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto input_data = reinterpret_cast<float *>(inputs_.at(0)->Data());
|
||||
auto output_data = reinterpret_cast<float *>(outputs_.at(0)->Data());
|
||||
auto input_data = reinterpret_cast<float *>(in_tensors_.at(0)->Data());
|
||||
auto output_data = reinterpret_cast<float *>(out_tensors_.at(0)->Data());
|
||||
|
||||
return BroadcastTo(input_data, &shape_info_, output_data);
|
||||
}
|
||||
|
|
|
@ -48,24 +48,24 @@ int CastCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int CastCPUKernel::ReSize() {
|
||||
data_num_ = inputs_[0]->ElementsNum();
|
||||
data_num_ = in_tensors_[0]->ElementsNum();
|
||||
if (data_num_ == 0) {
|
||||
return RET_OK;
|
||||
}
|
||||
opParameter->thread_num_ = MSMIN(opParameter->thread_num_, data_num_);
|
||||
stride_ = UP_DIV(data_num_, opParameter->thread_num_);
|
||||
op_parameter_->thread_num_ = MSMIN(op_parameter_->thread_num_, data_num_);
|
||||
stride_ = UP_DIV(data_num_, op_parameter_->thread_num_);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CastCPUKernel::DoCast(int thread_id) {
|
||||
auto input = inputs_.at(0);
|
||||
auto input = in_tensors_.at(0);
|
||||
int data_num = MSMIN(stride_, data_num_ - thread_id * stride_);
|
||||
if (data_num <= 0) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
auto offset = thread_id * stride_;
|
||||
auto output_data = reinterpret_cast<float *>(outputs_.at(0)->Data());
|
||||
auto output_data = reinterpret_cast<float *>(out_tensors_.at(0)->Data());
|
||||
switch (input->data_type()) {
|
||||
case kNumberTypeUInt8:
|
||||
Uint8ToFloat32(reinterpret_cast<uint8_t *>(input->Data()) + offset, output_data + offset, data_num);
|
||||
|
@ -89,7 +89,7 @@ int CastCPUKernel::Run() {
|
|||
if (data_num_ == 0) {
|
||||
return RET_OK;
|
||||
}
|
||||
return LiteBackendParallelLaunch(CastRun, this, opParameter->thread_num_);
|
||||
return LiteBackendParallelLaunch(CastRun, this, op_parameter_->thread_num_);
|
||||
}
|
||||
|
||||
kernel::LiteKernel *CpuCastFp32KernelCreator(const std::vector<lite::tensor::Tensor *> &inputs,
|
||||
|
|
|
@ -48,19 +48,19 @@ int ConcatCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto input_num = inputs_.size();
|
||||
auto input_num = in_tensors_.size();
|
||||
std::vector<void *> inputs_addr(input_num, nullptr);
|
||||
std::vector<int *> inputs_output_shape(input_num + 1, nullptr);
|
||||
|
||||
std::vector<std::vector<int>> shapes;
|
||||
for (size_t i = 0; i < input_num; ++i) {
|
||||
inputs_addr[i] = inputs_[i]->Data();
|
||||
shapes.push_back(inputs_[i]->shape());
|
||||
inputs_addr[i] = in_tensors_[i]->Data();
|
||||
shapes.push_back(in_tensors_[i]->shape());
|
||||
inputs_output_shape[i] = shapes[i].data();
|
||||
}
|
||||
auto output_shape = outputs_.at(0)->shape();
|
||||
auto output_shape = out_tensors_.at(0)->shape();
|
||||
inputs_output_shape[input_num] = output_shape.data();
|
||||
auto output_addr = outputs_.at(0)->Data();
|
||||
auto output_addr = out_tensors_.at(0)->Data();
|
||||
|
||||
Concat(reinterpret_cast<void **>(inputs_addr.data()), input_num, axis_, inputs_output_shape.data(),
|
||||
output_shape.size(), output_addr);
|
||||
|
|
|
@ -52,7 +52,7 @@ int ConvolutionCPUKernel::InitWeightBias() {
|
|||
int pack_weight_size = oc_block_num * oc_block * ic4 * C4NUM * kernel_plane;
|
||||
|
||||
// init weight
|
||||
auto origin_weight = reinterpret_cast<float *>(inputs_.at(kWeightIndex)->Data());
|
||||
auto origin_weight = reinterpret_cast<float *>(in_tensors_.at(kWeightIndex)->Data());
|
||||
packed_weight_ = reinterpret_cast<float *>(malloc(pack_weight_size * sizeof(float)));
|
||||
if (packed_weight_ == nullptr) {
|
||||
MS_LOG(ERROR) << "malloc packed weight failed.";
|
||||
|
@ -68,11 +68,11 @@ int ConvolutionCPUKernel::InitWeightBias() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
memset(bias_data_, 0, oc_block_num * oc_block * sizeof(float));
|
||||
if (inputs_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(inputs_.at(kBiasIndex)->Data());
|
||||
if (in_tensors_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(in_tensors_.at(kBiasIndex)->Data());
|
||||
memcpy(bias_data_, ori_bias, out_channel * sizeof(float));
|
||||
} else {
|
||||
MS_ASSERT(inputs_.size() == kInputSize1);
|
||||
MS_ASSERT(in_tensors_.size() == kInputSize1);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -120,11 +120,11 @@ int ConvolutionCPUKernel::InitTmpBuffer() {
|
|||
|
||||
void ConvolutionCPUKernel::ConfigInputOutput() {
|
||||
// set output format
|
||||
auto output_tensor = outputs_.at(kOutputIndex);
|
||||
auto output_tensor = out_tensors_.at(kOutputIndex);
|
||||
output_tensor->SetFormat(schema::Format_NHWC);
|
||||
|
||||
// select trans func for input
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto ret = CheckLayout(input_tensor);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Check layout failed.";
|
||||
|
@ -139,7 +139,7 @@ void ConvolutionCPUKernel::ConfigInputOutput() {
|
|||
|
||||
int ConvolutionCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
auto ret = ConvolutionBaseCPUKernel::Init();
|
||||
|
@ -193,7 +193,7 @@ int ConvolutionCPUKernel::RunImpl(int task_id) {
|
|||
MS_LOG(ERROR) << "gemm_func is nullptr.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto output_addr = reinterpret_cast<float *>(outputs_.at(kOutputIndex)->Data());
|
||||
auto output_addr = reinterpret_cast<float *>(out_tensors_.at(kOutputIndex)->Data());
|
||||
ConvFp32(reinterpret_cast<float *>(nhwc4_input_), packed_input_, packed_weight_,
|
||||
reinterpret_cast<float *>(bias_data_), tmp_output_block_, output_addr, task_id, conv_param_, gemm_func_);
|
||||
return RET_OK;
|
||||
|
@ -215,7 +215,7 @@ int ConvolutionCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto ori_input_data = input_tensor->Data();
|
||||
int in_batch = conv_param_->input_batch_;
|
||||
int in_h = conv_param_->input_h_;
|
||||
|
|
|
@ -68,14 +68,14 @@ void Convolution1x1CPUKernel::InitConv1x1MatmulParam() {
|
|||
}
|
||||
|
||||
int Convolution1x1CPUKernel::InitConv1x1BiasWeight() {
|
||||
if (inputs_.size() == 3) {
|
||||
if (in_tensors_.size() == 3) {
|
||||
bias_data_ = malloc(matmul_param_->col_8_ * sizeof(float));
|
||||
if (bias_data_ == nullptr) {
|
||||
MS_LOG(ERROR) << "Conv1x1 Malloc bias_ptr_ error!";
|
||||
return RET_ERROR;
|
||||
}
|
||||
memset(bias_data_, 0, matmul_param_->col_8_ * sizeof(float));
|
||||
memcpy(bias_data_, inputs_[2]->Data(), conv_param_->output_channel_ * sizeof(float));
|
||||
memcpy(bias_data_, in_tensors_[2]->Data(), conv_param_->output_channel_ * sizeof(float));
|
||||
} else {
|
||||
bias_data_ = nullptr;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ int Convolution1x1CPUKernel::InitConv1x1BiasWeight() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
memset(weight_ptr_, 0, matmul_param_->deep_ * matmul_param_->col_8_ * sizeof(float));
|
||||
RowMajor2Col8Major(reinterpret_cast<float *>(inputs_[1]->Data()), weight_ptr_, matmul_param_->col_,
|
||||
RowMajor2Col8Major(reinterpret_cast<float *>(in_tensors_[1]->Data()), weight_ptr_, matmul_param_->col_,
|
||||
matmul_param_->deep_);
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ int Convolution1x1CPUKernel::InitConv1x1Param() {
|
|||
memset(input_ptr_, 0, matmul_param_->row_ * matmul_param_->deep_ * sizeof(float));
|
||||
}
|
||||
|
||||
thread_count_ = MSMIN(opParameter->thread_num_, UP_DIV(matmul_param_->col_, C8NUM));
|
||||
thread_count_ = MSMIN(op_parameter_->thread_num_, UP_DIV(matmul_param_->col_, C8NUM));
|
||||
thread_stride_ = UP_DIV(UP_DIV(matmul_param_->col_, C8NUM), thread_count_) * C8NUM;
|
||||
|
||||
pack_input_ = reinterpret_cast<float *>(malloc(matmul_param_->row_8_ * matmul_param_->deep_ * sizeof(float)));
|
||||
|
@ -137,7 +137,7 @@ void Convolution1x1CPUKernel::Pre1x1Trans(float *src_input, float *src_output) {
|
|||
|
||||
int Convolution1x1CPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
ConvolutionBaseCPUKernel::Init();
|
||||
|
@ -204,8 +204,8 @@ int Convolution1x1CPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto src_in = reinterpret_cast<float *>(inputs_[0]->Data());
|
||||
auto src_out = reinterpret_cast<float *>(outputs_[0]->Data());
|
||||
auto src_in = reinterpret_cast<float *>(in_tensors_[0]->Data());
|
||||
auto src_out = reinterpret_cast<float *>(out_tensors_[0]->Data());
|
||||
|
||||
for (int batch_index = 0; batch_index < conv_param_->input_batch_; batch_index++) {
|
||||
Pre1x1Trans(src_in + batch_index * conv_param_->input_h_ * conv_param_->input_w_ * conv_param_->input_channel_,
|
||||
|
|
|
@ -70,7 +70,7 @@ int Convolution3x3CPUKernel::InitWeightBias() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
memset(transformed_filter_addr_, 0, transformed_size);
|
||||
auto weight_data = reinterpret_cast<float *>(inputs_.at(kWeightIndex)->Data());
|
||||
auto weight_data = reinterpret_cast<float *>(in_tensors_.at(kWeightIndex)->Data());
|
||||
ProcessFilter(weight_data, transformed_filter_addr_, conv_param_, oc_block, oc_block_num);
|
||||
|
||||
// init bias
|
||||
|
@ -81,11 +81,11 @@ int Convolution3x3CPUKernel::InitWeightBias() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
memset(bias_data_, 0, new_bias_size);
|
||||
if (inputs_.size() == kInputSize2) {
|
||||
auto ori_bias_addr = reinterpret_cast<float *>(inputs_.at(kBiasIndex)->Data());
|
||||
if (in_tensors_.size() == kInputSize2) {
|
||||
auto ori_bias_addr = reinterpret_cast<float *>(in_tensors_.at(kBiasIndex)->Data());
|
||||
memcpy(bias_data_, ori_bias_addr, output_channel * sizeof(float));
|
||||
} else {
|
||||
MS_ASSERT(inputs_.size() == kInputSize1);
|
||||
MS_ASSERT(in_tensors_.size() == kInputSize1);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -149,10 +149,10 @@ int Convolution3x3CPUKernel::InitTmpBuffer() {
|
|||
}
|
||||
|
||||
void Convolution3x3CPUKernel::ConfigInputOutput() {
|
||||
auto output_tensor = outputs_.at(kOutputIndex);
|
||||
auto output_tensor = out_tensors_.at(kOutputIndex);
|
||||
output_tensor->SetFormat(schema::Format_NHWC);
|
||||
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto ret = CheckLayout(input_tensor);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Check layout failed.";
|
||||
|
@ -167,7 +167,7 @@ void Convolution3x3CPUKernel::ConfigInputOutput() {
|
|||
|
||||
int Convolution3x3CPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
auto ret = ConvolutionBaseCPUKernel::Init();
|
||||
|
@ -224,7 +224,7 @@ int Convolution3x3CPUKernel::RunImpl(int task_id) {
|
|||
MS_LOG(ERROR) << "gemm_func is nullptr.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto output_addr = reinterpret_cast<float *>(outputs_.at(kOutputIndex)->Data());
|
||||
auto output_addr = reinterpret_cast<float *>(out_tensors_.at(kOutputIndex)->Data());
|
||||
Conv3x3Fp32(reinterpret_cast<float *>(nhwc4_input_), transformed_filter_addr_, reinterpret_cast<float *>(bias_data_),
|
||||
output_addr, tmp_buffer_address_list_, task_id, conv_param_, gemm_func_);
|
||||
return RET_OK;
|
||||
|
@ -246,7 +246,7 @@ int Convolution3x3CPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto ori_input_data = input_tensor->Data();
|
||||
int in_batch = conv_param_->input_batch_;
|
||||
int in_h = conv_param_->input_h_;
|
||||
|
|
|
@ -49,7 +49,7 @@ ConvolutionDepthwiseCPUKernel::~ConvolutionDepthwiseCPUKernel() {
|
|||
|
||||
int ConvolutionDepthwiseCPUKernel::InitWeightBias() {
|
||||
// init weight: o, h, w, i; o == group, i == 1
|
||||
auto weight_tensor = inputs_[kWeightIndex];
|
||||
auto weight_tensor = in_tensors_[kWeightIndex];
|
||||
auto origin_weight = reinterpret_cast<float *>(weight_tensor->Data());
|
||||
int OC4 = UP_DIV(conv_param_->output_channel_, C4NUM);
|
||||
int pack_weight_size = C4NUM * OC4 * conv_param_->kernel_h_ * conv_param_->kernel_w_;
|
||||
|
@ -70,8 +70,8 @@ int ConvolutionDepthwiseCPUKernel::InitWeightBias() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
memset(bias_data_, 0, C4NUM * OC4 * sizeof(float));
|
||||
if (inputs_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(inputs_.at(kBiasIndex)->Data());
|
||||
if (in_tensors_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(in_tensors_.at(kBiasIndex)->Data());
|
||||
memcpy(bias_data_, ori_bias, conv_param_->output_channel_ * sizeof(float));
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ int ConvolutionDepthwiseCPUKernel::InitBuffer() {
|
|||
|
||||
int ConvolutionDepthwiseCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
// conv base init
|
||||
|
@ -183,7 +183,7 @@ int ConvolutionDepthwiseCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Only support input channel equals output channel.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto input_addr = reinterpret_cast<float *>(input_tensor->Data());
|
||||
|
||||
// pack input: to nhwc4
|
||||
|
@ -194,7 +194,7 @@ int ConvolutionDepthwiseCPUKernel::Run() {
|
|||
packed_input_ = input_addr;
|
||||
}
|
||||
|
||||
auto output_addr = reinterpret_cast<float *>(outputs_.at(kOutputIndex)->Data());
|
||||
auto output_addr = reinterpret_cast<float *>(out_tensors_.at(kOutputIndex)->Data());
|
||||
if (!need_align_) {
|
||||
packed_output_ = output_addr;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ using mindspore::schema::PrimitiveType_DepthwiseConv2D;
|
|||
namespace mindspore::kernel {
|
||||
int ConvolutionDepthwise3x3CPUKernel::InitWeightBias() {
|
||||
// init weight: o, h, w, i; o == group, i == 1
|
||||
auto weight_tensor = inputs_[kWeightIndex];
|
||||
auto weight_tensor = in_tensors_[kWeightIndex];
|
||||
auto origin_weight = reinterpret_cast<float *>(weight_tensor->Data());
|
||||
// o h w 1 -> o/4 h w 1 4
|
||||
int OC4 = UP_DIV(conv_param_->output_channel_, C4NUM);
|
||||
|
@ -60,8 +60,8 @@ int ConvolutionDepthwise3x3CPUKernel::InitWeightBias() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
memset(bias_data_, 0, C4NUM * OC4 * sizeof(float));
|
||||
if (inputs_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(inputs_.at(kBiasIndex)->Data());
|
||||
if (in_tensors_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(in_tensors_.at(kBiasIndex)->Data());
|
||||
memcpy(bias_data_, ori_bias, conv_param_->output_channel_ * sizeof(float));
|
||||
}
|
||||
return RET_OK;
|
||||
|
@ -101,7 +101,7 @@ int ConvolutionDepthwise3x3CPUKernel::InitBuffer() {
|
|||
|
||||
int ConvolutionDepthwise3x3CPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
// conv base init
|
||||
|
@ -177,7 +177,7 @@ int ConvolutionDepthwise3x3CPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Only support input channel equals output channel.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto input_addr = reinterpret_cast<float *>(input_tensor->Data());
|
||||
|
||||
// pack input: to nhwc4
|
||||
|
@ -188,7 +188,7 @@ int ConvolutionDepthwise3x3CPUKernel::Run() {
|
|||
packed_input_ = input_addr;
|
||||
}
|
||||
|
||||
auto output_addr = reinterpret_cast<float *>(outputs_.at(kOutputIndex)->Data());
|
||||
auto output_addr = reinterpret_cast<float *>(out_tensors_.at(kOutputIndex)->Data());
|
||||
if (!need_align_) {
|
||||
packed_output_ = output_addr;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ int ConvolutionSWCPUKernel::InitWeightBias() {
|
|||
int pack_weight_size = oc_block_num * oc_block * ic4 * C4NUM * kernel_plane;
|
||||
|
||||
// ==================================init weight======================================//
|
||||
auto origin_weight = reinterpret_cast<float *>(inputs_.at(kWeightIndex)->Data());
|
||||
auto origin_weight = reinterpret_cast<float *>(in_tensors_.at(kWeightIndex)->Data());
|
||||
packed_weight_ = reinterpret_cast<float *>(malloc(pack_weight_size * sizeof(float)));
|
||||
if (packed_weight_ == nullptr) {
|
||||
MS_LOG(ERROR) << "malloc packed weight failed.";
|
||||
|
@ -65,11 +65,11 @@ int ConvolutionSWCPUKernel::InitWeightBias() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
memset(bias_data_, 0, oc_block_num * oc_block * sizeof(float));
|
||||
if (inputs_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(inputs_.at(kBiasIndex)->Data());
|
||||
if (in_tensors_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(in_tensors_.at(kBiasIndex)->Data());
|
||||
memcpy(bias_data_, ori_bias, out_channel * sizeof(float));
|
||||
} else {
|
||||
MS_ASSERT(inputs_.size() == kInputSize1);
|
||||
MS_ASSERT(in_tensors_.size() == kInputSize1);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -102,11 +102,11 @@ int ConvolutionSWCPUKernel::InitTmpBuffer() {
|
|||
|
||||
void ConvolutionSWCPUKernel::ConfigInputOutput() {
|
||||
// set output format
|
||||
auto output_tensor = outputs_.at(kOutputIndex);
|
||||
auto output_tensor = out_tensors_.at(kOutputIndex);
|
||||
output_tensor->SetFormat(schema::Format_NHWC);
|
||||
|
||||
// select trans func for input
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto ret = CheckLayout(input_tensor);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Check layout failed.";
|
||||
|
@ -116,7 +116,7 @@ void ConvolutionSWCPUKernel::ConfigInputOutput() {
|
|||
|
||||
int ConvolutionSWCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
auto ret = ConvolutionBaseCPUKernel::Init();
|
||||
|
@ -171,7 +171,7 @@ int ConvolutionSWCPUKernel::ReSize() {
|
|||
}
|
||||
|
||||
int ConvolutionSWCPUKernel::RunImpl(int task_id) {
|
||||
auto output_addr = reinterpret_cast<float *>(outputs_.at(kOutputIndex)->Data());
|
||||
auto output_addr = reinterpret_cast<float *>(out_tensors_.at(kOutputIndex)->Data());
|
||||
ConvSWFp32(reinterpret_cast<float *>(nhwc4_input_), packed_weight_, reinterpret_cast<float *>(bias_data_),
|
||||
tmp_output_block_, output_addr, task_id, conv_param_, slidingWindow_param_);
|
||||
return RET_OK;
|
||||
|
@ -193,7 +193,7 @@ int ConvolutionSWCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto ori_input_data = input_tensor->Data();
|
||||
int in_batch = conv_param_->input_batch_;
|
||||
int in_h = conv_param_->input_h_;
|
||||
|
|
|
@ -103,7 +103,7 @@ int ConvolutionWinogradCPUKernel::InitWeightBias() {
|
|||
MS_LOG(ERROR) << "Malloc filter matrix failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto weight_tensor = inputs_.at(kWeightIndex);
|
||||
auto weight_tensor = in_tensors_.at(kWeightIndex);
|
||||
auto weight_data = reinterpret_cast<float *>(weight_tensor->Data());
|
||||
WinogradFilterTransform(weight_data, trans_weight_, kernel_unit_, input_unit_, conv_param_, oc_block);
|
||||
|
||||
|
@ -111,11 +111,11 @@ int ConvolutionWinogradCPUKernel::InitWeightBias() {
|
|||
size_t new_bias_size = oc4 * C4NUM * sizeof(float);
|
||||
bias_data_ = reinterpret_cast<float *>(malloc(new_bias_size));
|
||||
memset(bias_data_, 0, new_bias_size);
|
||||
if (inputs_.size() == kInputSize2) {
|
||||
auto ori_bias_addr = reinterpret_cast<float *>(inputs_.at(kBiasIndex)->Data());
|
||||
if (in_tensors_.size() == kInputSize2) {
|
||||
auto ori_bias_addr = reinterpret_cast<float *>(in_tensors_.at(kBiasIndex)->Data());
|
||||
memcpy(bias_data_, ori_bias_addr, output_channel * sizeof(float));
|
||||
} else {
|
||||
MS_ASSERT(inputs_.size() == kInputSize1);
|
||||
MS_ASSERT(in_tensors_.size() == kInputSize1);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -218,13 +218,13 @@ int ConvolutionWinogradCPUKernel::InitTmpBuffer() {
|
|||
}
|
||||
|
||||
int ConvolutionWinogradCPUKernel::ConfigInputOutput() {
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto ret = CheckLayout(input_tensor);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Check layout failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto output_tensor = outputs_.at(kOutputIndex);
|
||||
auto output_tensor = out_tensors_.at(kOutputIndex);
|
||||
output_tensor->SetFormat(schema::Format_NHWC);
|
||||
|
||||
// choose input transformer function (4x4 unit or 8x8 unit)
|
||||
|
@ -248,7 +248,7 @@ int ConvolutionWinogradCPUKernel::ConfigInputOutput() {
|
|||
|
||||
int ConvolutionWinogradCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
auto ret = ConvolutionBaseCPUKernel::Init();
|
||||
|
@ -325,7 +325,7 @@ int ConvolutionWinogradCPUKernel::RunImpl(int task_id) {
|
|||
MS_LOG(ERROR) << "gemm_func is nullptr.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto output_addr = reinterpret_cast<float *>(outputs_.at(kOutputIndex)->Data());
|
||||
auto output_addr = reinterpret_cast<float *>(out_tensors_.at(kOutputIndex)->Data());
|
||||
ConvWinogardFp32(reinterpret_cast<float *>(nhwc4_input_), reinterpret_cast<float *>(trans_weight_->GetData()),
|
||||
reinterpret_cast<const float *>(bias_data_), output_addr, tmp_buffer_address_list_, task_id,
|
||||
conv_param_, input_trans_func_, output_trans_func_, gemm_func_);
|
||||
|
@ -348,7 +348,7 @@ int ConvolutionWinogradCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto ori_input_data = input_tensor->Data();
|
||||
int in_batch = conv_param_->input_batch_;
|
||||
int in_h = conv_param_->input_h_;
|
||||
|
|
|
@ -43,12 +43,12 @@ int CropLaunch(int thread_id, LiteParallelGroupEnv *penv, void *cdata) {
|
|||
int CropCPUKernel::Init() { return RET_OK; }
|
||||
|
||||
int CropCPUKernel::CropParallelRun(int thread_id) {
|
||||
auto input = inputs_[0];
|
||||
auto output = outputs_[0];
|
||||
auto input = in_tensors_[0];
|
||||
auto output = out_tensors_[0];
|
||||
float *input_data = reinterpret_cast<float *>(input->Data());
|
||||
float *output_data = reinterpret_cast<float *>(output->Data());
|
||||
Crop4D(input_data, output_data, input->shape().data(), output->shape().data(),
|
||||
reinterpret_cast<CropParameter *>(opParameter));
|
||||
reinterpret_cast<CropParameter *>(op_parameter_));
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,9 @@ int CropCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto input = inputs_[0];
|
||||
auto output = outputs_[0];
|
||||
auto param = reinterpret_cast<CropParameter *>(opParameter);
|
||||
auto input = in_tensors_[0];
|
||||
auto output = out_tensors_[0];
|
||||
auto param = reinterpret_cast<CropParameter *>(op_parameter_);
|
||||
if (output->shape()[1] < param->op_parameter_.thread_num_) {
|
||||
float *input_data = reinterpret_cast<float *>(input->Data());
|
||||
float *output_data = reinterpret_cast<float *>(output->Data());
|
||||
|
|
|
@ -64,14 +64,14 @@ int DeConvolutionCPUKernel::ReSize() {
|
|||
}
|
||||
|
||||
int DeConvolutionCPUKernel::InitWeightBias() {
|
||||
if (inputs_.size() == 3) {
|
||||
if (in_tensors_.size() == 3) {
|
||||
bias_data_ = malloc(UP_ROUND(conv_param_->output_channel_, C4NUM) * sizeof(float));
|
||||
if (bias_data_ == nullptr) {
|
||||
MS_LOG(ERROR) << "deconv malloc bias_data_ error!";
|
||||
return RET_ERROR;
|
||||
}
|
||||
memset(bias_data_, 0, UP_ROUND(conv_param_->output_channel_, C4NUM) * sizeof(float));
|
||||
memcpy(bias_data_, inputs_[2]->Data(), conv_param_->output_channel_ * sizeof(float));
|
||||
memcpy(bias_data_, in_tensors_[2]->Data(), conv_param_->output_channel_ * sizeof(float));
|
||||
} else {
|
||||
bias_data_ = nullptr;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ int DeConvolutionCPUKernel::InitWeightBias() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
memset(weight_ptr_, 0, weight_pack_size);
|
||||
PackNHWCToC8HWN8Fp32(reinterpret_cast<float *>(inputs_[1]->Data()), weight_ptr_, conv_param_->input_channel_,
|
||||
PackNHWCToC8HWN8Fp32(reinterpret_cast<float *>(in_tensors_[1]->Data()), weight_ptr_, conv_param_->input_channel_,
|
||||
kernel_plane_, conv_param_->output_channel_);
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ int DeConvolutionCPUKernel::InitParam() {
|
|||
matmul_param_->row_8_ = UP_ROUND(matmul_param_->row_, C8NUM);
|
||||
matmul_param_->col_8_ = UP_ROUND(conv_param_->output_channel_, C8NUM) * kernel_plane_;
|
||||
|
||||
thread_count_ = MSMIN(opParameter->thread_num_, UP_DIV(conv_param_->output_channel_, C8NUM));
|
||||
thread_count_ = MSMIN(op_parameter_->thread_num_, UP_DIV(conv_param_->output_channel_, C8NUM));
|
||||
thread_stride_ = UP_DIV(UP_DIV(conv_param_->output_channel_, C8NUM), thread_count_);
|
||||
|
||||
pack_input_ = reinterpret_cast<float *>(malloc(matmul_param_->row_8_ * matmul_param_->deep_ * sizeof(float)));
|
||||
|
@ -174,7 +174,7 @@ int DeConvolutionCPUKernel::DoPostFunc(int task_id) {
|
|||
|
||||
int DeConvolutionCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
ConvolutionBaseCPUKernel::Init();
|
||||
|
@ -199,8 +199,8 @@ int DeConvolutionCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
float *src_in = reinterpret_cast<float *>(inputs_[0]->Data());
|
||||
float *src_out = reinterpret_cast<float *>(outputs_[0]->Data());
|
||||
float *src_in = reinterpret_cast<float *>(in_tensors_[0]->Data());
|
||||
float *src_out = reinterpret_cast<float *>(out_tensors_[0]->Data());
|
||||
|
||||
for (int batch_index = 0; batch_index < conv_param_->input_batch_; batch_index++) {
|
||||
input_ptr_ = src_in + batch_index * input_plane_ * conv_param_->input_channel_;
|
||||
|
|
|
@ -46,14 +46,14 @@ DeconvolutionDepthwiseCPUKernel::~DeconvolutionDepthwiseCPUKernel() {
|
|||
}
|
||||
|
||||
int DeconvolutionDepthwiseCPUKernel::InitSlideParam() {
|
||||
conv_param_->input_batch_ = outputs_.front()->shape().at(kNHWC_N);
|
||||
conv_param_->input_h_ = outputs_.front()->shape().at(kNHWC_H);
|
||||
conv_param_->input_w_ = outputs_.front()->shape().at(kNHWC_W);
|
||||
conv_param_->input_channel_ = outputs_.front()->shape().at(kNHWC_C);
|
||||
conv_param_->output_batch_ = inputs_.front()->shape().at(kNHWC_N);
|
||||
conv_param_->output_h_ = inputs_.front()->shape().at(kNHWC_H);
|
||||
conv_param_->output_w_ = inputs_.front()->shape().at(kNHWC_W);
|
||||
conv_param_->output_channel_ = inputs_.front()->shape().at(kNHWC_C);
|
||||
conv_param_->input_batch_ = out_tensors_.front()->shape().at(kNHWC_N);
|
||||
conv_param_->input_h_ = out_tensors_.front()->shape().at(kNHWC_H);
|
||||
conv_param_->input_w_ = out_tensors_.front()->shape().at(kNHWC_W);
|
||||
conv_param_->input_channel_ = out_tensors_.front()->shape().at(kNHWC_C);
|
||||
conv_param_->output_batch_ = in_tensors_.front()->shape().at(kNHWC_N);
|
||||
conv_param_->output_h_ = in_tensors_.front()->shape().at(kNHWC_H);
|
||||
conv_param_->output_w_ = in_tensors_.front()->shape().at(kNHWC_W);
|
||||
conv_param_->output_channel_ = in_tensors_.front()->shape().at(kNHWC_C);
|
||||
|
||||
// init sliding window param
|
||||
sliding_ = new SlidingWindowParam;
|
||||
|
@ -63,7 +63,7 @@ int DeconvolutionDepthwiseCPUKernel::InitSlideParam() {
|
|||
|
||||
int DeconvolutionDepthwiseCPUKernel::InitWeightBias() {
|
||||
// init weight: o, h, w, i; o == group, i == 1
|
||||
auto weight_tensor = inputs_[kWeightIndex];
|
||||
auto weight_tensor = in_tensors_[kWeightIndex];
|
||||
auto origin_weight = reinterpret_cast<float *>(weight_tensor->Data());
|
||||
int OC4 = UP_DIV(conv_param_->output_channel_, C4NUM);
|
||||
int pack_weight_size = C4NUM * OC4 * conv_param_->kernel_h_ * conv_param_->kernel_w_;
|
||||
|
@ -84,8 +84,8 @@ int DeconvolutionDepthwiseCPUKernel::InitWeightBias() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
memset(bias_data_, 0, C4NUM * OC4 * sizeof(float));
|
||||
if (inputs_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(inputs_.at(kBiasIndex)->Data());
|
||||
if (in_tensors_.size() == kInputSize2) {
|
||||
auto ori_bias = reinterpret_cast<float *>(in_tensors_.at(kBiasIndex)->Data());
|
||||
memcpy(bias_data_, ori_bias, conv_param_->output_channel_ * sizeof(float));
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ int DeconvolutionDepthwiseCPUKernel::InitBuffer() {
|
|||
|
||||
int DeconvolutionDepthwiseCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
InitSlideParam();
|
||||
|
@ -192,7 +192,7 @@ int DeconvolutionDepthwiseCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Only support input channel equals output channel.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto input_tensor = inputs_.at(kInputIndex);
|
||||
auto input_tensor = in_tensors_.at(kInputIndex);
|
||||
auto input_addr = reinterpret_cast<float *>(input_tensor->Data());
|
||||
|
||||
// pack input: to nhwc4
|
||||
|
@ -203,9 +203,9 @@ int DeconvolutionDepthwiseCPUKernel::Run() {
|
|||
packed_input_ = input_addr;
|
||||
}
|
||||
|
||||
auto output_addr = reinterpret_cast<float *>(outputs_.at(kOutputIndex)->Data());
|
||||
auto output_addr = reinterpret_cast<float *>(out_tensors_.at(kOutputIndex)->Data());
|
||||
if (!need_align_) {
|
||||
memset(output_addr, 0, outputs_.at(kOutputIndex)->ElementsNum() * sizeof(float));
|
||||
memset(output_addr, 0, out_tensors_.at(kOutputIndex)->ElementsNum() * sizeof(float));
|
||||
packed_output_ = output_addr;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ int DepthToSpaceCPUKernel::Init() {
|
|||
if (ret != RET_OK) {
|
||||
return ret;
|
||||
}
|
||||
DepthToSpaceParameter *param = reinterpret_cast<DepthToSpaceParameter *>(opParameter);
|
||||
DepthToSpaceParameter *param = reinterpret_cast<DepthToSpaceParameter *>(op_parameter_);
|
||||
param->data_type_size_ = sizeof(float);
|
||||
if (!InferShapeDone()) {
|
||||
return RET_OK;
|
||||
|
@ -52,12 +52,12 @@ int DepthToSpaceCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto input = inputs_[0];
|
||||
auto output = outputs_[0];
|
||||
auto input = in_tensors_[0];
|
||||
auto output = out_tensors_[0];
|
||||
const float *input_data = reinterpret_cast<const float *>(input->Data());
|
||||
float *output_data = reinterpret_cast<float *>(output->Data());
|
||||
auto in_shape = input->shape();
|
||||
DepthToSpaceParameter *param = reinterpret_cast<DepthToSpaceParameter *>(opParameter);
|
||||
DepthToSpaceParameter *param = reinterpret_cast<DepthToSpaceParameter *>(op_parameter_);
|
||||
if (input->GetFormat() == schema::Format_NHWC) {
|
||||
DepthToSpaceForNHWC(input_data, output_data, in_shape.data(), param);
|
||||
return RET_OK;
|
||||
|
|
|
@ -26,7 +26,7 @@ using mindspore::schema::PrimitiveType_Elu;
|
|||
|
||||
namespace mindspore::kernel {
|
||||
int EluCPUKernel::Init() {
|
||||
elu_parameter_ = reinterpret_cast<EluParameter *>(opParameter);
|
||||
elu_parameter_ = reinterpret_cast<EluParameter *>(op_parameter_);
|
||||
elu_parameter_->thread_num_ = thread_count_;
|
||||
|
||||
if (!InferShapeDone()) {
|
||||
|
@ -37,7 +37,7 @@ int EluCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int EluCPUKernel::ReSize() {
|
||||
elu_parameter_->in_size_ = inputs_.front()->ElementsNum();
|
||||
elu_parameter_->in_size_ = in_tensors_.front()->ElementsNum();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,8 @@ int EluCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
input_addr = reinterpret_cast<float *>(inputs_.front()->Data());
|
||||
output_addr = reinterpret_cast<float *>(outputs_.front()->Data());
|
||||
input_addr = reinterpret_cast<float *>(in_tensors_.front()->Data());
|
||||
output_addr = reinterpret_cast<float *>(out_tensors_.front()->Data());
|
||||
|
||||
auto ret = LiteBackendParallelLaunch(EluRun, this, elu_parameter_->thread_num_);
|
||||
if (ret != RET_OK) {
|
||||
|
|
|
@ -26,7 +26,7 @@ using mindspore::schema::PrimitiveType_EmbeddingLookup;
|
|||
|
||||
namespace mindspore::kernel {
|
||||
int EmbeddingLookupCPUKernel::Init() {
|
||||
embedding_lookup_parameter_ = reinterpret_cast<EmbeddingLookupParameter *>(opParameter);
|
||||
embedding_lookup_parameter_ = reinterpret_cast<EmbeddingLookupParameter *>(op_parameter_);
|
||||
embedding_lookup_parameter_->thread_num = thread_count_;
|
||||
|
||||
if (!InferShapeDone()) {
|
||||
|
@ -36,17 +36,17 @@ int EmbeddingLookupCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int EmbeddingLookupCPUKernel::ReSize() {
|
||||
embedding_lookup_parameter_->ids_size_ = inputs_.back()->ElementsNum();
|
||||
embedding_lookup_parameter_->ids_size_ = in_tensors_.back()->ElementsNum();
|
||||
|
||||
embedding_lookup_parameter_->layer_size_ = 1;
|
||||
auto in_shape = inputs_.front()->shape();
|
||||
auto in_shape = in_tensors_.front()->shape();
|
||||
for (int i = 1; i < in_shape.size(); ++i) {
|
||||
embedding_lookup_parameter_->layer_size_ *= in_shape[i];
|
||||
}
|
||||
|
||||
embedding_lookup_parameter_->layer_num_ = 0;
|
||||
for (int i = 0; i < inputs_.size() - 1; ++i) {
|
||||
embedding_lookup_parameter_->layer_num_ += inputs_[i]->shape()[0];
|
||||
for (int i = 0; i < in_tensors_.size() - 1; ++i) {
|
||||
embedding_lookup_parameter_->layer_num_ += in_tensors_[i]->shape()[0];
|
||||
}
|
||||
|
||||
if (input_addr_ != nullptr) {
|
||||
|
@ -112,13 +112,13 @@ int EmbeddingLookupCPUKernel::Run() {
|
|||
return prepare_ret;
|
||||
}
|
||||
int dest_loc = 0;
|
||||
for (int i = 0; i < inputs_.size() - 1; i++) {
|
||||
auto input_t = reinterpret_cast<float *>(inputs_.at(i)->Data());
|
||||
memcpy(input_addr_ + dest_loc, input_t, sizeof(float) * inputs_.at(i)->ElementsNum());
|
||||
dest_loc += inputs_.at(i)->ElementsNum();
|
||||
for (int i = 0; i < in_tensors_.size() - 1; i++) {
|
||||
auto input_t = reinterpret_cast<float *>(in_tensors_.at(i)->Data());
|
||||
memcpy(input_addr_ + dest_loc, input_t, sizeof(float) * in_tensors_.at(i)->ElementsNum());
|
||||
dest_loc += in_tensors_.at(i)->ElementsNum();
|
||||
}
|
||||
output_addr_ = reinterpret_cast<float *>(outputs_.front()->Data());
|
||||
ids_addr_ = reinterpret_cast<int *>(inputs_.back()->Data());
|
||||
output_addr_ = reinterpret_cast<float *>(out_tensors_.front()->Data());
|
||||
ids_addr_ = reinterpret_cast<int *>(in_tensors_.back()->Data());
|
||||
|
||||
auto ret = LiteBackendParallelLaunch(EmbeddingLookupRun, this, embedding_lookup_parameter_->thread_num);
|
||||
if (ret != RET_OK) {
|
||||
|
|
|
@ -30,7 +30,7 @@ using mindspore::schema::PrimitiveType_ExpandDims;
|
|||
namespace mindspore::kernel {
|
||||
int ExpandDimsCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
int ret = ReSize();
|
||||
|
@ -38,7 +38,7 @@ int ExpandDimsCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int ExpandDimsCPUKernel::ReSize() {
|
||||
data_size_ = inputs_.at(0)->ElementsNum();
|
||||
data_size_ = in_tensors_.at(0)->ElementsNum();
|
||||
thread_sz_count_ = MSMIN(thread_count_, data_size_);
|
||||
thread_sz_stride_ = UP_DIV(data_size_, thread_sz_count_);
|
||||
return RET_OK;
|
||||
|
@ -74,8 +74,8 @@ int ExpandDimsCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
in_ptr_ = reinterpret_cast<float *>(inputs_.at(0)->Data());
|
||||
out_ptr_ = reinterpret_cast<float *>(outputs_.at(0)->Data());
|
||||
in_ptr_ = reinterpret_cast<float *>(in_tensors_.at(0)->Data());
|
||||
out_ptr_ = reinterpret_cast<float *>(out_tensors_.at(0)->Data());
|
||||
auto ret = LiteBackendParallelLaunch(ExpandDimsRun, this, thread_sz_count_);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "ExpandDimsRun error error_code[" << ret << "]";
|
||||
|
|
|
@ -36,10 +36,10 @@ constexpr int kOutputNum = 1;
|
|||
|
||||
int FillCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
data_size_ = outputs_.front()->ElementsNum();
|
||||
data_size_ = out_tensors_.front()->ElementsNum();
|
||||
thread_sz_count_ = MSMIN(thread_count_, data_size_);
|
||||
thread_sz_stride_ = UP_DIV(data_size_, thread_sz_count_);
|
||||
return RET_OK;
|
||||
|
@ -77,8 +77,8 @@ int FillCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto fillData = inputs_.at(inputs_.size() - 1);
|
||||
auto output = outputs_.front();
|
||||
auto fillData = in_tensors_.at(in_tensors_.size() - 1);
|
||||
auto output = out_tensors_.front();
|
||||
auto fill_data = reinterpret_cast<float *>(fillData->Data());
|
||||
src_data_ = fill_data[0];
|
||||
out_ptr_ = reinterpret_cast<float *>(output->Data());
|
||||
|
|
|
@ -29,7 +29,7 @@ using mindspore::schema::PrimitiveType_Flatten;
|
|||
namespace mindspore::kernel {
|
||||
int FlattenCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ int FlattenCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int FlattenCPUKernel::ReSize() {
|
||||
auto output_shape = outputs_[0]->shape();
|
||||
auto output_shape = out_tensors_[0]->shape();
|
||||
flatten_param_->size = sizeof(float);
|
||||
for (int i = 0; i < output_shape.size(); i++) {
|
||||
flatten_param_->size *= output_shape[i];
|
||||
|
@ -52,8 +52,8 @@ int FlattenCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto input = reinterpret_cast<float *>(inputs_[0]->Data());
|
||||
auto output = reinterpret_cast<float *>(outputs_[0]->Data());
|
||||
auto input = reinterpret_cast<float *>(in_tensors_[0]->Data());
|
||||
auto output = reinterpret_cast<float *>(out_tensors_[0]->Data());
|
||||
Flatten(input, output, flatten_param_);
|
||||
return RET_OK;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class FlattenCPUKernel : public LiteKernel {
|
|||
: LiteKernel(parameter, inputs, outputs, ctx, primitive) {
|
||||
flatten_param_ = reinterpret_cast<FlattenParameter *>(parameter);
|
||||
}
|
||||
~FlattenCPUKernel() override = default;;
|
||||
~FlattenCPUKernel() override = default;
|
||||
|
||||
int Init() override;
|
||||
int ReSize() override;
|
||||
|
|
|
@ -45,12 +45,12 @@ int FullconnectionCPUKernel::ReSize() { return RET_OK; }
|
|||
|
||||
int FullconnectionCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
fc_param_->row_ = (inputs_[0]->shape())[0];
|
||||
fc_param_->col_ = (inputs_[1]->shape())[0];
|
||||
fc_param_->deep_ = (inputs_[1]->shape())[1];
|
||||
fc_param_->row_ = (in_tensors_[0]->shape())[0];
|
||||
fc_param_->col_ = (in_tensors_[1]->shape())[0];
|
||||
fc_param_->deep_ = (in_tensors_[1]->shape())[1];
|
||||
|
||||
fc_param_->row_8_ = UP_ROUND(fc_param_->row_, 8);
|
||||
fc_param_->col_8_ = UP_ROUND(fc_param_->col_, 8);
|
||||
|
@ -60,8 +60,8 @@ int FullconnectionCPUKernel::Init() {
|
|||
|
||||
bias_ptr_ = reinterpret_cast<float *>(malloc(fc_param_->col_8_ * sizeof(float)));
|
||||
memset(bias_ptr_, 0, fc_param_->col_8_ * sizeof(float));
|
||||
if (inputs_.size() == 3) {
|
||||
memcpy(bias_ptr_, inputs_[2]->Data(), fc_param_->col_ * sizeof(float));
|
||||
if (in_tensors_.size() == 3) {
|
||||
memcpy(bias_ptr_, in_tensors_[2]->Data(), fc_param_->col_ * sizeof(float));
|
||||
}
|
||||
|
||||
a_c8_ptr_ = reinterpret_cast<float *>(malloc(fc_param_->row_8_ * fc_param_->deep_ * sizeof(float)));
|
||||
|
@ -75,7 +75,7 @@ int FullconnectionCPUKernel::Init() {
|
|||
return RET_MEMORY_FAILED;
|
||||
}
|
||||
memset(b_r8_ptr_, 0, fc_param_->col_8_ * fc_param_->deep_ * sizeof(float));
|
||||
RowMajor2Col8Major(reinterpret_cast<float *>(inputs_[1]->Data()), b_r8_ptr_, fc_param_->col_, fc_param_->deep_);
|
||||
RowMajor2Col8Major(reinterpret_cast<float *>(in_tensors_[1]->Data()), b_r8_ptr_, fc_param_->col_, fc_param_->deep_);
|
||||
|
||||
c_r8x8_ptr_ = reinterpret_cast<float *>(malloc(fc_param_->row_8_ * fc_param_->col_8_ * sizeof(float)));
|
||||
if (c_r8x8_ptr_ == nullptr) {
|
||||
|
@ -114,8 +114,8 @@ int FullconnectionCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto a_ptr = reinterpret_cast<float *>(inputs_.at(0)->Data());
|
||||
auto output_ptr = reinterpret_cast<float *>(outputs_.at(0)->Data());
|
||||
auto a_ptr = reinterpret_cast<float *>(in_tensors_.at(0)->Data());
|
||||
auto output_ptr = reinterpret_cast<float *>(out_tensors_.at(0)->Data());
|
||||
|
||||
RowMajor2Col8Major(a_ptr, a_c8_ptr_, fc_param_->row_, fc_param_->deep_);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ FusedBatchnormCPUKernel::~FusedBatchnormCPUKernel() {
|
|||
}
|
||||
|
||||
int FusedBatchnormCPUKernel::InitConstTensor() {
|
||||
auto scale = inputs_[1];
|
||||
auto scale = in_tensors_[1];
|
||||
scale_addr_ = reinterpret_cast<float *>(malloc(scale->ElementsNum() * sizeof(float)));
|
||||
if (scale_addr_ == nullptr) {
|
||||
MS_LOG(ERROR) << "Malloc buffer failed.";
|
||||
|
@ -55,7 +55,7 @@ int FusedBatchnormCPUKernel::InitConstTensor() {
|
|||
}
|
||||
memcpy(scale_addr_, scale->Data(), scale->ElementsNum() * sizeof(float));
|
||||
|
||||
auto offset = inputs_[2];
|
||||
auto offset = in_tensors_[2];
|
||||
offset_addr_ = reinterpret_cast<float *>(malloc(offset->ElementsNum() * sizeof(float)));
|
||||
if (offset_addr_ == nullptr) {
|
||||
MS_LOG(ERROR) << "Malloc buffer failed.";
|
||||
|
@ -63,7 +63,7 @@ int FusedBatchnormCPUKernel::InitConstTensor() {
|
|||
}
|
||||
memcpy(offset_addr_, offset->Data(), offset->ElementsNum() * sizeof(float));
|
||||
|
||||
auto mean = inputs_[3];
|
||||
auto mean = in_tensors_[3];
|
||||
mean_addr_ = reinterpret_cast<float *>(malloc(mean->ElementsNum() * sizeof(float)));
|
||||
if (mean_addr_ == nullptr) {
|
||||
MS_LOG(ERROR) << "Malloc buffer failed.";
|
||||
|
@ -71,7 +71,7 @@ int FusedBatchnormCPUKernel::InitConstTensor() {
|
|||
}
|
||||
memcpy(mean_addr_, mean->Data(), mean->ElementsNum() * sizeof(float));
|
||||
|
||||
auto variance = inputs_[4];
|
||||
auto variance = in_tensors_[4];
|
||||
var_addr_ = reinterpret_cast<float *>(malloc(variance->ElementsNum() * sizeof(float)));
|
||||
if (var_addr_ == nullptr) {
|
||||
MS_LOG(ERROR) << "Malloc buffer failed.";
|
||||
|
@ -83,10 +83,10 @@ int FusedBatchnormCPUKernel::InitConstTensor() {
|
|||
|
||||
int FusedBatchnormCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
auto input_shapes = inputs_[0]->shape();
|
||||
auto input_shapes = in_tensors_[0]->shape();
|
||||
auto n_dim = input_shapes.size();
|
||||
batchnorm_param_->channel_ = input_shapes[n_dim - 1];
|
||||
batchnorm_param_->unit_ = 1;
|
||||
|
@ -105,7 +105,7 @@ int FusedBatchnormCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int FusedBatchnormCPUKernel::ReSize() {
|
||||
auto input_shapes = inputs_[0]->shape();
|
||||
auto input_shapes = in_tensors_[0]->shape();
|
||||
batchnorm_param_->unit_ = 1;
|
||||
for (int i = 0; i < input_shapes.size() - 1; i++) {
|
||||
batchnorm_param_->unit_ *= input_shapes[i];
|
||||
|
@ -134,8 +134,8 @@ int FusedBatchnormCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail! Ret error code: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
in_addr_ = reinterpret_cast<float *>(inputs_.at(0)->Data());
|
||||
out_addr_ = reinterpret_cast<float *>(outputs_.at(0)->Data());
|
||||
in_addr_ = reinterpret_cast<float *>(in_tensors_.at(0)->Data());
|
||||
out_addr_ = reinterpret_cast<float *>(out_tensors_.at(0)->Data());
|
||||
|
||||
int ret = LiteBackendParallelLaunch(FusedBatchNormRun, this, batchnorm_param_->op_parameter_.thread_num_);
|
||||
if (ret != RET_OK) {
|
||||
|
|
|
@ -30,17 +30,17 @@ using mindspore::schema::PrimitiveType_Gather;
|
|||
namespace mindspore::kernel {
|
||||
|
||||
int GatherCPUKernel::Init() {
|
||||
axis_ = (reinterpret_cast<GatherParameter *>(opParameter))->axis_;
|
||||
batchDims_ = (reinterpret_cast<GatherParameter *>(opParameter))->batchDims_;
|
||||
axis_ = (reinterpret_cast<GatherParameter *>(op_parameter_))->axis_;
|
||||
batchDims_ = (reinterpret_cast<GatherParameter *>(op_parameter_))->batchDims_;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int GatherCPUKernel::ReSize() { return RET_OK; }
|
||||
|
||||
int GatherCPUKernel::DoGather(int task_id) {
|
||||
auto input_tensor = inputs_.at(0);
|
||||
auto indices_tensor = inputs_.at(1);
|
||||
auto out_tensor = outputs_.at(0);
|
||||
auto input_tensor = in_tensors_.at(0);
|
||||
auto indices_tensor = in_tensors_.at(1);
|
||||
auto out_tensor = out_tensors_.at(0);
|
||||
|
||||
auto input_ptr = reinterpret_cast<float *>(input_tensor->Data());
|
||||
auto indices_ptr = reinterpret_cast<int *>(indices_tensor->Data());
|
||||
|
|
|
@ -39,10 +39,10 @@ GatherNdCPUKernel::~GatherNdCPUKernel() {
|
|||
|
||||
int GatherNdCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
auto indices_tensor = inputs_.at(1);
|
||||
auto indices_tensor = in_tensors_.at(1);
|
||||
auto indices_shape = indices_tensor->shape();
|
||||
int indices_rank = indices_shape.size();
|
||||
count_ = 1;
|
||||
|
@ -64,9 +64,9 @@ int GatherNdCPUKernel::Init() {
|
|||
}
|
||||
|
||||
int GatherNdCPUKernel::ReSize() {
|
||||
auto in_shape = inputs_.front()->shape();
|
||||
auto in_shape = in_tensors_.front()->shape();
|
||||
int in_rank = in_shape.size();
|
||||
auto indices_tensor = inputs_.at(1);
|
||||
auto indices_tensor = in_tensors_.at(1);
|
||||
auto indices_shape = indices_tensor->shape();
|
||||
int indices_rank = indices_shape.size();
|
||||
int idx_lastshape = indices_shape[indices_rank - 1];
|
||||
|
@ -121,8 +121,8 @@ int GatherNdCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
in_ptr_ = reinterpret_cast<float *>(inputs_.front()->Data());
|
||||
out_ptr_ = reinterpret_cast<float *>(outputs_.front()->Data());
|
||||
in_ptr_ = reinterpret_cast<float *>(in_tensors_.front()->Data());
|
||||
out_ptr_ = reinterpret_cast<float *>(out_tensors_.front()->Data());
|
||||
auto ret = LiteBackendParallelLaunch(GatherNdRun, this, thread_sz_count_);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "gatherNd error error_code[" << ret << "]";
|
||||
|
|
|
@ -34,8 +34,8 @@ int LocalResponseNormCPUKernel::Init() { return RET_OK; }
|
|||
int LocalResponseNormCPUKernel::ReSize() { return RET_OK; }
|
||||
|
||||
int LocalResponseNormCPUKernel::DoLocalResponseNorm(int task_id) {
|
||||
auto input_tensor = inputs_.front();
|
||||
auto out_tensor = outputs_.front();
|
||||
auto input_tensor = in_tensors_.front();
|
||||
auto out_tensor = out_tensors_.front();
|
||||
auto input_ptr = reinterpret_cast<float *>(input_tensor->Data());
|
||||
auto output_ptr = reinterpret_cast<float *>(out_tensor->Data());
|
||||
|
||||
|
@ -55,7 +55,7 @@ int LocalResponseNormCPUKernel::DoLocalResponseNorm(int task_id) {
|
|||
output_ptr += stride * task_id * channel;
|
||||
|
||||
auto error_code = LocalResponseNorm(input_ptr, count, channel, output_ptr,
|
||||
reinterpret_cast<LocalResponseNormParameter *>(opParameter));
|
||||
reinterpret_cast<LocalResponseNormParameter *>(op_parameter_));
|
||||
if (error_code != RET_OK) {
|
||||
MS_LOG(ERROR) << "DoLocalResponseNorm error task_id[" << task_id << "] error_code[" << error_code << "]";
|
||||
return RET_ERROR;
|
||||
|
|
|
@ -28,14 +28,14 @@ using mindspore::schema::PrimitiveType_Lstm;
|
|||
|
||||
namespace mindspore::kernel {
|
||||
int LstmCPUKernel::InitParam() {
|
||||
auto input = inputs_.front();
|
||||
auto input = in_tensors_.front();
|
||||
MS_ASSERT(input != nullptr);
|
||||
std::vector<int> in_shape = input->shape();
|
||||
lstm_parm_->seq_len_ = in_shape[0];
|
||||
lstm_parm_->batch_ = in_shape[1];
|
||||
lstm_parm_->input_size_ = in_shape[2];
|
||||
|
||||
auto weight_i = inputs_[1];
|
||||
auto weight_i = in_tensors_[1];
|
||||
MS_ASSERT(weight_i != nullptr);
|
||||
std::vector<int> w_shape = weight_i->shape();
|
||||
lstm_parm_->hidden_size_ = w_shape[1] / 4;
|
||||
|
@ -57,7 +57,7 @@ int LstmCPUKernel::InitBuffer() {
|
|||
|
||||
int LstmCPUKernel::InitWeightBias() {
|
||||
// copy weight_i and weight_h
|
||||
auto weight_i = inputs_.at(1);
|
||||
auto weight_i = in_tensors_.at(1);
|
||||
MS_ASSERT(weight_i != nullptr);
|
||||
weight_i_ptr_ = reinterpret_cast<float *>(malloc(weight_i->ElementsNum() * sizeof(float)));
|
||||
if (weight_i_ptr_ == nullptr) {
|
||||
|
@ -66,7 +66,7 @@ int LstmCPUKernel::InitWeightBias() {
|
|||
}
|
||||
memcpy(weight_i_ptr_, weight_i->Data(), weight_i->ElementsNum() * sizeof(float));
|
||||
|
||||
auto weight_h = inputs_.at(2);
|
||||
auto weight_h = in_tensors_.at(2);
|
||||
MS_ASSERT(weight_h != nullptr);
|
||||
weight_h_ptr_ = reinterpret_cast<float *>(malloc(weight_h->ElementsNum() * sizeof(float)));
|
||||
if (weight_h_ptr_ == nullptr) {
|
||||
|
@ -83,7 +83,7 @@ int LstmCPUKernel::InitWeightBias() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
|
||||
auto bias_data = reinterpret_cast<float *>(inputs_.at(3)->Data());
|
||||
auto bias_data = reinterpret_cast<float *>(in_tensors_.at(3)->Data());
|
||||
int state_bias_offset = 4 * lstm_parm_->hidden_size_;
|
||||
for (int i = 0; i < state_bias_offset; i++) {
|
||||
bias_ptr_[i] = bias_data[i] + bias_data[i + state_bias_offset];
|
||||
|
@ -100,7 +100,7 @@ int LstmCPUKernel::InitWeightBias() {
|
|||
|
||||
int LstmCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
auto ret = InitParam();
|
||||
|
@ -146,21 +146,21 @@ int LstmCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto input = inputs_.at(kInputIndex);
|
||||
auto input = in_tensors_.at(kInputIndex);
|
||||
MS_ASSERT(input != nullptr);
|
||||
auto hidden_state = inputs_.at(4);
|
||||
auto hidden_state = in_tensors_.at(4);
|
||||
MS_ASSERT(hidden_state != nullptr);
|
||||
auto cell_state = inputs_.at(5);
|
||||
auto cell_state = in_tensors_.at(5);
|
||||
MS_ASSERT(cell_state != nullptr);
|
||||
auto output = outputs_.at(0);
|
||||
auto output = out_tensors_.at(0);
|
||||
MS_ASSERT(output != nullptr);
|
||||
|
||||
auto input_ptr = reinterpret_cast<float *>(input->Data());
|
||||
auto output_ptr = reinterpret_cast<float *>(output->Data());
|
||||
|
||||
auto output_hidden_state = outputs_[1];
|
||||
auto output_hidden_state = out_tensors_[1];
|
||||
memcpy(output_hidden_state->Data(), hidden_state->Data(), hidden_state->ElementsNum() * sizeof(float));
|
||||
auto output_cell_state = outputs_[2];
|
||||
auto output_cell_state = out_tensors_[2];
|
||||
memcpy(output_cell_state->Data(), cell_state->Data(), cell_state->ElementsNum() * sizeof(float));
|
||||
|
||||
Lstm(output_ptr, input_ptr, weight_i_ptr_, weight_h_ptr_, bias_ptr_,
|
||||
|
|
|
@ -28,7 +28,7 @@ class LstmCPUKernel : public LiteKernel {
|
|||
const std::vector<lite::tensor::Tensor *> &outputs, const lite::Context *ctx,
|
||||
const lite::Primitive *primitive)
|
||||
: LiteKernel(parameter, inputs, outputs, ctx, primitive) {
|
||||
lstm_parm_ = reinterpret_cast<LstmParameter *>(opParameter);
|
||||
lstm_parm_ = reinterpret_cast<LstmParameter *>(op_parameter_);
|
||||
}
|
||||
|
||||
~LstmCPUKernel() override {
|
||||
|
|
|
@ -34,12 +34,12 @@ int MatmulCPUKernel::ReSize() { return RET_OK; }
|
|||
|
||||
int MatmulCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
int batch = 1;
|
||||
auto a_shape = inputs_[0]->shape();
|
||||
auto c_shape = outputs_[0]->shape();
|
||||
auto a_shape = in_tensors_[0]->shape();
|
||||
auto c_shape = out_tensors_[0]->shape();
|
||||
for (int i = 0; i < a_shape.size() - 2; ++i) {
|
||||
batch *= a_shape[i];
|
||||
}
|
||||
|
@ -97,9 +97,9 @@ int MatmulCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto a_ptr = reinterpret_cast<float *>(inputs_[0]->Data());
|
||||
auto b_ptr = reinterpret_cast<float *>(inputs_[1]->Data());
|
||||
auto c_ptr = reinterpret_cast<float *>(outputs_[0]->Data());
|
||||
auto a_ptr = reinterpret_cast<float *>(in_tensors_[0]->Data());
|
||||
auto b_ptr = reinterpret_cast<float *>(in_tensors_[1]->Data());
|
||||
auto c_ptr = reinterpret_cast<float *>(out_tensors_[0]->Data());
|
||||
auto a_stride = params_->row_ * params_->deep_;
|
||||
auto b_stride = params_->deep_ * params_->col_;
|
||||
auto c_stride = params_->row_ * params_->col_;
|
||||
|
|
|
@ -33,8 +33,8 @@ int Nchw2NhwcCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto input = inputs_[0];
|
||||
auto output = outputs_[0];
|
||||
auto input = in_tensors_[0];
|
||||
auto output = out_tensors_[0];
|
||||
|
||||
if (input->shape().size() == 4) {
|
||||
PackNCHWToNHWCFp32(input->Data(), output->Data(), output->Batch(), output->Height() * output->Width(),
|
||||
|
|
|
@ -33,8 +33,8 @@ int Nhwc2NchwCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto input = inputs_[0];
|
||||
auto output = outputs_[0];
|
||||
auto input = in_tensors_[0];
|
||||
auto output = out_tensors_[0];
|
||||
|
||||
if (input->shape().size() == 4) {
|
||||
PackNHWCToNCHWFp32(input->Data(), output->Data(), output->Batch(), output->Height() * output->Width(),
|
||||
|
|
|
@ -36,17 +36,17 @@ constexpr size_t kOutputNum = 1;
|
|||
|
||||
int OneHotCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
// indices depth on_value off_value
|
||||
if (inputs_.size() != kInputNum || outputs_.size() != kOutputNum) {
|
||||
MS_LOG(ERROR) << "OneHot input size should be " << kInputNum << ", got " << inputs_.size()
|
||||
<< ", output size should be" << kOutputNum << ", got " << outputs_.size();
|
||||
if (in_tensors_.size() != kInputNum || out_tensors_.size() != kOutputNum) {
|
||||
MS_LOG(ERROR) << "OneHot input size should be " << kInputNum << ", got " << in_tensors_.size()
|
||||
<< ", output size should be" << kOutputNum << ", got " << out_tensors_.size();
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
auto indices = inputs_.at(0);
|
||||
auto indices = in_tensors_.at(0);
|
||||
if (indices == nullptr) {
|
||||
MS_LOG(ERROR) << "OneHot inputs[0] indices nullptr";
|
||||
return RET_NULL_PTR;
|
||||
|
@ -64,7 +64,7 @@ int OneHotCPUKernel::Init() {
|
|||
}
|
||||
thread_num_ = context_->thread_num_;
|
||||
|
||||
const int indices_rank = static_cast<int>(inputs_.at(0)->shape().size());
|
||||
const int indices_rank = static_cast<int>(in_tensors_.at(0)->shape().size());
|
||||
if (axis_ < 0) {
|
||||
axis_ += indices_rank + 1;
|
||||
}
|
||||
|
@ -87,8 +87,8 @@ int RunOneHot(int task_id, LiteParallelGroupEnv *penv, void *cdata) {
|
|||
}
|
||||
|
||||
int OneHotCPUKernel::OneHotImpl(int task_id) {
|
||||
auto indices_data = static_cast<int *>(inputs_.at(0)->Data());
|
||||
auto output = outputs_.at(0);
|
||||
auto indices_data = static_cast<int *>(in_tensors_.at(0)->Data());
|
||||
auto output = out_tensors_.at(0);
|
||||
if (output == nullptr) {
|
||||
MS_LOG(ERROR) << "OneHot output nullptr";
|
||||
return RET_NULL_PTR;
|
||||
|
@ -99,20 +99,20 @@ int OneHotCPUKernel::OneHotImpl(int task_id) {
|
|||
if (ret != RET_OK) {
|
||||
return ret;
|
||||
}
|
||||
auto one_hot_param = reinterpret_cast<OneHotParameter *>(opParameter);
|
||||
auto one_hot_param = reinterpret_cast<OneHotParameter *>(op_parameter_);
|
||||
|
||||
ret = OneHot(indices_data, output_data, one_hot_param, task_id, thread_num_);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int OneHotCPUKernel::GetParams() {
|
||||
auto one_hot_param = reinterpret_cast<OneHotParameter *>(opParameter);
|
||||
auto one_hot_param = reinterpret_cast<OneHotParameter *>(op_parameter_);
|
||||
if (one_hot_param == nullptr) {
|
||||
MS_LOG(ERROR) << "cast OneHotParameter nullptr";
|
||||
return RET_NULL_PTR;
|
||||
}
|
||||
|
||||
auto depth_tensor = inputs_.at(1);
|
||||
auto depth_tensor = in_tensors_.at(1);
|
||||
if (depth_tensor == nullptr) {
|
||||
MS_LOG(ERROR) << "OneHot inputs[1] depth nullptr";
|
||||
return RET_NULL_PTR;
|
||||
|
@ -123,7 +123,7 @@ int OneHotCPUKernel::GetParams() {
|
|||
}
|
||||
one_hot_param->depth_ = *depth;
|
||||
|
||||
auto on_value_tensor = inputs_.at(2);
|
||||
auto on_value_tensor = in_tensors_.at(2);
|
||||
if (on_value_tensor == nullptr) {
|
||||
MS_LOG(ERROR) << "OneHot inputs[2] on_value nullptr";
|
||||
return RET_NULL_PTR;
|
||||
|
@ -134,7 +134,7 @@ int OneHotCPUKernel::GetParams() {
|
|||
}
|
||||
one_hot_param->on_value_ = *on_value;
|
||||
|
||||
auto off_value_tensor = inputs_.at(3);
|
||||
auto off_value_tensor = in_tensors_.at(3);
|
||||
if (off_value_tensor == nullptr) {
|
||||
MS_LOG(ERROR) << "OneHot inputs[3] off_value nullptr";
|
||||
return RET_NULL_PTR;
|
||||
|
|
|
@ -37,17 +37,17 @@ constexpr int kOutputNum = 1;
|
|||
|
||||
int PadCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
if (inputs_.size() != kInputNum || outputs_.size() != kOutputNum) {
|
||||
MS_LOG(ERROR) << "Pad input size should be " << kInputNum << ", got " << inputs_.size() << ", output size should be"
|
||||
<< kOutputNum << ", got " << outputs_.size();
|
||||
if (in_tensors_.size() != kInputNum || out_tensors_.size() != kOutputNum) {
|
||||
MS_LOG(ERROR) << "Pad input size should be " << kInputNum << ", got " << in_tensors_.size()
|
||||
<< ", output size should be" << kOutputNum << ", got " << out_tensors_.size();
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
auto input = inputs_.at(0);
|
||||
auto output = outputs_.at(0);
|
||||
auto input = in_tensors_.at(0);
|
||||
auto output = out_tensors_.at(0);
|
||||
if (input == nullptr || output == nullptr) {
|
||||
MS_LOG(ERROR) << "Pad input or output nullptr";
|
||||
return RET_NULL_PTR;
|
||||
|
@ -77,8 +77,8 @@ int PadImpl(int task_id, LiteParallelGroupEnv *penv, void *cdata) {
|
|||
}
|
||||
|
||||
int PadCPUKernel::RunImpl(int task_id) {
|
||||
auto input = inputs_.at(0);
|
||||
auto output = outputs_.at(0);
|
||||
auto input = in_tensors_.at(0);
|
||||
auto output = out_tensors_.at(0);
|
||||
|
||||
auto input_data = reinterpret_cast<float *>(input->Data());
|
||||
auto output_data = reinterpret_cast<float *>(output->Data());
|
||||
|
@ -94,7 +94,7 @@ int PadCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto output = outputs_.at(0);
|
||||
auto output = out_tensors_.at(0);
|
||||
int output_size = output->DataSize();
|
||||
|
||||
auto output_data = reinterpret_cast<float *>(output->Data());
|
||||
|
|
|
@ -30,7 +30,7 @@ using mindspore::schema::PrimitiveType_Pooling;
|
|||
namespace mindspore::kernel {
|
||||
int PoolingCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
auto ret = PoolingBaseCPUKernel::Init();
|
||||
|
@ -51,8 +51,8 @@ int PoolingCPUKernel::ReSize() {
|
|||
}
|
||||
|
||||
int PoolingCPUKernel::RunImpl(int task_id) {
|
||||
auto input_ptr = reinterpret_cast<float *>(inputs_.at(kInputIndex)->Data());
|
||||
auto output_ptr = reinterpret_cast<float *>(outputs_.at(kOutputIndex)->Data());
|
||||
auto input_ptr = reinterpret_cast<float *>(in_tensors_.at(kInputIndex)->Data());
|
||||
auto output_ptr = reinterpret_cast<float *>(out_tensors_.at(kOutputIndex)->Data());
|
||||
if (pooling_param_->max_pooling_) {
|
||||
MaxPooling(input_ptr, output_ptr, pooling_param_, task_id);
|
||||
} else {
|
||||
|
|
|
@ -55,15 +55,15 @@ int PowerCPUKernel::Run() {
|
|||
}
|
||||
|
||||
int PowerCPUKernel::RunImpl(int task_id) {
|
||||
auto x_addr = reinterpret_cast<float *>(inputs_[0]->Data());
|
||||
auto output_addr = reinterpret_cast<float *>(outputs_[0]->Data());
|
||||
auto size = inputs_[0]->ElementsNum();
|
||||
auto x_addr = reinterpret_cast<float *>(in_tensors_[0]->Data());
|
||||
auto output_addr = reinterpret_cast<float *>(out_tensors_[0]->Data());
|
||||
auto size = in_tensors_[0]->ElementsNum();
|
||||
int stride = UP_DIV(size, thread_count_);
|
||||
int len = MSMIN(stride, size - stride * task_id);
|
||||
float *exp_addr = nullptr;
|
||||
bool broadcast = true;
|
||||
if (inputs_.size() == 2) {
|
||||
exp_addr = reinterpret_cast<float *>(inputs_[1]->Data());
|
||||
if (in_tensors_.size() == 2) {
|
||||
exp_addr = reinterpret_cast<float *>(in_tensors_[1]->Data());
|
||||
broadcast = false;
|
||||
}
|
||||
float *cur_exp;
|
||||
|
@ -82,8 +82,7 @@ kernel::LiteKernel *CpuPowerFp32KernelCreator(const std::vector<lite::tensor::Te
|
|||
const kernel::KernelKey &desc, const lite::Primitive *primitive) {
|
||||
MS_ASSERT(opParameter != nullptr);
|
||||
MS_ASSERT(desc.type == schema::PrimitiveType_Power);
|
||||
PowerCPUKernel *kernel =
|
||||
new (std::nothrow) PowerCPUKernel(opParameter, inputs, outputs, ctx, primitive);
|
||||
PowerCPUKernel *kernel = new (std::nothrow) PowerCPUKernel(opParameter, inputs, outputs, ctx, primitive);
|
||||
if (kernel == nullptr) {
|
||||
MS_LOG(ERROR) << "new PowerCPUKernel fail!";
|
||||
return nullptr;
|
||||
|
|
|
@ -31,9 +31,9 @@ class PowerCPUKernel : public LiteKernel {
|
|||
: LiteKernel(param, inputs, outputs, ctx, primitive),
|
||||
ctx_(ctx),
|
||||
thread_count_(ctx->thread_num_),
|
||||
power_(reinterpret_cast<PowerParameter *>(opParameter)->power_),
|
||||
scale_(reinterpret_cast<PowerParameter *>(opParameter)->scale_),
|
||||
shift_(reinterpret_cast<PowerParameter *>(opParameter)->shift_) {}
|
||||
power_(reinterpret_cast<PowerParameter *>(op_parameter_)->power_),
|
||||
scale_(reinterpret_cast<PowerParameter *>(op_parameter_)->scale_),
|
||||
shift_(reinterpret_cast<PowerParameter *>(op_parameter_)->shift_) {}
|
||||
~PowerCPUKernel() override = default;
|
||||
|
||||
int Init() override;
|
||||
|
|
|
@ -51,10 +51,10 @@ int PReluCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto input = inputs_.at(0);
|
||||
auto input = in_tensors_.at(0);
|
||||
prelu_param_->input_num_ = input->ElementsNum();
|
||||
input_data = reinterpret_cast<float *>(input->Data());
|
||||
output_data = reinterpret_cast<float *>(outputs_.at(0)->Data());
|
||||
output_data = reinterpret_cast<float *>(out_tensors_.at(0)->Data());
|
||||
|
||||
auto ret = LiteBackendParallelLaunch(PReluRun, this, prelu_param_->thread_num_);
|
||||
if (ret != RET_OK) {
|
||||
|
|
|
@ -32,7 +32,7 @@ class PReluCPUKernel : public LiteKernel {
|
|||
const std::vector<lite::tensor::Tensor *> &outputs, const lite::Context *ctx,
|
||||
const lite::Primitive *primitive)
|
||||
: LiteKernel(parameter, inputs, outputs, ctx, primitive), ctx_(ctx), thread_count_(ctx->thread_num_) {
|
||||
prelu_param_ = (reinterpret_cast<PReluParameter *>(opParameter));
|
||||
prelu_param_ = (reinterpret_cast<PReluParameter *>(op_parameter_));
|
||||
primitive_ = primitive;
|
||||
}
|
||||
~PReluCPUKernel() = default;
|
||||
|
|
|
@ -43,10 +43,10 @@ int RangeCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
size_t start = (reinterpret_cast<RangeParameter *>(opParameter))->start_;
|
||||
size_t limit = (reinterpret_cast<RangeParameter *>(opParameter))->limit_;
|
||||
size_t delta = (reinterpret_cast<RangeParameter *>(opParameter))->delta_;
|
||||
auto output_ptr = reinterpret_cast<float *>(outputs_.at(0)->Data());
|
||||
size_t start = (reinterpret_cast<RangeParameter *>(op_parameter_))->start_;
|
||||
size_t limit = (reinterpret_cast<RangeParameter *>(op_parameter_))->limit_;
|
||||
size_t delta = (reinterpret_cast<RangeParameter *>(op_parameter_))->delta_;
|
||||
auto output_ptr = reinterpret_cast<float *>(out_tensors_.at(0)->Data());
|
||||
Range(output_ptr, start, limit, delta);
|
||||
return RET_OK;
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ int RankCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
auto output_ptr = reinterpret_cast<float *>(outputs_.at(0)->Data());
|
||||
auto in_shape = inputs_[0]->shape();
|
||||
auto output_ptr = reinterpret_cast<float *>(out_tensors_.at(0)->Data());
|
||||
auto in_shape = in_tensors_[0]->shape();
|
||||
auto rank = in_shape.size();
|
||||
Rank(output_ptr, rank);
|
||||
return RET_OK;
|
||||
|
|
|
@ -43,20 +43,20 @@ constexpr size_t kOutputNum = 1;
|
|||
} // namespace
|
||||
|
||||
int ReduceCPUKernel::CheckInputsOutputs() {
|
||||
if (inputs_.size() != kInputNum) {
|
||||
MS_LOG(ERROR) << "Reduce inputs size should be " << kInputNum << " but got " << inputs_.size();
|
||||
if (in_tensors_.size() != kInputNum) {
|
||||
MS_LOG(ERROR) << "Reduce inputs size should be " << kInputNum << " but got " << in_tensors_.size();
|
||||
return RET_ERROR;
|
||||
}
|
||||
if (outputs_.size() != kOutputNum) {
|
||||
MS_LOG(ERROR) << "Reduce outputs size should be " << kOutputNum << " but got " << outputs_.size();
|
||||
if (out_tensors_.size() != kOutputNum) {
|
||||
MS_LOG(ERROR) << "Reduce outputs size should be " << kOutputNum << " but got " << out_tensors_.size();
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto input = inputs_.at(0);
|
||||
auto input = in_tensors_.at(0);
|
||||
if (input == nullptr) {
|
||||
MS_LOG(ERROR) << "Reduce input is nullptr";
|
||||
return RET_NULL_PTR;
|
||||
}
|
||||
auto output = outputs_.at(0);
|
||||
auto output = out_tensors_.at(0);
|
||||
if (output == nullptr) {
|
||||
MS_LOG(ERROR) << "Reduce output is nullptr";
|
||||
return RET_NULL_PTR;
|
||||
|
@ -65,7 +65,7 @@ int ReduceCPUKernel::CheckInputsOutputs() {
|
|||
}
|
||||
|
||||
int ReduceCPUKernel::CheckParameters() {
|
||||
size_t input_rank = inputs_.at(0)->shape().size();
|
||||
size_t input_rank = in_tensors_.at(0)->shape().size();
|
||||
if (static_cast<size_t>(num_axes_) > input_rank) {
|
||||
MS_LOG(ERROR) << "Reduce num of reduce axes " << num_axes_ << " larger than input rank " << input_rank;
|
||||
return RET_ERROR;
|
||||
|
@ -92,7 +92,7 @@ int ReduceCPUKernel::CheckParameters() {
|
|||
|
||||
int ReduceCPUKernel::Init() {
|
||||
if (context_->infer_shape_interrupt_ && !context_->running_) {
|
||||
SetNeedReInit();
|
||||
set_need_reinit();
|
||||
return RET_OK;
|
||||
}
|
||||
auto ret = CheckInputsOutputs();
|
||||
|
@ -162,8 +162,8 @@ int ReduceCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << prepare_ret;
|
||||
return prepare_ret;
|
||||
}
|
||||
tmp_shape_ = inputs_.at(0)->shape();
|
||||
src_data_ = static_cast<float *>(inputs_.at(0)->Data());
|
||||
tmp_shape_ = in_tensors_.at(0)->shape();
|
||||
src_data_ = static_cast<float *>(in_tensors_.at(0)->Data());
|
||||
for (int i = 0; i < data_buffers_.size(); ++i) {
|
||||
dst_data_ = data_buffers_[i];
|
||||
int axis = axes_[i];
|
||||
|
@ -195,7 +195,7 @@ int ReduceCPUKernel::Run() {
|
|||
inner_size_ *= tmp_shape_[i];
|
||||
}
|
||||
axis_size_ = tmp_shape_[last_reduce_axis];
|
||||
dst_data_ = reinterpret_cast<float *>(outputs_.at(0)->Data());
|
||||
dst_data_ = reinterpret_cast<float *>(out_tensors_.at(0)->Data());
|
||||
auto error_code = LiteBackendParallelLaunch(ReduceImpl, this, context_->thread_num_);
|
||||
if (error_code != RET_OK) {
|
||||
MS_LOG(ERROR) << "Reduce run error, error_code[" << error_code << "]";
|
||||
|
@ -206,7 +206,7 @@ int ReduceCPUKernel::Run() {
|
|||
}
|
||||
|
||||
int ReduceCPUKernel::MallocTmpBuffer() {
|
||||
auto input_shape = inputs_.at(0)->shape();
|
||||
auto input_shape = in_tensors_.at(0)->shape();
|
||||
for (auto i = 0; i < num_axes_ - 1; i++) {
|
||||
int axis = axes_[i];
|
||||
size_t size = 1;
|
||||
|
|
|
@ -41,9 +41,9 @@ int ReshapeCPUKernel::Run() {
|
|||
MS_LOG(ERROR) << "Prepare fail!ret: " << ret;
|
||||
return ret;
|
||||
}
|
||||
auto input_ptr = inputs_.at(kInputIndex)->Data();
|
||||
auto output_ptr = outputs_.at(kOutputIndex)->Data();
|
||||
size_t data_size = inputs_.at(kInputIndex)->Size();
|
||||
auto input_ptr = in_tensors_.at(kInputIndex)->Data();
|
||||
auto output_ptr = out_tensors_.at(kOutputIndex)->Data();
|
||||
size_t data_size = in_tensors_.at(kInputIndex)->Size();
|
||||
Reshape(input_ptr, output_ptr, data_size);
|
||||
return RET_OK;
|
||||
}
|
||||
|
|
|
@ -49,12 +49,12 @@ int ResizeImpl(int task_id, LiteParallelGroupEnv *penv, void *cdata) {
|
|||
}
|
||||
|
||||
int ResizeCPUKernel::RunImpl(int task_id) {
|
||||
auto input = inputs_.at(0);
|
||||
auto input = in_tensors_.at(0);
|
||||
auto input_data = reinterpret_cast<float *>(input->Data());
|
||||
if (input_data == nullptr) {
|
||||
return RET_NULL_PTR;
|
||||
}
|
||||
auto output_data = reinterpret_cast<float *>(outputs_.at(0)->Data());
|
||||
auto output_data = reinterpret_cast<float *>(out_tensors_.at(0)->Data());
|
||||
if (output_data == nullptr) {
|
||||
return RET_NULL_PTR;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ int ResizeCPUKernel::RunImpl(int task_id) {
|
|||
int ret = 0;
|
||||
switch (method_) {
|
||||
case static_cast<int>(schema::ResizeMethod_BILINEAR): {
|
||||
ret = ResizeBilinear(input_data, output_data, input_shape.data(), outputs_[0]->shape().data(),
|
||||
ret = ResizeBilinear(input_data, output_data, input_shape.data(), out_tensors_[0]->shape().data(),
|
||||
align_corners_, task_id, context_->thread_num_);
|
||||
break;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ int ResizeCPUKernel::RunImpl(int task_id) {
|
|||
MS_LOG(ERROR) << "ResizeNearestNeighbor not support align_corners.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
ret = ResizeNearestNeighbor(input_data, output_data, input_shape.data(), outputs_[0]->shape().data(), task_id,
|
||||
ret = ResizeNearestNeighbor(input_data, output_data, input_shape.data(), out_tensors_[0]->shape().data(), task_id,
|
||||
context_->thread_num_);
|
||||
break;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue