!29118 Refactor kernel mod class and its subclasses.
Merge pull request !29118 from TronZhang/refact_kernel_mod_class
This commit is contained in:
commit
af02897be7
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -48,12 +48,6 @@ AicpuOpKernelMod::~AicpuOpKernelMod() {
|
|||
ext_info_.clear();
|
||||
}
|
||||
|
||||
void AicpuOpKernelMod::SetInputSizeList(const std::vector<size_t> &size_list) { input_size_list_ = size_list; }
|
||||
const std::vector<size_t> &AicpuOpKernelMod::GetInputSizeList() const { return input_size_list_; }
|
||||
void AicpuOpKernelMod::SetOutputSizeList(const std::vector<size_t> &size_list) { output_size_list_ = size_list; }
|
||||
const std::vector<size_t> &AicpuOpKernelMod::GetOutputSizeList() const { return output_size_list_; }
|
||||
void AicpuOpKernelMod::SetWorkspaceSizeList(const std::vector<size_t> &size_list) { workspace_size_list_ = size_list; }
|
||||
const std::vector<size_t> &AicpuOpKernelMod::GetWorkspaceSizeList() const { return workspace_size_list_; }
|
||||
void AicpuOpKernelMod::SetInputList(const std::vector<int64_t> &input_list) { input_list_ = input_list; }
|
||||
void AicpuOpKernelMod::SetOutputList(const std::vector<int64_t> &output_list) { output_list_ = output_list; }
|
||||
void AicpuOpKernelMod::SetNodeDef(const std::string &node_def) { (void)node_def_str_.assign(node_def); }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -51,13 +51,6 @@ class AicpuOpKernelMod : public AscendKernelMod {
|
|||
*/
|
||||
void CreateCpuKernelInfo(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &outputs);
|
||||
|
||||
void SetInputSizeList(const std::vector<size_t> &size_list);
|
||||
void SetOutputSizeList(const std::vector<size_t> &size_list);
|
||||
void SetWorkspaceSizeList(const std::vector<size_t> &size_list);
|
||||
const std::vector<size_t> &GetInputSizeList() const override;
|
||||
const std::vector<size_t> &GetOutputSizeList() const override;
|
||||
const std::vector<size_t> &GetWorkspaceSizeList() const override;
|
||||
|
||||
protected:
|
||||
std::string args_;
|
||||
std::string ext_info_;
|
||||
|
@ -70,10 +63,6 @@ class AicpuOpKernelMod : public AscendKernelMod {
|
|||
private:
|
||||
std::vector<int64_t> input_list_;
|
||||
std::vector<int64_t> output_list_;
|
||||
|
||||
std::vector<size_t> input_size_list_;
|
||||
std::vector<size_t> output_size_list_;
|
||||
std::vector<size_t> workspace_size_list_;
|
||||
};
|
||||
|
||||
using AicpuOpKernelModPtr = std::shared_ptr<AicpuOpKernelMod>;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -37,18 +37,6 @@ constexpr uint32_t DEFAULT_BLOCK_DIM = 1;
|
|||
*/
|
||||
AkgKernelMod::AkgKernelMod(const KernelPackPtr &kernel_pack) : kernel_pack_(kernel_pack) {}
|
||||
|
||||
void AkgKernelMod::SetInputSizeList(const std::vector<size_t> &size_list) { input_size_list_ = size_list; }
|
||||
|
||||
void AkgKernelMod::SetOutputSizeList(const std::vector<size_t> &size_list) { output_size_list_ = size_list; }
|
||||
|
||||
void AkgKernelMod::SetWorkspaceSizeList(const std::vector<size_t> &size_list) { workspace_size_list_ = size_list; }
|
||||
|
||||
const std::vector<size_t> &AkgKernelMod::GetInputSizeList() const { return input_size_list_; }
|
||||
|
||||
const std::vector<size_t> &AkgKernelMod::GetOutputSizeList() const { return output_size_list_; }
|
||||
|
||||
const std::vector<size_t> &AkgKernelMod::GetWorkspaceSizeList() const { return workspace_size_list_; }
|
||||
|
||||
bool AkgKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs, void *stream_ptr) {
|
||||
if (stream_ptr == nullptr) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,13 +28,6 @@ class AkgKernelMod : public AscendKernelMod {
|
|||
public:
|
||||
explicit AkgKernelMod(const KernelPackPtr &kernel_pack);
|
||||
~AkgKernelMod() final {}
|
||||
|
||||
void SetInputSizeList(const std::vector<size_t> &size_list);
|
||||
void SetOutputSizeList(const std::vector<size_t> &size_list);
|
||||
void SetWorkspaceSizeList(const std::vector<size_t> &size_list);
|
||||
const std::vector<size_t> &GetInputSizeList() const override;
|
||||
const std::vector<size_t> &GetOutputSizeList() const override;
|
||||
const std::vector<size_t> &GetWorkspaceSizeList() const override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs, void *stream_ptr) override;
|
||||
std::vector<TaskInfoPtr> GenTask(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
|
@ -42,9 +35,6 @@ class AkgKernelMod : public AscendKernelMod {
|
|||
|
||||
private:
|
||||
KernelPackPtr kernel_pack_;
|
||||
std::vector<size_t> input_size_list_;
|
||||
std::vector<size_t> output_size_list_;
|
||||
std::vector<size_t> workspace_size_list_;
|
||||
};
|
||||
|
||||
using AkgKernelModPtr = std::shared_ptr<AkgKernelMod>;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,7 +28,7 @@ namespace mindspore {
|
|||
namespace kernel {
|
||||
void AkgCpuKernelBuilder::AkgSetKernelMod(const KernelPackPtr &kernel_pack,
|
||||
const AkgKernelJsonGenerator &json_generator, const AnfNodePtr &anf_node) {
|
||||
auto kernel_mod_ptr = std::make_shared<CpuKernelMod>(kernel_pack);
|
||||
auto kernel_mod_ptr = std::make_shared<AkgCpuKernelMod>(kernel_pack);
|
||||
kernel_mod_ptr->SetInputSizeList(json_generator.input_size_list());
|
||||
kernel_mod_ptr->SetOutputSizeList(json_generator.output_size_list());
|
||||
AnfAlgo::SetKernelMod(kernel_mod_ptr, anf_node.get());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -54,9 +54,9 @@ struct AkgCallBack {
|
|||
~AkgCallBack() = default;
|
||||
};
|
||||
|
||||
CpuKernelManagerPtr CpuKernelMod::kernelmanager_ = std::make_shared<CpuKernelManager>();
|
||||
AkgCpuKernelManagerPtr AkgCpuKernelMod::kernel_manager_ = std::make_shared<AkgCpuKernelManager>();
|
||||
|
||||
CpuKernelManager::~CpuKernelManager() {
|
||||
AkgCpuKernelManager::~AkgCpuKernelManager() {
|
||||
for (auto &cpu_func_pair : cpu_func_map_) {
|
||||
if (cpu_func_pair.second.second != nullptr) {
|
||||
(void)dlclose(cpu_func_pair.second.second);
|
||||
|
@ -64,7 +64,7 @@ CpuKernelManager::~CpuKernelManager() {
|
|||
}
|
||||
}
|
||||
|
||||
void *CpuKernelManager::SearchFunc(const std::string &kernel_name) const {
|
||||
void *AkgCpuKernelManager::SearchFunc(const std::string &kernel_name) const {
|
||||
auto iter = cpu_func_map_.find(kernel_name);
|
||||
if (iter == cpu_func_map_.end()) {
|
||||
return nullptr;
|
||||
|
@ -73,12 +73,12 @@ void *CpuKernelManager::SearchFunc(const std::string &kernel_name) const {
|
|||
}
|
||||
}
|
||||
|
||||
void *CpuKernelManager::SearchFuncWithSharedLock(const std::string &kernel_name) const {
|
||||
void *AkgCpuKernelManager::SearchFuncWithSharedLock(const std::string &kernel_name) const {
|
||||
std::shared_lock lock(mutex_);
|
||||
return SearchFunc(kernel_name);
|
||||
}
|
||||
|
||||
void *CpuKernelManager::GetFunction(const std::string &kernel_name) {
|
||||
void *AkgCpuKernelManager::GetFunction(const std::string &kernel_name) {
|
||||
if (auto func = SearchFuncWithSharedLock(kernel_name); func != nullptr) {
|
||||
return func;
|
||||
}
|
||||
|
@ -114,14 +114,14 @@ void *CpuKernelManager::GetFunction(const std::string &kernel_name) {
|
|||
return launch_func;
|
||||
}
|
||||
|
||||
CpuKernelMod::CpuKernelMod(const KernelPackPtr &kp) {
|
||||
AkgCpuKernelMod::AkgCpuKernelMod(const KernelPackPtr &kp) {
|
||||
auto js = nlohmann::json::parse(kp->GetJson()->contents, kp->GetJson()->contents + kp->GetJson()->len);
|
||||
kernel_name_ = js["kernelName"];
|
||||
launch_func_ = kernelmanager_->GetFunction(kernel_name_);
|
||||
launch_func_ = kernel_manager_->GetFunction(kernel_name_);
|
||||
}
|
||||
|
||||
bool CpuKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs, void *stream_ptr) {
|
||||
bool AkgCpuKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs, void *stream_ptr) {
|
||||
if (launch_func_ == nullptr) {
|
||||
MS_LOG(ERROR) << "GetFunction failed. kernel: " << kernel_name_;
|
||||
return false;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,13 +24,14 @@
|
|||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
#include "backend/kernel_compiler/kernel.h"
|
||||
#include "backend/kernel_compiler/cpu/cpu_kernel_mod.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class CpuKernelManager {
|
||||
class AkgCpuKernelManager {
|
||||
public:
|
||||
CpuKernelManager() = default;
|
||||
~CpuKernelManager();
|
||||
AkgCpuKernelManager() = default;
|
||||
~AkgCpuKernelManager();
|
||||
|
||||
void *GetFunction(const std::string &kernel_name);
|
||||
|
||||
|
@ -42,32 +43,23 @@ class CpuKernelManager {
|
|||
std::unordered_map<std::string, std::pair<void *, void *>> cpu_func_map_;
|
||||
mutable std::shared_mutex mutex_;
|
||||
};
|
||||
using CpuKernelManagerPtr = std::shared_ptr<CpuKernelManager>;
|
||||
class CpuKernelMod : public KernelMod {
|
||||
using AkgCpuKernelManagerPtr = std::shared_ptr<AkgCpuKernelManager>;
|
||||
class AkgCpuKernelMod : public CpuKernelMod {
|
||||
public:
|
||||
explicit CpuKernelMod(const KernelPackPtr &kp);
|
||||
~CpuKernelMod() = default;
|
||||
explicit AkgCpuKernelMod(const KernelPackPtr &kp);
|
||||
~AkgCpuKernelMod() = default;
|
||||
|
||||
void SetInputSizeList(const std::vector<size_t> &size_list) { input_size_list_ = size_list; }
|
||||
void SetOutputSizeList(const std::vector<size_t> &size_list) { output_size_list_ = size_list; }
|
||||
void SetWorkspaceSizeList(const std::vector<size_t> &size_list) { workspace_size_list_ = size_list; }
|
||||
const std::vector<size_t> &GetInputSizeList() const override { return input_size_list_; }
|
||||
const std::vector<size_t> &GetOutputSizeList() const override { return output_size_list_; }
|
||||
const std::vector<size_t> &GetWorkspaceSizeList() const override { return workspace_size_list_; }
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs, void *stream_ptr) override;
|
||||
|
||||
static CpuKernelManagerPtr kernelmanager_;
|
||||
static AkgCpuKernelManagerPtr kernel_manager_;
|
||||
|
||||
private:
|
||||
std::vector<size_t> input_size_list_;
|
||||
std::vector<size_t> output_size_list_;
|
||||
std::vector<size_t> workspace_size_list_; // workspace is not used in cpu kernel.
|
||||
void *launch_func_;
|
||||
std::string kernel_name_;
|
||||
};
|
||||
|
||||
using CpuKernelModPtr = std::shared_ptr<CpuKernelMod>;
|
||||
using AkgCpuKernelModPtr = std::shared_ptr<AkgCpuKernelMod>;
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_AKG_CPU_AKG_CPU_KERNEL_MOD_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -30,7 +30,7 @@ constexpr int32_t ARGS_SIZE = 1;
|
|||
|
||||
void AkgGpuKernelBuilder::AkgSetKernelMod(const KernelPackPtr &kernel_pack,
|
||||
const AkgKernelJsonGenerator &json_generator, const AnfNodePtr &anf_node) {
|
||||
auto kernel_mod_ptr = std::make_shared<GpuKernelMod>(kernel_pack);
|
||||
auto kernel_mod_ptr = std::make_shared<AkgGpuKernelMod>(kernel_pack);
|
||||
auto kernel_json_info = kernel_pack->kernel_json_info();
|
||||
kernel_mod_ptr->SetInputSizeList(json_generator.input_size_list());
|
||||
kernel_mod_ptr->SetOutputSizeList(json_generator.output_size_list());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "backend/kernel_compiler/akg/gpu/akg_gpu_kernel_mod.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "utils/ms_utils.h"
|
||||
|
||||
|
@ -30,11 +31,11 @@ const int REGISTER_UNIT_IN_WARP = 256;
|
|||
const int WARP_SIZE = 32;
|
||||
const int WARP_ALLOC_GRAN = 4;
|
||||
|
||||
GpuKernelManagerPtr GpuKernelMod::kernelmanager_ = std::make_shared<GpuKernelManager>();
|
||||
GpuKernelManager::GpuKernelManager() {}
|
||||
AkgGpuKernelManagerPtr AkgGpuKernelMod::kernel_manager_ = std::make_shared<AkgGpuKernelManager>();
|
||||
AkgGpuKernelManager::AkgGpuKernelManager() {}
|
||||
|
||||
CUresult GpuKernelManager::GetFunction(const KernelPackPtr &kernel_pack, bool force_reload,
|
||||
vector<uint32_t> *thread_info, CUfunction *func) {
|
||||
CUresult AkgGpuKernelManager::GetFunction(const KernelPackPtr &kernel_pack, bool force_reload,
|
||||
vector<uint32_t> *thread_info, CUfunction *func) {
|
||||
if (kernel_pack->GetJson() == nullptr || kernel_pack->GetJson()->contents == nullptr ||
|
||||
kernel_pack->GetKernel() == nullptr || kernel_pack->GetKernel()->contents == nullptr) {
|
||||
MS_LOG(ERROR) << "GPU:Invalid kernel pack, json or kernel is nullptr.";
|
||||
|
@ -85,22 +86,10 @@ CUresult GpuKernelManager::GetFunction(const KernelPackPtr &kernel_pack, bool fo
|
|||
return result;
|
||||
}
|
||||
|
||||
GpuKernelMod::GpuKernelMod(const KernelPackPtr &kernel_pack) : kernel_pack_(kernel_pack) {}
|
||||
AkgGpuKernelMod::AkgGpuKernelMod(const KernelPackPtr &kernel_pack) : kernel_pack_(kernel_pack) {}
|
||||
|
||||
void GpuKernelMod::SetInputSizeList(const std::vector<size_t> &size_list) { input_size_list_ = size_list; }
|
||||
|
||||
void GpuKernelMod::SetOutputSizeList(const std::vector<size_t> &size_list) { output_size_list_ = size_list; }
|
||||
|
||||
void GpuKernelMod::SetWorkspaceSizeList(const std::vector<size_t> &size_list) { workspace_size_list_ = size_list; }
|
||||
|
||||
const std::vector<size_t> &GpuKernelMod::GetInputSizeList() const { return input_size_list_; }
|
||||
|
||||
const std::vector<size_t> &GpuKernelMod::GetOutputSizeList() const { return output_size_list_; }
|
||||
|
||||
const std::vector<size_t> &GpuKernelMod::GetWorkspaceSizeList() const { return workspace_size_list_; }
|
||||
|
||||
bool GpuKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs, void *stream_ptr) {
|
||||
bool AkgGpuKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs, void *stream_ptr) {
|
||||
if (stream_ptr == 0) {
|
||||
MS_LOG(ERROR) << "stream_ptr should not be nullptr.";
|
||||
return false;
|
||||
|
@ -111,7 +100,7 @@ bool GpuKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vect
|
|||
}
|
||||
vector<uint32_t> thread_info;
|
||||
CUfunction kernel_addr;
|
||||
CUresult result = kernelmanager_->GetFunction(kernel_pack_, false, &thread_info, &kernel_addr);
|
||||
CUresult result = kernel_manager_->GetFunction(kernel_pack_, false, &thread_info, &kernel_addr);
|
||||
if (result != CUDA_SUCCESS) {
|
||||
const char *msg = nullptr;
|
||||
cuGetErrorName(result, &msg);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -22,6 +22,7 @@
|
|||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include "backend/kernel_compiler/kernel.h"
|
||||
#include "backend/kernel_compiler/gpu/gpu_kernel_mod.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
|
@ -34,10 +35,10 @@ struct GpuKernelMeta {
|
|||
};
|
||||
using GpuKernelMetaPtr = std::shared_ptr<GpuKernelMeta>;
|
||||
|
||||
class GpuKernelManager {
|
||||
class AkgGpuKernelManager {
|
||||
public:
|
||||
GpuKernelManager();
|
||||
virtual ~GpuKernelManager() {
|
||||
AkgGpuKernelManager();
|
||||
virtual ~AkgGpuKernelManager() {
|
||||
for (auto iter = infotable_.begin(); iter != infotable_.end(); ++iter) {
|
||||
CUresult ret = cuModuleUnload(iter->second->module_);
|
||||
if (ret != CUDA_SUCCESS && ret != CUDA_ERROR_DEINITIALIZED) {
|
||||
|
@ -51,32 +52,23 @@ class GpuKernelManager {
|
|||
private:
|
||||
std::unordered_map<std::string, GpuKernelMetaPtr> infotable_;
|
||||
};
|
||||
using GpuKernelManagerPtr = std::shared_ptr<GpuKernelManager>;
|
||||
using AkgGpuKernelManagerPtr = std::shared_ptr<AkgGpuKernelManager>;
|
||||
|
||||
class GpuKernelMod : public KernelMod {
|
||||
class AkgGpuKernelMod : public GpuKernelMod {
|
||||
public:
|
||||
explicit GpuKernelMod(const KernelPackPtr &kernel_pack);
|
||||
virtual ~GpuKernelMod() {}
|
||||
explicit AkgGpuKernelMod(const KernelPackPtr &kernel_pack);
|
||||
virtual ~AkgGpuKernelMod() {}
|
||||
|
||||
void SetInputSizeList(const std::vector<size_t> &size_list);
|
||||
void SetOutputSizeList(const std::vector<size_t> &size_list);
|
||||
void SetWorkspaceSizeList(const std::vector<size_t> &size_list);
|
||||
const std::vector<size_t> &GetInputSizeList() const override;
|
||||
const std::vector<size_t> &GetOutputSizeList() const override;
|
||||
const std::vector<size_t> &GetWorkspaceSizeList() const override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs, void *stream_ptr) override;
|
||||
|
||||
static GpuKernelManagerPtr kernelmanager_;
|
||||
static AkgGpuKernelManagerPtr kernel_manager_;
|
||||
|
||||
private:
|
||||
KernelPackPtr kernel_pack_;
|
||||
std::vector<size_t> input_size_list_;
|
||||
std::vector<size_t> output_size_list_;
|
||||
std::vector<size_t> workspace_size_list_;
|
||||
};
|
||||
|
||||
using GpuKernelModPtr = std::shared_ptr<GpuKernelMod>;
|
||||
using AkgGpuKernelModPtr = std::shared_ptr<AkgGpuKernelMod>;
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -30,7 +30,8 @@ constexpr float kAdamBlock = 1000;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void AdamCPUKernel::LaunchAdam(const std::vector<kernel::AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &) {
|
||||
void AdamCpuKernelMod::LaunchAdam(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &) {
|
||||
T *var = reinterpret_cast<T *>(inputs[VAR]->addr);
|
||||
T *m = reinterpret_cast<T *>(inputs[M]->addr);
|
||||
T *v = reinterpret_cast<T *>(inputs[V]->addr);
|
||||
|
@ -64,8 +65,8 @@ void AdamCPUKernel::LaunchAdam(const std::vector<kernel::AddressPtr> &inputs, co
|
|||
ParallelLaunch(task, lens, kAdamBlock, this);
|
||||
}
|
||||
|
||||
void AdamCPUKernel::LaunchAdamNnacl(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &) {
|
||||
void AdamCpuKernelMod::LaunchAdamNnacl(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &) {
|
||||
float *var = reinterpret_cast<float *>(inputs[VAR]->addr);
|
||||
float *m = reinterpret_cast<float *>(inputs[M]->addr);
|
||||
float *v = reinterpret_cast<float *>(inputs[V]->addr);
|
||||
|
@ -93,7 +94,7 @@ void AdamCPUKernel::LaunchAdamNnacl(const std::vector<kernel::AddressPtr> &input
|
|||
ParallelLaunch(task, lens, kAdamBlock, this);
|
||||
}
|
||||
|
||||
void AdamCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void AdamCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
dtype_ = AnfAlgo::GetInputDeviceDataType(kernel_node, 0);
|
||||
|
@ -104,8 +105,8 @@ void AdamCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
|||
use_nesterov_ = AnfAlgo::GetNodeAttr<bool>(kernel_node, USE_NESTEROV);
|
||||
}
|
||||
|
||||
bool AdamCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool AdamCpuKernelMod::Launch(const std::vector<kernel::AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kAdamInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kAdamOutputsNum, kernel_name_);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class AdamCPUKernel : public CPUKernel {
|
||||
class AdamCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
AdamCPUKernel() = default;
|
||||
~AdamCPUKernel() override = default;
|
||||
AdamCpuKernelMod() = default;
|
||||
~AdamCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
|
@ -45,7 +45,7 @@ class AdamCPUKernel : public CPUKernel {
|
|||
enum input_list_ { VAR, M, V, BETA1_POWER, BETA2_POWER, LR, BETA1, BETA2, EPSILON, GRAD };
|
||||
};
|
||||
|
||||
MS_REG_CPU_KERNEL(Adam, KernelAttr(), AdamCPUKernel);
|
||||
MS_REG_CPU_KERNEL(Adam, KernelAttr(), AdamCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -32,8 +32,8 @@ constexpr size_t kAdamDeltaOutputsNum = 1;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void AdamDeltaCPUKernel::LaunchAdamDelta(T *delta, T *m, T *v, float lr, float beta1, float beta2, float epsilon,
|
||||
const T *gradient, size_t size) {
|
||||
void AdamDeltaCpuKernelMod::LaunchAdamDelta(T *delta, T *m, T *v, float lr, float beta1, float beta2, float epsilon,
|
||||
const T *gradient, size_t size) {
|
||||
std::function<void(size_t, size_t)> task;
|
||||
if (dtype_ == kNumberTypeFloat32) {
|
||||
task = [this, delta, m, v, lr, beta1, beta2, epsilon, gradient](size_t start, size_t end) {
|
||||
|
@ -57,7 +57,7 @@ void AdamDeltaCPUKernel::LaunchAdamDelta(T *delta, T *m, T *v, float lr, float b
|
|||
ParallelLaunchAutoSearch(task, size, this, ¶llel_search_info_);
|
||||
}
|
||||
|
||||
void AdamDeltaCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void AdamDeltaCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
std::vector<size_t> delta_shape = AnfAlgo::GetOutputDeviceShape(kernel_node, 0);
|
||||
|
@ -96,8 +96,8 @@ void AdamDeltaCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
}
|
||||
|
||||
void AdamDeltaCPUKernel::CheckParams(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &outputs) const {
|
||||
void AdamDeltaCpuKernelMod::CheckParams(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &outputs) const {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kAdamDeltaInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kAdamDeltaOutputsNum, kernel_name_);
|
||||
|
||||
|
@ -121,8 +121,9 @@ void AdamDeltaCPUKernel::CheckParams(const std::vector<kernel::AddressPtr> &inpu
|
|||
}
|
||||
}
|
||||
|
||||
bool AdamDeltaCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool AdamDeltaCpuKernelMod::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CheckParams(inputs, outputs);
|
||||
auto m = reinterpret_cast<float *>(inputs[0]->addr);
|
||||
auto v = reinterpret_cast<float *>(inputs[1]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,10 +24,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class AdamDeltaCPUKernel : public CPUKernel {
|
||||
class AdamDeltaCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
AdamDeltaCPUKernel() = default;
|
||||
~AdamDeltaCPUKernel() override = default;
|
||||
AdamDeltaCpuKernelMod() = default;
|
||||
~AdamDeltaCpuKernelMod() override = default;
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) override;
|
||||
|
@ -55,7 +55,7 @@ MS_REG_CPU_KERNEL(AdamNoUpdateParam,
|
|||
.AddInputAttr(kNumberTypeFloat32)
|
||||
.AddInputAttr(kNumberTypeFloat32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
AdamDeltaCPUKernel);
|
||||
AdamDeltaCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,8 +33,8 @@ constexpr size_t kAdamWeightDecayOutputsNum = 3;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void AdamWeightDecayCPUKernel::LaunchAdamWeightDecay(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &) {
|
||||
void AdamWeightDecayCpuKernelMod::LaunchAdamWeightDecay(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &) {
|
||||
T *var = reinterpret_cast<T *>(inputs[VAR]->addr);
|
||||
T *m = reinterpret_cast<T *>(inputs[M]->addr);
|
||||
T *v = reinterpret_cast<T *>(inputs[V]->addr);
|
||||
|
@ -64,8 +64,8 @@ void AdamWeightDecayCPUKernel::LaunchAdamWeightDecay(const std::vector<AddressPt
|
|||
ParallelLaunchAutoSearch(task, lens, this, ¶llel_search_info_);
|
||||
}
|
||||
|
||||
void AdamWeightDecayCPUKernel::LaunchAdamWeightDecayNnacl(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &) {
|
||||
void AdamWeightDecayCpuKernelMod::LaunchAdamWeightDecayNnacl(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &) {
|
||||
auto var = reinterpret_cast<float *>(inputs[VAR]->addr);
|
||||
auto m = reinterpret_cast<float *>(inputs[M]->addr);
|
||||
auto v = reinterpret_cast<float *>(inputs[V]->addr);
|
||||
|
@ -88,15 +88,15 @@ void AdamWeightDecayCPUKernel::LaunchAdamWeightDecayNnacl(const std::vector<Addr
|
|||
ParallelLaunchAutoSearch(task, lens, this, ¶llel_search_info_);
|
||||
}
|
||||
|
||||
void AdamWeightDecayCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void AdamWeightDecayCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
dtype_ = AnfAlgo::GetInputDeviceDataType(kernel_node, 0);
|
||||
}
|
||||
|
||||
bool AdamWeightDecayCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool AdamWeightDecayCpuKernelMod::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kAdamWeightDecayInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kAdamWeightDecayOutputsNum, kernel_name_);
|
||||
if (inputs[VAR]->size != inputs[M]->size) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class AdamWeightDecayCPUKernel : public CPUKernel {
|
||||
class AdamWeightDecayCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
AdamWeightDecayCPUKernel() = default;
|
||||
~AdamWeightDecayCPUKernel() override = default;
|
||||
AdamWeightDecayCpuKernelMod() = default;
|
||||
~AdamWeightDecayCpuKernelMod() override = default;
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) override;
|
||||
|
@ -42,7 +42,7 @@ class AdamWeightDecayCPUKernel : public CPUKernel {
|
|||
enum input_list_ { VAR, M, V, LR, BETA1, BETA2, EPSILON, DECAY, GRAD };
|
||||
};
|
||||
|
||||
MS_REG_CPU_KERNEL(AdamWeightDecay, KernelAttr(), AdamWeightDecayCPUKernel)
|
||||
MS_REG_CPU_KERNEL(AdamWeightDecay, KernelAttr(), AdamWeightDecayCpuKernelMod)
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -27,7 +27,7 @@ constexpr size_t kAllGatherOutputsNum = 1;
|
|||
constexpr auto kRanksGroup = "group";
|
||||
} // namespace
|
||||
|
||||
void AllGatherCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void AllGatherCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node);
|
||||
|
@ -35,8 +35,9 @@ void AllGatherCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
|||
ranks_group_ = AnfAlgo::GetNodeAttr<std::vector<int>>(kernel_node, kRanksGroup);
|
||||
}
|
||||
|
||||
bool AllGatherCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool AllGatherCpuKernelMod::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kAllGatherInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kAllGatherOutputsNum, kernel_name_);
|
||||
auto *input_addr = reinterpret_cast<float *>(inputs[0]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class AllGatherCPUKernel : public CPUKernel {
|
||||
class AllGatherCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
AllGatherCPUKernel() = default;
|
||||
~AllGatherCPUKernel() override = default;
|
||||
AllGatherCpuKernelMod() = default;
|
||||
~AllGatherCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -40,7 +40,7 @@ class AllGatherCPUKernel : public CPUKernel {
|
|||
};
|
||||
|
||||
MS_REG_CPU_KERNEL(_HostAllGather, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
AllGatherCPUKernel);
|
||||
AllGatherCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,15 +28,15 @@ constexpr size_t kApplyAdagradInputsNum = 4;
|
|||
constexpr size_t kApplyAdagradOutputsNum = 2;
|
||||
} // namespace
|
||||
|
||||
void ApplyAdagradCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void ApplyAdagradCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
update_slots_ = AnfAlgo::GetNodeAttr<bool>(kernel_node, "update_slots");
|
||||
dtype_ = AnfAlgo::GetInputDeviceDataType(kernel_node, 0);
|
||||
}
|
||||
|
||||
bool ApplyAdagradCPUKernel::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool ApplyAdagradCpuKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
CheckParam(inputs, outputs);
|
||||
if (dtype_ == kNumberTypeFloat16) {
|
||||
LaunchKernel<float16>(inputs, outputs);
|
||||
|
@ -49,8 +49,8 @@ bool ApplyAdagradCPUKernel::Launch(const std::vector<AddressPtr> &inputs, const
|
|||
return true;
|
||||
}
|
||||
|
||||
void ApplyAdagradCPUKernel::CheckParam(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) const {
|
||||
void ApplyAdagradCpuKernelMod::CheckParam(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) const {
|
||||
// inputs: var, accum, lr, gradient
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kApplyAdagradInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kApplyAdagradOutputsNum, kernel_name_);
|
||||
|
@ -74,8 +74,8 @@ void ApplyAdagradCPUKernel::CheckParam(const std::vector<AddressPtr> &inputs,
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ApplyAdagradCPUKernel::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
void ApplyAdagradCpuKernelMod::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
auto *var = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
auto *accum = reinterpret_cast<T *>(inputs[1]->addr);
|
||||
const auto *lr = reinterpret_cast<T *>(inputs[2]->addr);
|
||||
|
@ -102,8 +102,8 @@ void ApplyAdagradCPUKernel::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ApplyAdagradCPUKernel::LaunchApplyAdagrad(T *var, T *accum, const T *lr, const T *gradient, size_t start,
|
||||
size_t end) const {
|
||||
void ApplyAdagradCpuKernelMod::LaunchApplyAdagrad(T *var, T *accum, const T *lr, const T *gradient, size_t start,
|
||||
size_t end) const {
|
||||
// DataType can only be float32 or float16, so eps will not be zero.
|
||||
auto one = static_cast<T>(1);
|
||||
auto eps = static_cast<T>(1e-6);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class ApplyAdagradCPUKernel : public CPUKernel {
|
||||
class ApplyAdagradCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
ApplyAdagradCPUKernel() = default;
|
||||
~ApplyAdagradCPUKernel() override = default;
|
||||
ApplyAdagradCpuKernelMod() = default;
|
||||
~ApplyAdagradCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -56,7 +56,7 @@ MS_REG_CPU_KERNEL(ApplyAdagrad,
|
|||
.AddInputAttr(kNumberTypeFloat32)
|
||||
.AddOutputAttr(kNumberTypeFloat32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
ApplyAdagradCPUKernel);
|
||||
ApplyAdagradCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(ApplyAdagrad,
|
||||
KernelAttr()
|
||||
|
@ -66,7 +66,7 @@ MS_REG_CPU_KERNEL(ApplyAdagrad,
|
|||
.AddInputAttr(kNumberTypeFloat16)
|
||||
.AddOutputAttr(kNumberTypeFloat16)
|
||||
.AddOutputAttr(kNumberTypeFloat16),
|
||||
ApplyAdagradCPUKernel);
|
||||
ApplyAdagradCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,13 +24,14 @@ namespace {
|
|||
constexpr size_t kApplyMomentumInputsNum = 5;
|
||||
} // namespace
|
||||
|
||||
void ApplyMomentumCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void ApplyMomentumCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
}
|
||||
|
||||
bool ApplyMomentumCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &, const std::vector<kernel::AddressPtr> &) {
|
||||
bool ApplyMomentumCpuKernelMod::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kApplyMomentumInputsNum, kernel_name_);
|
||||
if (inputs[0]->size != inputs[1]->size) {
|
||||
MS_LOG(EXCEPTION) << "For '" << kernel_name_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class ApplyMomentumCPUKernel : public CPUKernel {
|
||||
class ApplyMomentumCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
ApplyMomentumCPUKernel() = default;
|
||||
~ApplyMomentumCPUKernel() override = default;
|
||||
ApplyMomentumCpuKernelMod() = default;
|
||||
~ApplyMomentumCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -44,7 +44,7 @@ MS_REG_CPU_KERNEL(ApplyMomentum,
|
|||
.AddInputAttr(kNumberTypeFloat32)
|
||||
.AddInputAttr(kNumberTypeFloat32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
ApplyMomentumCPUKernel);
|
||||
ApplyMomentumCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(ApplyMomentum,
|
||||
KernelAttr()
|
||||
.AddInputAttr(kNumberTypeFloat32)
|
||||
|
@ -54,7 +54,7 @@ MS_REG_CPU_KERNEL(ApplyMomentum,
|
|||
.AddInputAttr(kNumberTypeFloat32)
|
||||
.AddOutputAttr(kNumberTypeFloat32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
ApplyMomentumCPUKernel);
|
||||
ApplyMomentumCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -57,7 +57,7 @@ bool check_validation(const std::vector<size_t> &shape, const size_t num_before_
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void ArgmaxCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void ArgmaxCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
shape_ = AnfAlgo::GetInputDeviceShape(kernel_node, 0);
|
||||
|
@ -85,8 +85,9 @@ void ArgmaxCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool ArgmaxCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool ArgmaxCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
if (!check_validation<T>(shape_, num_before_axis_, num_after_axis_, inputs, outputs)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,10 +26,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class ArgmaxCPUKernel : public CPUKernel {
|
||||
class ArgmaxCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
ArgmaxCPUKernel() = default;
|
||||
~ArgmaxCPUKernel() override = default;
|
||||
ArgmaxCpuKernelMod() = default;
|
||||
~ArgmaxCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -43,8 +43,8 @@ class ArgmaxCPUKernel : public CPUKernel {
|
|||
size_t dim_axis_{0};
|
||||
};
|
||||
|
||||
MS_REG_CPU_KERNEL_T(Argmax, KernelAttr(), ArgmaxCPUKernel, float);
|
||||
MS_REG_CPU_KERNEL_T(Argmax, KernelAttr(), ArgmaxCPUKernel, float16);
|
||||
MS_REG_CPU_KERNEL_T(Argmax, KernelAttr(), ArgmaxCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(Argmax, KernelAttr(), ArgmaxCpuKernelMod, float16);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -61,7 +61,7 @@ bool check_validation(const std::vector<size_t> &shape, const size_t num_before_
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void ArgMaxWithValueCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void ArgMaxWithValueCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
shape_ = AnfAlgo::GetInputDeviceShape(kernel_node, 0);
|
||||
|
@ -86,9 +86,9 @@ void ArgMaxWithValueCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool ArgMaxWithValueCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool ArgMaxWithValueCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
if (!check_validation<T>(shape_, num_before_axis_, num_after_axis_, inputs, outputs)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,10 +28,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class ArgMaxWithValueCPUKernel : public CPUKernel {
|
||||
class ArgMaxWithValueCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
ArgMaxWithValueCPUKernel() = default;
|
||||
~ArgMaxWithValueCPUKernel() override = default;
|
||||
ArgMaxWithValueCpuKernelMod() = default;
|
||||
~ArgMaxWithValueCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -45,8 +45,8 @@ class ArgMaxWithValueCPUKernel : public CPUKernel {
|
|||
size_t dim_axis_{0};
|
||||
};
|
||||
|
||||
MS_REG_CPU_KERNEL_T(ArgMaxWithValue, KernelAttr(), ArgMaxWithValueCPUKernel, float);
|
||||
MS_REG_CPU_KERNEL_T(ArgMaxWithValue, KernelAttr(), ArgMaxWithValueCPUKernel, float16);
|
||||
MS_REG_CPU_KERNEL_T(ArgMaxWithValue, KernelAttr(), ArgMaxWithValueCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(ArgMaxWithValue, KernelAttr(), ArgMaxWithValueCpuKernelMod, float16);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -62,7 +62,7 @@ bool check_validation(const std::vector<size_t> &shape, const size_t num_before_
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void ArgMinWithValueCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void ArgMinWithValueCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
shape_ = AnfAlgo::GetInputDeviceShape(kernel_node, 0);
|
||||
|
@ -90,9 +90,9 @@ void ArgMinWithValueCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool ArgMinWithValueCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool ArgMinWithValueCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
if (!check_validation<T>(shape_, num_before_axis_, num_after_axis_, inputs, outputs)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,10 +28,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class ArgMinWithValueCPUKernel : public CPUKernel {
|
||||
class ArgMinWithValueCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
ArgMinWithValueCPUKernel() = default;
|
||||
~ArgMinWithValueCPUKernel() override = default;
|
||||
ArgMinWithValueCpuKernelMod() = default;
|
||||
~ArgMinWithValueCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -45,8 +45,8 @@ class ArgMinWithValueCPUKernel : public CPUKernel {
|
|||
size_t dim_axis_{0};
|
||||
};
|
||||
|
||||
MS_REG_CPU_KERNEL_T(ArgMinWithValue, KernelAttr(), ArgMinWithValueCPUKernel, float);
|
||||
MS_REG_CPU_KERNEL_T(ArgMinWithValue, KernelAttr(), ArgMinWithValueCPUKernel, float16);
|
||||
MS_REG_CPU_KERNEL_T(ArgMinWithValue, KernelAttr(), ArgMinWithValueCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(ArgMinWithValue, KernelAttr(), ArgMinWithValueCpuKernelMod, float16);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -62,7 +62,7 @@ void ElementRealDiv(const T *input1, const T *input2, T *out, size_t size, size_
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticCPUKernel<T>::AssignAdd(T *input1, const T *input2, T *out) {
|
||||
void ArithmeticCpuKernelMod<T>::AssignAdd(T *input1, const T *input2, T *out) {
|
||||
auto task = [&input1, &input2, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = input1[i] + input2[i];
|
||||
|
@ -73,7 +73,7 @@ void ArithmeticCPUKernel<T>::AssignAdd(T *input1, const T *input2, T *out) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticCPUKernel<T>::Add(const T *input1, const T *input2, T *out) {
|
||||
void ArithmeticCpuKernelMod<T>::Add(const T *input1, const T *input2, T *out) {
|
||||
BroadcastIterator base_iter(input_shape1_, input_shape2_, output_shape_);
|
||||
auto task = [&input1, &input2, &out, &base_iter](size_t start, size_t end) {
|
||||
auto iter = base_iter;
|
||||
|
@ -87,7 +87,7 @@ void ArithmeticCPUKernel<T>::Add(const T *input1, const T *input2, T *out) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticCPUKernel<T>::Sub(const T *input1, const T *input2, T *out) {
|
||||
void ArithmeticCpuKernelMod<T>::Sub(const T *input1, const T *input2, T *out) {
|
||||
if constexpr (std::is_same_v<T, float>) {
|
||||
if (input_shape1_ == input_shape2_) {
|
||||
auto task = [this, input1, input2, out](size_t start, size_t end) {
|
||||
|
@ -122,7 +122,7 @@ void ArithmeticCPUKernel<T>::Sub(const T *input1, const T *input2, T *out) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticCPUKernel<T>::Mul(const T *input1, const T *input2, T *out) {
|
||||
void ArithmeticCpuKernelMod<T>::Mul(const T *input1, const T *input2, T *out) {
|
||||
if constexpr (std::is_same_v<T, float>) {
|
||||
if (input_shape1_ == input_shape2_) {
|
||||
auto task = [this, input1, input2, out](size_t start, size_t end) {
|
||||
|
@ -156,7 +156,7 @@ void ArithmeticCPUKernel<T>::Mul(const T *input1, const T *input2, T *out) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticCPUKernel<T>::RealDiv(const T *input1, const T *input2, T *out) {
|
||||
void ArithmeticCpuKernelMod<T>::RealDiv(const T *input1, const T *input2, T *out) {
|
||||
if (input_shape1_ == input_shape2_) {
|
||||
auto task = [&](size_t start, size_t end) {
|
||||
ElementRealDiv<T>(input1 + start, input2 + start, out + start, end - start, 1, 1);
|
||||
|
@ -207,7 +207,7 @@ void ArithmeticCPUKernel<T>::RealDiv(const T *input1, const T *input2, T *out) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticCPUKernel<T>::Div(const T *input1, const T *input2, T *out) {
|
||||
void ArithmeticCpuKernelMod<T>::Div(const T *input1, const T *input2, T *out) {
|
||||
BroadcastIterator base_iter(input_shape1_, input_shape2_, output_shape_);
|
||||
auto task = [&input1, &input2, &out, &base_iter](size_t start, size_t end) {
|
||||
auto iter = base_iter;
|
||||
|
@ -236,7 +236,7 @@ void ArithmeticCPUKernel<T>::Div(const T *input1, const T *input2, T *out) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticCPUKernel<T>::FloorDiv(const T *input1, const T *input2, T *out) {
|
||||
void ArithmeticCpuKernelMod<T>::FloorDiv(const T *input1, const T *input2, T *out) {
|
||||
BroadcastIterator base_iter(input_shape1_, input_shape2_, output_shape_);
|
||||
auto task = [&input1, &input2, &out, &base_iter](size_t start, size_t end) {
|
||||
auto iter = base_iter;
|
||||
|
@ -265,7 +265,7 @@ void ArithmeticCPUKernel<T>::FloorDiv(const T *input1, const T *input2, T *out)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticCPUKernel<T>::Mod(const T *input1, const T *input2, T *out) {
|
||||
void ArithmeticCpuKernelMod<T>::Mod(const T *input1, const T *input2, T *out) {
|
||||
BroadcastIterator base_iter(input_shape1_, input_shape2_, output_shape_);
|
||||
auto task = [&input1, &input2, &out, &base_iter](size_t start, size_t end) {
|
||||
auto iter = base_iter;
|
||||
|
@ -287,7 +287,7 @@ void ArithmeticCPUKernel<T>::Mod(const T *input1, const T *input2, T *out) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticCPUKernel<T>::FloorMod(const T *input1, const T *input2, T *out) {
|
||||
void ArithmeticCpuKernelMod<T>::FloorMod(const T *input1, const T *input2, T *out) {
|
||||
BroadcastIterator base_iter(input_shape1_, input_shape2_, output_shape_);
|
||||
auto task = [&input1, &input2, &out, &base_iter](size_t start, size_t end) {
|
||||
auto iter = base_iter;
|
||||
|
@ -304,7 +304,7 @@ void ArithmeticCPUKernel<T>::FloorMod(const T *input1, const T *input2, T *out)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticCPUKernel<T>::Pow(const T *input1, const T *input2, T *out) {
|
||||
void ArithmeticCpuKernelMod<T>::Pow(const T *input1, const T *input2, T *out) {
|
||||
if constexpr (std::is_same_v<T, float>) {
|
||||
auto is_power_single = [this]() {
|
||||
bool is_power_single = false;
|
||||
|
@ -361,7 +361,7 @@ void ArithmeticCPUKernel<T>::Pow(const T *input1, const T *input2, T *out) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticCPUKernel<T>::SquaredDifference(const T *input1, const T *input2, T *out) {
|
||||
void ArithmeticCpuKernelMod<T>::SquaredDifference(const T *input1, const T *input2, T *out) {
|
||||
BroadcastIterator base_iter(input_shape1_, input_shape2_, output_shape_);
|
||||
auto task = [&input1, &input2, &out, &base_iter](size_t start, size_t end) {
|
||||
auto iter = base_iter;
|
||||
|
@ -376,7 +376,7 @@ void ArithmeticCPUKernel<T>::SquaredDifference(const T *input1, const T *input2,
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticCPUKernel<T>::Atan2(const T *input1, const T *input2, T *out) {
|
||||
void ArithmeticCpuKernelMod<T>::Atan2(const T *input1, const T *input2, T *out) {
|
||||
BroadcastIterator base_iter(input_shape1_, input_shape2_, output_shape_);
|
||||
auto task = [&input1, &input2, &out, &base_iter](size_t start, size_t end) {
|
||||
auto iter = base_iter;
|
||||
|
@ -391,22 +391,22 @@ void ArithmeticCPUKernel<T>::Atan2(const T *input1, const T *input2, T *out) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticCPUKernel<T>::InitComputeFunc() {
|
||||
void ArithmeticCpuKernelMod<T>::InitComputeFunc() {
|
||||
if (kernel_name_ == prim::kPrimAssignAdd->name()) {
|
||||
return;
|
||||
}
|
||||
static const std::unordered_map<std::string, TypeComputeFunc> arithmeticMathFuncMap{
|
||||
{prim::kPrimAdd->name(), &ArithmeticCPUKernel<T>::Add},
|
||||
{prim::kPrimSub->name(), &ArithmeticCPUKernel<T>::Sub},
|
||||
{prim::kPrimMul->name(), &ArithmeticCPUKernel<T>::Mul},
|
||||
{prim::kPrimDiv->name(), &ArithmeticCPUKernel<T>::Div},
|
||||
{prim::kPrimMod->name(), &ArithmeticCPUKernel<T>::Mod},
|
||||
{prim::kPrimFloorMod->name(), &ArithmeticCPUKernel<T>::FloorMod},
|
||||
{prim::kPrimPow->name(), &ArithmeticCPUKernel<T>::Pow},
|
||||
{prim::kPrimFloorDiv->name(), &ArithmeticCPUKernel<T>::FloorDiv},
|
||||
{prim::kPrimAtan2->name(), &ArithmeticCPUKernel<T>::Atan2},
|
||||
{prim::kPrimRealDiv->name(), &ArithmeticCPUKernel<T>::RealDiv},
|
||||
{prim::kPrimSquaredDifference->name(), &ArithmeticCPUKernel<T>::SquaredDifference}};
|
||||
{prim::kPrimAdd->name(), &ArithmeticCpuKernelMod<T>::Add},
|
||||
{prim::kPrimSub->name(), &ArithmeticCpuKernelMod<T>::Sub},
|
||||
{prim::kPrimMul->name(), &ArithmeticCpuKernelMod<T>::Mul},
|
||||
{prim::kPrimDiv->name(), &ArithmeticCpuKernelMod<T>::Div},
|
||||
{prim::kPrimMod->name(), &ArithmeticCpuKernelMod<T>::Mod},
|
||||
{prim::kPrimFloorMod->name(), &ArithmeticCpuKernelMod<T>::FloorMod},
|
||||
{prim::kPrimPow->name(), &ArithmeticCpuKernelMod<T>::Pow},
|
||||
{prim::kPrimFloorDiv->name(), &ArithmeticCpuKernelMod<T>::FloorDiv},
|
||||
{prim::kPrimAtan2->name(), &ArithmeticCpuKernelMod<T>::Atan2},
|
||||
{prim::kPrimRealDiv->name(), &ArithmeticCpuKernelMod<T>::RealDiv},
|
||||
{prim::kPrimSquaredDifference->name(), &ArithmeticCpuKernelMod<T>::SquaredDifference}};
|
||||
if (arithmeticMathFuncMap.find(kernel_name_) == arithmeticMathFuncMap.end()) {
|
||||
MS_LOG(EXCEPTION) << "For 'Arithmetic', only supports operators in " << Unorderedmap2Str(arithmeticMathFuncMap)
|
||||
<< ", but got " << kernel_name_;
|
||||
|
@ -415,7 +415,7 @@ void ArithmeticCPUKernel<T>::InitComputeFunc() {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void ArithmeticCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
input_shape1_ = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0);
|
||||
|
@ -455,8 +455,8 @@ void ArithmeticCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool ArithmeticCPUKernel<T>::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool ArithmeticCpuKernelMod<T>::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kOutputsNum, kernel_name_);
|
||||
auto *input1 = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,10 +26,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class ArithmeticCPUKernel : public CPUKernel {
|
||||
class ArithmeticCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
ArithmeticCPUKernel() = default;
|
||||
~ArithmeticCPUKernel() override = default;
|
||||
ArithmeticCpuKernelMod() = default;
|
||||
~ArithmeticCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -51,7 +51,7 @@ class ArithmeticCPUKernel : public CPUKernel {
|
|||
void Atan2(const T *input1, const T *input2, T *out);
|
||||
void SquaredDifference(const T *input1, const T *input2, T *out);
|
||||
|
||||
using TypeComputeFunc = std::function<void(ArithmeticCPUKernel *, const T *in_x, const T *in_y, T *out)>;
|
||||
using TypeComputeFunc = std::function<void(ArithmeticCpuKernelMod *, const T *in_x, const T *in_y, T *out)>;
|
||||
TypeComputeFunc compute_func_{nullptr};
|
||||
size_t output_size_{1};
|
||||
ArithmeticParameter op_para_{};
|
||||
|
@ -66,145 +66,145 @@ class ArithmeticCPUKernel : public CPUKernel {
|
|||
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Sub, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticCPUKernel, int32_t);
|
||||
ArithmeticCpuKernelMod, int32_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Sub, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticCPUKernel, float);
|
||||
ArithmeticCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Sub, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
ArithmeticCPUKernel, int64_t);
|
||||
ArithmeticCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Sub, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticCPUKernel, double);
|
||||
ArithmeticCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Mul, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticCPUKernel, int32_t);
|
||||
ArithmeticCpuKernelMod, int32_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Mul, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticCPUKernel, float);
|
||||
ArithmeticCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Mul, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
ArithmeticCPUKernel, int64_t);
|
||||
ArithmeticCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Mul, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticCPUKernel, double);
|
||||
ArithmeticCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Div, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticCPUKernel, int32_t);
|
||||
ArithmeticCpuKernelMod, int32_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Div, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticCPUKernel, float);
|
||||
ArithmeticCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Div, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
ArithmeticCPUKernel, int64_t);
|
||||
ArithmeticCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Div, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticCPUKernel, double);
|
||||
ArithmeticCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Pow, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticCPUKernel, int32_t);
|
||||
ArithmeticCpuKernelMod, int32_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Pow, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticCPUKernel, float);
|
||||
ArithmeticCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Pow, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
ArithmeticCPUKernel, int64_t);
|
||||
ArithmeticCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Pow, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticCPUKernel, double);
|
||||
ArithmeticCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
RealDiv, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticCPUKernel, int32_t);
|
||||
ArithmeticCpuKernelMod, int32_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
RealDiv,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat16).AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeFloat16),
|
||||
ArithmeticCPUKernel, float16);
|
||||
ArithmeticCpuKernelMod, float16);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
RealDiv,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticCPUKernel, float);
|
||||
ArithmeticCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
RealDiv, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
ArithmeticCPUKernel, int64_t);
|
||||
ArithmeticCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
RealDiv,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticCPUKernel, double);
|
||||
ArithmeticCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
FloorDiv, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticCPUKernel, int);
|
||||
ArithmeticCpuKernelMod, int);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
FloorDiv,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticCPUKernel, float);
|
||||
ArithmeticCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
FloorDiv, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
ArithmeticCPUKernel, int64_t);
|
||||
ArithmeticCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
FloorDiv,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticCPUKernel, double);
|
||||
ArithmeticCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Mod, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticCPUKernel, int);
|
||||
ArithmeticCpuKernelMod, int);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Mod, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticCPUKernel, float);
|
||||
ArithmeticCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Mod, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
ArithmeticCPUKernel, int64_t);
|
||||
ArithmeticCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
FloorMod, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
ArithmeticCPUKernel, int64_t);
|
||||
ArithmeticCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
FloorMod, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticCPUKernel, int32_t);
|
||||
ArithmeticCpuKernelMod, int32_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
FloorMod,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticCPUKernel, float);
|
||||
ArithmeticCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
FloorMod,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat16).AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeFloat16),
|
||||
ArithmeticCPUKernel, float16);
|
||||
ArithmeticCpuKernelMod, float16);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
AssignAdd, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticCPUKernel, int32_t);
|
||||
ArithmeticCpuKernelMod, int32_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
AssignAdd,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticCPUKernel, float);
|
||||
ArithmeticCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
AssignAdd, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
ArithmeticCPUKernel, int64_t);
|
||||
ArithmeticCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
AssignAdd,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticCPUKernel, double);
|
||||
ArithmeticCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
SquaredDifference,
|
||||
KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticCPUKernel, int);
|
||||
ArithmeticCpuKernelMod, int);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
SquaredDifference,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat16).AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeFloat16),
|
||||
ArithmeticCPUKernel, float16);
|
||||
ArithmeticCpuKernelMod, float16);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
SquaredDifference,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticCPUKernel, float);
|
||||
ArithmeticCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
SquaredDifference,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticCPUKernel, double);
|
||||
ArithmeticCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Atan2,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticCPUKernel, float);
|
||||
ArithmeticCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Atan2,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticCPUKernel, double);
|
||||
ArithmeticCpuKernelMod, double);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,7 @@ constexpr size_t kOutputsNum = 1;
|
|||
|
||||
template <typename T>
|
||||
template <typename Op>
|
||||
void ArithmeticLogicCPUKernel<T>::BinaryOp(const T *input1, const T *input2, bool *out, Op op) {
|
||||
void ArithmeticLogicCpuKernelMod<T>::BinaryOp(const T *input1, const T *input2, bool *out, Op op) {
|
||||
size_t input1_size = 1;
|
||||
size_t input2_size = 2;
|
||||
|
||||
|
@ -80,56 +80,56 @@ void ArithmeticLogicCPUKernel<T>::BinaryOp(const T *input1, const T *input2, boo
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticLogicCPUKernel<T>::Less(const T *input1, const T *input2, bool *out) {
|
||||
void ArithmeticLogicCpuKernelMod<T>::Less(const T *input1, const T *input2, bool *out) {
|
||||
BinaryOp(input1, input2, out, std::less<T>());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticLogicCPUKernel<T>::Equal(const T *input1, const T *input2, bool *out) {
|
||||
void ArithmeticLogicCpuKernelMod<T>::Equal(const T *input1, const T *input2, bool *out) {
|
||||
BinaryOp(input1, input2, out, std::equal_to<T>());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticLogicCPUKernel<T>::NotEqual(const T *input1, const T *input2, bool *out) {
|
||||
void ArithmeticLogicCpuKernelMod<T>::NotEqual(const T *input1, const T *input2, bool *out) {
|
||||
BinaryOp(input1, input2, out, std::not_equal_to<T>());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticLogicCPUKernel<T>::LogicalAnd(const T *input1, const T *input2, bool *out) {
|
||||
void ArithmeticLogicCpuKernelMod<T>::LogicalAnd(const T *input1, const T *input2, bool *out) {
|
||||
BinaryOp(input1, input2, out, std::logical_and<T>());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticLogicCPUKernel<T>::LogicalOr(const T *input1, const T *input2, bool *out) {
|
||||
void ArithmeticLogicCpuKernelMod<T>::LogicalOr(const T *input1, const T *input2, bool *out) {
|
||||
BinaryOp(input1, input2, out, std::logical_or<T>());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticLogicCPUKernel<T>::Greater(const T *input1, const T *input2, bool *out) {
|
||||
void ArithmeticLogicCpuKernelMod<T>::Greater(const T *input1, const T *input2, bool *out) {
|
||||
BinaryOp(input1, input2, out, std::greater<T>());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticLogicCPUKernel<T>::GreaterEqual(const T *input1, const T *input2, bool *out) {
|
||||
void ArithmeticLogicCpuKernelMod<T>::GreaterEqual(const T *input1, const T *input2, bool *out) {
|
||||
BinaryOp(input1, input2, out, std::greater_equal<T>());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticLogicCPUKernel<T>::LessEqual(const T *input1, const T *input2, bool *out) {
|
||||
void ArithmeticLogicCpuKernelMod<T>::LessEqual(const T *input1, const T *input2, bool *out) {
|
||||
BinaryOp(input1, input2, out, std::less_equal<T>());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticLogicCPUKernel<T>::InitComputeFunc() {
|
||||
void ArithmeticLogicCpuKernelMod<T>::InitComputeFunc() {
|
||||
static const std::unordered_map<std::string, TypeComputeFunc> arithmeticLogicFuncMap{
|
||||
{prim::kPrimGreater->name(), &ArithmeticLogicCPUKernel<T>::Greater},
|
||||
{prim::kPrimGreaterEqual->name(), &ArithmeticLogicCPUKernel<T>::GreaterEqual},
|
||||
{prim::kPrimLogicalAnd->name(), &ArithmeticLogicCPUKernel<T>::LogicalAnd},
|
||||
{prim::kPrimLessEqual->name(), &ArithmeticLogicCPUKernel<T>::LessEqual},
|
||||
{prim::kPrimLogicalOr->name(), &ArithmeticLogicCPUKernel<T>::LogicalOr},
|
||||
{prim::kPrimLess->name(), &ArithmeticLogicCPUKernel<T>::Less},
|
||||
{prim::kPrimNotEqual->name(), &ArithmeticLogicCPUKernel<T>::NotEqual},
|
||||
{prim::kPrimEqual->name(), &ArithmeticLogicCPUKernel<T>::Equal}};
|
||||
{prim::kPrimGreater->name(), &ArithmeticLogicCpuKernelMod<T>::Greater},
|
||||
{prim::kPrimGreaterEqual->name(), &ArithmeticLogicCpuKernelMod<T>::GreaterEqual},
|
||||
{prim::kPrimLogicalAnd->name(), &ArithmeticLogicCpuKernelMod<T>::LogicalAnd},
|
||||
{prim::kPrimLessEqual->name(), &ArithmeticLogicCpuKernelMod<T>::LessEqual},
|
||||
{prim::kPrimLogicalOr->name(), &ArithmeticLogicCpuKernelMod<T>::LogicalOr},
|
||||
{prim::kPrimLess->name(), &ArithmeticLogicCpuKernelMod<T>::Less},
|
||||
{prim::kPrimNotEqual->name(), &ArithmeticLogicCpuKernelMod<T>::NotEqual},
|
||||
{prim::kPrimEqual->name(), &ArithmeticLogicCpuKernelMod<T>::Equal}};
|
||||
if (arithmeticLogicFuncMap.find(kernel_name_) == arithmeticLogicFuncMap.end()) {
|
||||
MS_LOG(EXCEPTION) << "For 'ArithmeticLogic', only supports operators in "
|
||||
<< Unorderedmap2Str(arithmeticLogicFuncMap) << ", but got " << kernel_name_;
|
||||
|
@ -138,7 +138,7 @@ void ArithmeticLogicCPUKernel<T>::InitComputeFunc() {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticLogicCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void ArithmeticLogicCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
input_shape1_ = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0);
|
||||
|
@ -175,9 +175,9 @@ void ArithmeticLogicCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool ArithmeticLogicCPUKernel<T>::Launch(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> & /* workspace */,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool ArithmeticLogicCpuKernelMod<T>::Launch(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> & /* workspace */,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kOutputsNum, kernel_name_);
|
||||
const auto *input1 = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -27,10 +27,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class ArithmeticLogicCPUKernel : public CPUKernel {
|
||||
class ArithmeticLogicCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
ArithmeticLogicCPUKernel() = default;
|
||||
~ArithmeticLogicCPUKernel() override = default;
|
||||
ArithmeticLogicCpuKernelMod() = default;
|
||||
~ArithmeticLogicCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -51,7 +51,7 @@ class ArithmeticLogicCPUKernel : public CPUKernel {
|
|||
void LogicalAnd(const T *input1, const T *input2, bool *out);
|
||||
void LogicalOr(const T *input1, const T *input2, bool *out);
|
||||
|
||||
using TypeComputeFunc = std::function<void(ArithmeticLogicCPUKernel *, const T *, const T *, bool *)>;
|
||||
using TypeComputeFunc = std::function<void(ArithmeticLogicCpuKernelMod *, const T *, const T *, bool *)>;
|
||||
TypeComputeFunc compute_func_{nullptr};
|
||||
size_t output_size_{1};
|
||||
TypeId dtype_{kTypeUnknown};
|
||||
|
@ -66,135 +66,135 @@ class ArithmeticLogicCPUKernel : public CPUKernel {
|
|||
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Less, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int);
|
||||
ArithmeticLogicCpuKernelMod, int);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Less, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, float);
|
||||
ArithmeticLogicCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Less, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int64_t);
|
||||
ArithmeticLogicCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Less, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, double);
|
||||
ArithmeticLogicCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Equal, KernelAttr().AddInputAttr(kNumberTypeBool).AddInputAttr(kNumberTypeBool).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, bool);
|
||||
ArithmeticLogicCpuKernelMod, bool);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Equal, KernelAttr().AddInputAttr(kNumberTypeInt8).AddInputAttr(kNumberTypeInt8).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int8_t);
|
||||
ArithmeticLogicCpuKernelMod, int8_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Equal, KernelAttr().AddInputAttr(kNumberTypeInt16).AddInputAttr(kNumberTypeInt16).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int16_t);
|
||||
ArithmeticLogicCpuKernelMod, int16_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Equal, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int);
|
||||
ArithmeticLogicCpuKernelMod, int);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Equal, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int64_t);
|
||||
ArithmeticLogicCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Equal, KernelAttr().AddInputAttr(kNumberTypeUInt8).AddInputAttr(kNumberTypeUInt8).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, uint8_t);
|
||||
ArithmeticLogicCpuKernelMod, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Equal, KernelAttr().AddInputAttr(kNumberTypeUInt16).AddInputAttr(kNumberTypeUInt16).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, uint16_t);
|
||||
ArithmeticLogicCpuKernelMod, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Equal, KernelAttr().AddInputAttr(kNumberTypeUInt32).AddInputAttr(kNumberTypeUInt32).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, uint32_t);
|
||||
ArithmeticLogicCpuKernelMod, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Equal, KernelAttr().AddInputAttr(kNumberTypeFloat16).AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, float16);
|
||||
ArithmeticLogicCpuKernelMod, float16);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Equal, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, float);
|
||||
ArithmeticLogicCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Equal, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, double);
|
||||
ArithmeticLogicCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
NotEqual, KernelAttr().AddInputAttr(kNumberTypeBool).AddInputAttr(kNumberTypeBool).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, bool);
|
||||
ArithmeticLogicCpuKernelMod, bool);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
NotEqual, KernelAttr().AddInputAttr(kNumberTypeInt8).AddInputAttr(kNumberTypeInt8).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int8_t);
|
||||
ArithmeticLogicCpuKernelMod, int8_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
NotEqual, KernelAttr().AddInputAttr(kNumberTypeInt16).AddInputAttr(kNumberTypeInt16).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int16_t);
|
||||
ArithmeticLogicCpuKernelMod, int16_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
NotEqual, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int);
|
||||
ArithmeticLogicCpuKernelMod, int);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
NotEqual, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int64_t);
|
||||
ArithmeticLogicCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
NotEqual, KernelAttr().AddInputAttr(kNumberTypeUInt8).AddInputAttr(kNumberTypeUInt8).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, uint8_t);
|
||||
ArithmeticLogicCpuKernelMod, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
NotEqual, KernelAttr().AddInputAttr(kNumberTypeUInt16).AddInputAttr(kNumberTypeUInt16).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, uint16_t);
|
||||
ArithmeticLogicCpuKernelMod, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
NotEqual, KernelAttr().AddInputAttr(kNumberTypeUInt32).AddInputAttr(kNumberTypeUInt32).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, uint32_t);
|
||||
ArithmeticLogicCpuKernelMod, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
NotEqual,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat16).AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, float16);
|
||||
ArithmeticLogicCpuKernelMod, float16);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
NotEqual,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, float);
|
||||
ArithmeticLogicCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
NotEqual,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, double);
|
||||
ArithmeticLogicCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Greater, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int);
|
||||
ArithmeticLogicCpuKernelMod, int);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Greater,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, float);
|
||||
ArithmeticLogicCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Greater,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, double);
|
||||
ArithmeticLogicCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Greater, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int64_t);
|
||||
ArithmeticLogicCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
GreaterEqual,
|
||||
KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int);
|
||||
ArithmeticLogicCpuKernelMod, int);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
GreaterEqual,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, float);
|
||||
ArithmeticLogicCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
GreaterEqual,
|
||||
KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int64_t);
|
||||
ArithmeticLogicCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
GreaterEqual,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, double);
|
||||
ArithmeticLogicCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
LessEqual, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int);
|
||||
ArithmeticLogicCpuKernelMod, int);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
LessEqual, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, int64_t);
|
||||
ArithmeticLogicCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
LessEqual,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, float);
|
||||
ArithmeticLogicCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
LessEqual,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, double);
|
||||
ArithmeticLogicCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
LogicalAnd, KernelAttr().AddInputAttr(kNumberTypeBool).AddInputAttr(kNumberTypeBool).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, bool);
|
||||
ArithmeticLogicCpuKernelMod, bool);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
LogicalOr, KernelAttr().AddInputAttr(kNumberTypeBool).AddInputAttr(kNumberTypeBool).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticLogicCPUKernel, bool);
|
||||
ArithmeticLogicCpuKernelMod, bool);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,7 @@ constexpr size_t kInputsNum = 1;
|
|||
constexpr size_t kOutputsNum = 1;
|
||||
|
||||
template <typename T>
|
||||
void Square(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Square(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = in[i] * in[i];
|
||||
|
@ -43,7 +43,7 @@ void Square(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Sign(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Sign(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
if (in[i] < 0) {
|
||||
|
@ -59,7 +59,7 @@ void Sign(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Neg(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Neg(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = -in[i];
|
||||
|
@ -68,7 +68,7 @@ void Neg(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
ParallelLaunch(task, size, kMaxNegSerialSize);
|
||||
}
|
||||
|
||||
void LogicalNot(ArithmeticSelfCPUKernel *content, const bool *in, bool *out, size_t size) {
|
||||
void LogicalNot(ArithmeticSelfCpuKernelMod *content, const bool *in, bool *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = !in[i];
|
||||
|
@ -78,7 +78,7 @@ void LogicalNot(ArithmeticSelfCPUKernel *content, const bool *in, bool *out, siz
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void OnesLike(ArithmeticSelfCPUKernel *content, const T *, T *out, size_t size) {
|
||||
void OnesLike(ArithmeticSelfCpuKernelMod *content, const T *, T *out, size_t size) {
|
||||
auto task = [&out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(1);
|
||||
|
@ -88,7 +88,7 @@ void OnesLike(ArithmeticSelfCPUKernel *content, const T *, T *out, size_t size)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ZerosLike(ArithmeticSelfCPUKernel *content, const T *, T *out, size_t size) {
|
||||
void ZerosLike(ArithmeticSelfCpuKernelMod *content, const T *, T *out, size_t size) {
|
||||
auto task = [&out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(0);
|
||||
|
@ -98,7 +98,7 @@ void ZerosLike(ArithmeticSelfCPUKernel *content, const T *, T *out, size_t size)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Floor(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Floor(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(floor(in[i]));
|
||||
|
@ -108,7 +108,7 @@ void Floor(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Rint(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Rint(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(rint(in[i]));
|
||||
|
@ -118,7 +118,7 @@ void Rint(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Round(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Round(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(nearbyint(in[i]));
|
||||
|
@ -128,7 +128,7 @@ void Round(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Reciprocal(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Reciprocal(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(1.0 / in[i]);
|
||||
|
@ -138,7 +138,7 @@ void Reciprocal(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t si
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Gelu(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Gelu(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
auto factor_a = static_cast<T>(0.7978845608);
|
||||
auto factor_b = static_cast<T>(0.044715);
|
||||
|
@ -153,7 +153,7 @@ void Gelu(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Asin(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Asin(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(asin(static_cast<double>(in[i])));
|
||||
|
@ -163,7 +163,7 @@ void Asin(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ACos(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void ACos(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(acos(static_cast<double>(in[i])));
|
||||
|
@ -173,7 +173,7 @@ void ACos(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Atan(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Atan(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(atan(static_cast<double>(in[i])));
|
||||
|
@ -183,7 +183,7 @@ void Atan(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Sin(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Sin(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(sin(static_cast<double>(in[i])));
|
||||
|
@ -193,7 +193,7 @@ void Sin(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Cos(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Cos(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(cos(static_cast<double>(in[i])));
|
||||
|
@ -203,7 +203,7 @@ void Cos(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Tan(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Tan(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(tan(static_cast<double>(in[i])));
|
||||
|
@ -213,7 +213,7 @@ void Tan(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Sinh(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Sinh(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(sinh(static_cast<double>(in[i])));
|
||||
|
@ -223,7 +223,7 @@ void Sinh(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Cosh(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Cosh(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(cosh(static_cast<double>(in[i])));
|
||||
|
@ -233,7 +233,7 @@ void Cosh(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Asinh(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Asinh(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(asinh(static_cast<double>(in[i])));
|
||||
|
@ -243,7 +243,7 @@ void Asinh(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ComplexAcosh(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void ComplexAcosh(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(acosh(in[i]));
|
||||
|
@ -253,7 +253,7 @@ void ComplexAcosh(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Acosh(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Acosh(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(acosh(static_cast<double>(in[i])));
|
||||
|
@ -263,7 +263,7 @@ void Acosh(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Atanh(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Atanh(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(atanh(static_cast<double>(in[i])));
|
||||
|
@ -273,7 +273,7 @@ void Atanh(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Abs(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Abs(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = abs(in[i]);
|
||||
|
@ -283,7 +283,7 @@ void Abs(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void Sqrt(ArithmeticSelfCPUKernel *content, const T *in, T *out, size_t size) {
|
||||
void Sqrt(ArithmeticSelfCpuKernelMod *content, const T *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(sqrt(in[i]));
|
||||
|
@ -298,15 +298,15 @@ void Identity(const T *in, T *out, size_t size) {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
void ArithmeticSelfCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void ArithmeticSelfCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
dtype_ = AnfAlgo::GetInputDeviceDataType(kernel_node, 0);
|
||||
}
|
||||
|
||||
bool ArithmeticSelfCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool ArithmeticSelfCpuKernelMod::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kOutputsNum, kernel_name_);
|
||||
if (dtype_ == kNumberTypeFloat32 || dtype_ == kNumberTypeFloat16) {
|
||||
|
@ -332,8 +332,8 @@ bool ArithmeticSelfCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inpu
|
|||
return true;
|
||||
}
|
||||
|
||||
void ArithmeticSelfCPUKernel::LaunchLogicalNot(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
void ArithmeticSelfCpuKernelMod::LaunchLogicalNot(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
auto *input = reinterpret_cast<bool *>(inputs[0]->addr);
|
||||
auto *output = reinterpret_cast<bool *>(outputs[0]->addr);
|
||||
size_t lens = outputs[0]->size / sizeof(bool);
|
||||
|
@ -341,12 +341,13 @@ void ArithmeticSelfCPUKernel::LaunchLogicalNot(const std::vector<AddressPtr> &in
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticSelfCPUKernel::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
void ArithmeticSelfCpuKernelMod::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
const auto *input = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
auto *output = reinterpret_cast<T *>(outputs[0]->addr);
|
||||
const size_t lens = outputs[0]->size / sizeof(T);
|
||||
static const std::unordered_map<std::string, std::function<void(ArithmeticSelfCPUKernel *, const T *, T *, size_t)>>
|
||||
static const std::unordered_map<std::string,
|
||||
std::function<void(ArithmeticSelfCpuKernelMod *, const T *, T *, size_t)>>
|
||||
arithmeticSelfFuncMap{{prim::kPrimSquare->name(), Square<T>},
|
||||
{prim::kPrimSign->name(), Sign<T>},
|
||||
{prim::kPrimNeg->name(), Neg<T>},
|
||||
|
@ -380,24 +381,25 @@ void ArithmeticSelfCPUKernel::LaunchKernel(const std::vector<AddressPtr> &inputs
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void ArithmeticSelfCPUKernel::LaunchKernelComplex(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
void ArithmeticSelfCpuKernelMod::LaunchKernelComplex(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
const auto *input = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
auto *output = reinterpret_cast<T *>(outputs[0]->addr);
|
||||
const size_t lens = outputs[0]->size / sizeof(T);
|
||||
static const std::unordered_map<std::string, std::function<void(ArithmeticSelfCPUKernel *, const T *, T *, size_t)>>
|
||||
static const std::unordered_map<std::string,
|
||||
std::function<void(ArithmeticSelfCpuKernelMod *, const T *, T *, size_t)>>
|
||||
arithmeticSelfFuncMap{{prim::kPrimSquare->name(), Square<T>}, {prim::kPrimAcosh->name(), ComplexAcosh<T>}};
|
||||
const auto func_pair = arithmeticSelfFuncMap.find(kernel_name_);
|
||||
if (arithmeticSelfFuncMap.find(kernel_name_) == arithmeticSelfFuncMap.end()) {
|
||||
MS_LOG(EXCEPTION) << "ArithmeticSelfCPUKernel does not support " << kernel_name_;
|
||||
MS_LOG(EXCEPTION) << "ArithmeticSelfCpuKernelMod does not support " << kernel_name_;
|
||||
}
|
||||
func_pair->second(this, input, output, lens);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool IdentityCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool IdentityCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kOutputsNum, kernel_name_);
|
||||
T *input = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -29,10 +29,10 @@ using complex128 = std::complex<double>;
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class ArithmeticSelfCPUKernel : public CPUKernel {
|
||||
class ArithmeticSelfCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
ArithmeticSelfCPUKernel() = default;
|
||||
~ArithmeticSelfCPUKernel() override = default;
|
||||
ArithmeticSelfCpuKernelMod() = default;
|
||||
~ArithmeticSelfCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -52,164 +52,164 @@ class ArithmeticSelfCPUKernel : public CPUKernel {
|
|||
};
|
||||
|
||||
template <typename T>
|
||||
class IdentityCPUKernel : public ArithmeticSelfCPUKernel {
|
||||
class IdentityCpuKernelMod : public ArithmeticSelfCpuKernelMod {
|
||||
public:
|
||||
IdentityCPUKernel() = default;
|
||||
~IdentityCPUKernel() override = default;
|
||||
IdentityCpuKernelMod() = default;
|
||||
~IdentityCpuKernelMod() override = default;
|
||||
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) override;
|
||||
};
|
||||
|
||||
MS_REG_CPU_KERNEL(Square, KernelAttr().AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Square, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Square, KernelAttr().AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Square, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Square, KernelAttr().AddInputAttr(kNumberTypeComplex64).AddOutputAttr(kNumberTypeComplex64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Square, KernelAttr().AddInputAttr(kNumberTypeComplex128).AddOutputAttr(kNumberTypeComplex128),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Neg, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Neg, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Neg, KernelAttr().AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Neg, KernelAttr().AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(ZerosLike, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(ZerosLike, KernelAttr().AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(ZerosLike, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(OnesLike, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(OnesLike, KernelAttr().AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(OnesLike, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Sign, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Sign, KernelAttr().AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Sign, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Floor, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Floor, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Rint, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Rint, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Round, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Round, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Reciprocal, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Reciprocal, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(GeLU, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(LogicalNot, KernelAttr().AddInputAttr(kNumberTypeBool).AddOutputAttr(kNumberTypeBool),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Asin, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Asin, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(ACos, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(ACos, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Atan, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Atan, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Sin, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Sin, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Cos, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Cos, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Tan, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Tan, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Sinh, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Sinh, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Cosh, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Cosh, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Asinh, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Asinh, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Acosh, KernelAttr().AddInputAttr(kNumberTypeComplex64).AddOutputAttr(kNumberTypeComplex64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Acosh, KernelAttr().AddInputAttr(kNumberTypeComplex128).AddOutputAttr(kNumberTypeComplex128),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Acosh, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Acosh, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Atanh, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Atanh, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Abs, KernelAttr().AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Abs, KernelAttr().AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Abs, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Abs, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(Sqrt, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
ArithmeticSelfCPUKernel);
|
||||
ArithmeticSelfCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeUInt64).AddOutputAttr(kNumberTypeUInt64),
|
||||
IdentityCPUKernel, uint64_t);
|
||||
IdentityCpuKernelMod, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
IdentityCPUKernel, int64_t);
|
||||
IdentityCpuKernelMod, int64_t);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeUInt32).AddOutputAttr(kNumberTypeUInt32),
|
||||
IdentityCPUKernel, uint32_t);
|
||||
IdentityCpuKernelMod, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
IdentityCPUKernel, int32_t);
|
||||
IdentityCpuKernelMod, int32_t);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeUInt16).AddOutputAttr(kNumberTypeUInt16),
|
||||
IdentityCPUKernel, uint16_t);
|
||||
IdentityCpuKernelMod, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeInt16).AddOutputAttr(kNumberTypeInt16),
|
||||
IdentityCPUKernel, int16_t);
|
||||
IdentityCpuKernelMod, int16_t);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeUInt8).AddOutputAttr(kNumberTypeUInt8),
|
||||
IdentityCPUKernel, uint8_t);
|
||||
IdentityCpuKernelMod, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeInt8).AddOutputAttr(kNumberTypeInt8),
|
||||
IdentityCPUKernel, int8_t);
|
||||
IdentityCpuKernelMod, int8_t);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeComplex64).AddOutputAttr(kNumberTypeComplex64),
|
||||
IdentityCPUKernel, complex64);
|
||||
IdentityCpuKernelMod, complex64);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeComplex128).AddOutputAttr(kNumberTypeComplex128),
|
||||
IdentityCPUKernel, complex128);
|
||||
IdentityCpuKernelMod, complex128);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
IdentityCPUKernel, double);
|
||||
IdentityCpuKernelMod, double);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
IdentityCPUKernel, float);
|
||||
IdentityCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeFloat16),
|
||||
IdentityCPUKernel, float16);
|
||||
IdentityCpuKernelMod, float16);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeBool).AddOutputAttr(kNumberTypeBool),
|
||||
IdentityCPUKernel, bool);
|
||||
IdentityCpuKernelMod, bool);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeComplex64).AddOutputAttr(kNumberTypeComplex64),
|
||||
IdentityCPUKernel, complex64);
|
||||
IdentityCpuKernelMod, complex64);
|
||||
MS_REG_CPU_KERNEL_T(Identity, KernelAttr().AddInputAttr(kNumberTypeComplex128).AddOutputAttr(kNumberTypeComplex128),
|
||||
IdentityCPUKernel, complex128);
|
||||
IdentityCpuKernelMod, complex128);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -35,7 +35,7 @@ const std::map<TypeId, size_t> input_x_dtype_size_map = {
|
|||
{kNumberTypeFloat16, sizeof(float16)}, {kNumberTypeFloat32, sizeof(float)}, {kNumberTypeFloat64, sizeof(double)}};
|
||||
} // namespace
|
||||
|
||||
void AssignCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void AssignCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
auto input_x_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0);
|
||||
|
@ -62,8 +62,8 @@ void AssignCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
|||
input_x_dtype_size_ = type_len->second;
|
||||
}
|
||||
|
||||
bool AssignCPUKernel::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool AssignCpuKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kAssignInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kAssignOutputsNum, kernel_name_);
|
||||
static std::string kernel_name = kernel_name_;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,10 +26,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class AssignCPUKernel : public CPUKernel {
|
||||
class AssignCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
AssignCPUKernel() = default;
|
||||
~AssignCPUKernel() override = default;
|
||||
AssignCpuKernelMod() = default;
|
||||
~AssignCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -44,54 +44,54 @@ class AssignCPUKernel : public CPUKernel {
|
|||
|
||||
MS_REG_CPU_KERNEL(
|
||||
Assign, KernelAttr().AddInputAttr(kNumberTypeBool).AddInputAttr(kNumberTypeBool).AddOutputAttr(kNumberTypeBool),
|
||||
AssignCPUKernel);
|
||||
AssignCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(
|
||||
Assign, KernelAttr().AddInputAttr(kNumberTypeInt8).AddInputAttr(kNumberTypeInt8).AddOutputAttr(kNumberTypeInt8),
|
||||
AssignCPUKernel);
|
||||
AssignCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(
|
||||
Assign, KernelAttr().AddInputAttr(kNumberTypeInt16).AddInputAttr(kNumberTypeInt16).AddOutputAttr(kNumberTypeInt16),
|
||||
AssignCPUKernel);
|
||||
AssignCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(
|
||||
Assign, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
AssignCPUKernel);
|
||||
AssignCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(
|
||||
Assign, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
AssignCPUKernel);
|
||||
AssignCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(
|
||||
Assign, KernelAttr().AddInputAttr(kNumberTypeUInt8).AddInputAttr(kNumberTypeUInt8).AddOutputAttr(kNumberTypeUInt8),
|
||||
AssignCPUKernel);
|
||||
AssignCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(
|
||||
Assign, KernelAttr().AddInputAttr(kNumberTypeUInt16).AddInputAttr(kNumberTypeUInt16).AddOutputAttr(kNumberTypeUInt16),
|
||||
AssignCPUKernel);
|
||||
AssignCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(
|
||||
Assign, KernelAttr().AddInputAttr(kNumberTypeUInt32).AddInputAttr(kNumberTypeUInt32).AddOutputAttr(kNumberTypeUInt32),
|
||||
AssignCPUKernel);
|
||||
AssignCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(
|
||||
Assign, KernelAttr().AddInputAttr(kNumberTypeUInt64).AddInputAttr(kNumberTypeUInt64).AddOutputAttr(kNumberTypeUInt64),
|
||||
AssignCPUKernel);
|
||||
AssignCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(
|
||||
Assign,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat16).AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeFloat16),
|
||||
AssignCPUKernel);
|
||||
AssignCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(
|
||||
Assign,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
AssignCPUKernel);
|
||||
AssignCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(
|
||||
Assign,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
AssignCPUKernel);
|
||||
AssignCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -27,7 +27,7 @@ constexpr size_t kBiasAddInputsNum = 2;
|
|||
constexpr size_t kBiasAddOutputsNum = 1;
|
||||
} // namespace
|
||||
|
||||
void BiasAddCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void BiasAddCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
input_shape_ = AnfAlgo::GetInputDeviceShape(kernel_node, 0);
|
||||
|
@ -50,8 +50,8 @@ void BiasAddCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
}
|
||||
|
||||
bool BiasAddCPUKernel::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool BiasAddCpuKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kBiasAddInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kBiasAddOutputsNum, kernel_name_);
|
||||
const auto *src_addr = reinterpret_cast<float *>(inputs[0]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class BiasAddCPUKernel : public CPUKernel {
|
||||
class BiasAddCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
BiasAddCPUKernel() = default;
|
||||
~BiasAddCPUKernel() override = default;
|
||||
BiasAddCpuKernelMod() = default;
|
||||
~BiasAddCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
|
@ -39,7 +39,7 @@ class BiasAddCPUKernel : public CPUKernel {
|
|||
std::vector<size_t> input_shape_;
|
||||
std::vector<size_t> bias_shape_;
|
||||
};
|
||||
MS_REG_CPU_KERNEL(BiasAdd, KernelAttr(), BiasAddCPUKernel);
|
||||
MS_REG_CPU_KERNEL(BiasAdd, KernelAttr(), BiasAddCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_BIAS_ADD_CPU_KERNEL_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,7 +25,7 @@ constexpr size_t kBiasAddGradInputsNum = 1;
|
|||
constexpr size_t kBiasAddGradOutputsNum = 1;
|
||||
} // namespace
|
||||
|
||||
void BiasAddGradCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void BiasAddGradCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
input_shape_ = AnfAlgo::GetInputDeviceShape(kernel_node, 0);
|
||||
|
@ -35,8 +35,8 @@ void BiasAddGradCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
}
|
||||
|
||||
bool BiasAddGradCPUKernel::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool BiasAddGradCpuKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kBiasAddGradInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kBiasAddGradOutputsNum, kernel_name_);
|
||||
const auto *input_addr = reinterpret_cast<float *>(inputs[0]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class BiasAddGradCPUKernel : public CPUKernel {
|
||||
class BiasAddGradCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
BiasAddGradCPUKernel() = default;
|
||||
~BiasAddGradCPUKernel() override = default;
|
||||
BiasAddGradCpuKernelMod() = default;
|
||||
~BiasAddGradCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
|
@ -37,7 +37,7 @@ class BiasAddGradCPUKernel : public CPUKernel {
|
|||
private:
|
||||
std::vector<size_t> input_shape_;
|
||||
};
|
||||
MS_REG_CPU_KERNEL(BiasAddGrad, KernelAttr(), BiasAddGradCPUKernel);
|
||||
MS_REG_CPU_KERNEL(BiasAddGrad, KernelAttr(), BiasAddGradCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_BIAS_ADD_GRAD_CPU_KERNEL_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,8 +24,8 @@ constexpr size_t kBceOutputsNum = 1;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void BinaryCrossEntropyCpuKernel::LaunchToScalar(const int &input_size, const int &reduction, T *loss,
|
||||
T *tmp_loss) const {
|
||||
void BinaryCrossEntropyCpuKernelMod::LaunchToScalar(const int &input_size, const int &reduction, T *loss,
|
||||
T *tmp_loss) const {
|
||||
if (input_size % 2 == 1) {
|
||||
tmp_loss[0] += tmp_loss[input_size - 1];
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ void BinaryCrossEntropyCpuKernel::LaunchToScalar(const int &input_size, const in
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void BinaryCrossEntropyCpuKernel::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) const {
|
||||
void BinaryCrossEntropyCpuKernelMod::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) const {
|
||||
const auto *input_x = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
const auto *input_y = reinterpret_cast<T *>(inputs[1]->addr);
|
||||
const T *weight = weight_defined_ ? reinterpret_cast<T *>(inputs[2]->addr) : nullptr;
|
||||
|
@ -90,8 +90,8 @@ void BinaryCrossEntropyCpuKernel::LaunchKernel(const std::vector<AddressPtr> &in
|
|||
}
|
||||
}
|
||||
|
||||
bool BinaryCrossEntropyCpuKernel::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool BinaryCrossEntropyCpuKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
const size_t expect_inputs_num = weight_defined_ ? kBceInputsNumWithWeight : kBceInputsNumWithWeight - 1;
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), expect_inputs_num, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kBceOutputsNum, kernel_name_);
|
||||
|
@ -106,7 +106,7 @@ bool BinaryCrossEntropyCpuKernel::Launch(const std::vector<AddressPtr> &inputs,
|
|||
return true;
|
||||
}
|
||||
|
||||
void BinaryCrossEntropyCpuKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void BinaryCrossEntropyCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -27,10 +27,10 @@ namespace mindspore {
|
|||
namespace kernel {
|
||||
enum ReductionType { kNone, kMean, kSum };
|
||||
|
||||
class BinaryCrossEntropyCpuKernel : public CPUKernel {
|
||||
class BinaryCrossEntropyCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
BinaryCrossEntropyCpuKernel() = default;
|
||||
~BinaryCrossEntropyCpuKernel() override = default;
|
||||
BinaryCrossEntropyCpuKernelMod() = default;
|
||||
~BinaryCrossEntropyCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
|
@ -53,22 +53,22 @@ MS_REG_CPU_KERNEL(BinaryCrossEntropy,
|
|||
.AddInputAttr(kNumberTypeFloat16)
|
||||
.AddInputAttr(kNumberTypeFloat16)
|
||||
.AddOutputAttr(kNumberTypeFloat16),
|
||||
BinaryCrossEntropyCpuKernel);
|
||||
BinaryCrossEntropyCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(BinaryCrossEntropy,
|
||||
KernelAttr()
|
||||
.AddInputAttr(kNumberTypeFloat32)
|
||||
.AddInputAttr(kNumberTypeFloat32)
|
||||
.AddInputAttr(kNumberTypeFloat32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
BinaryCrossEntropyCpuKernel);
|
||||
BinaryCrossEntropyCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(
|
||||
BinaryCrossEntropy,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat16).AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeFloat16),
|
||||
BinaryCrossEntropyCpuKernel);
|
||||
BinaryCrossEntropyCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(
|
||||
BinaryCrossEntropy,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
BinaryCrossEntropyCpuKernel);
|
||||
BinaryCrossEntropyCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_NN_BINARY_CROSS_ENTROPY_KERNEL_H
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,8 +24,8 @@ constexpr size_t kBceGradOutputsNum = 1;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void BinaryCrossEntropyGradCpuKernel::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) const {
|
||||
void BinaryCrossEntropyGradCpuKernelMod::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) const {
|
||||
const auto *input_x = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
const auto *input_y = reinterpret_cast<T *>(inputs[1]->addr);
|
||||
const auto *dloss = reinterpret_cast<T *>(inputs[2]->addr);
|
||||
|
@ -69,8 +69,8 @@ void BinaryCrossEntropyGradCpuKernel::LaunchKernel(const std::vector<AddressPtr>
|
|||
}
|
||||
}
|
||||
|
||||
bool BinaryCrossEntropyGradCpuKernel::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool BinaryCrossEntropyGradCpuKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
const size_t expect_inputs_num = weight_defined_ ? kBceGradInputsNumWithWeight : kBceGradInputsNumWithWeight - 1;
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), expect_inputs_num, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kBceGradOutputsNum, kernel_name_);
|
||||
|
@ -85,7 +85,7 @@ bool BinaryCrossEntropyGradCpuKernel::Launch(const std::vector<AddressPtr> &inpu
|
|||
return true;
|
||||
}
|
||||
|
||||
void BinaryCrossEntropyGradCpuKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void BinaryCrossEntropyGradCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,10 +26,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class BinaryCrossEntropyGradCpuKernel : public CPUKernel {
|
||||
class BinaryCrossEntropyGradCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
BinaryCrossEntropyGradCpuKernel() = default;
|
||||
~BinaryCrossEntropyGradCpuKernel() override = default;
|
||||
BinaryCrossEntropyGradCpuKernelMod() = default;
|
||||
~BinaryCrossEntropyGradCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
|
@ -51,7 +51,7 @@ MS_REG_CPU_KERNEL(BinaryCrossEntropyGrad,
|
|||
.AddInputAttr(kNumberTypeFloat16)
|
||||
.AddInputAttr(kNumberTypeFloat16)
|
||||
.AddOutputAttr(kNumberTypeFloat16),
|
||||
BinaryCrossEntropyGradCpuKernel);
|
||||
BinaryCrossEntropyGradCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(BinaryCrossEntropyGrad,
|
||||
KernelAttr()
|
||||
.AddInputAttr(kNumberTypeFloat32)
|
||||
|
@ -59,21 +59,21 @@ MS_REG_CPU_KERNEL(BinaryCrossEntropyGrad,
|
|||
.AddInputAttr(kNumberTypeFloat32)
|
||||
.AddInputAttr(kNumberTypeFloat32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
BinaryCrossEntropyGradCpuKernel);
|
||||
BinaryCrossEntropyGradCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(BinaryCrossEntropyGrad,
|
||||
KernelAttr()
|
||||
.AddInputAttr(kNumberTypeFloat16)
|
||||
.AddInputAttr(kNumberTypeFloat16)
|
||||
.AddInputAttr(kNumberTypeFloat16)
|
||||
.AddOutputAttr(kNumberTypeFloat16),
|
||||
BinaryCrossEntropyGradCpuKernel);
|
||||
BinaryCrossEntropyGradCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(BinaryCrossEntropyGrad,
|
||||
KernelAttr()
|
||||
.AddInputAttr(kNumberTypeFloat32)
|
||||
.AddInputAttr(kNumberTypeFloat32)
|
||||
.AddInputAttr(kNumberTypeFloat32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
BinaryCrossEntropyGradCpuKernel);
|
||||
BinaryCrossEntropyGradCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_NN_BINARY_CROSS_ENTROPY_GRAD_KERNEL_H
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,7 +20,7 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
void BoundingBoxDecodeCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void BoundingBoxDecodeCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node);
|
||||
|
@ -74,9 +74,9 @@ void BoundingBoxDecodeCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool BoundingBoxDecodeCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool BoundingBoxDecodeCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
auto anchor_box = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
auto deltas = reinterpret_cast<T *>(inputs[1]->addr);
|
||||
auto bboxes = reinterpret_cast<T *>(outputs[0]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,10 +28,10 @@ namespace kernel {
|
|||
constexpr size_t MIN_MAX_SHAPE_SIZE = 2;
|
||||
constexpr size_t INPUT_NUMS = 2;
|
||||
template <typename T>
|
||||
class BoundingBoxDecodeCPUKernel : public CPUKernel {
|
||||
class BoundingBoxDecodeCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
BoundingBoxDecodeCPUKernel() = default;
|
||||
~BoundingBoxDecodeCPUKernel() override = default;
|
||||
BoundingBoxDecodeCpuKernelMod() = default;
|
||||
~BoundingBoxDecodeCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -48,12 +48,12 @@ class BoundingBoxDecodeCPUKernel : public CPUKernel {
|
|||
MS_REG_CPU_KERNEL_T(
|
||||
BoundingBoxDecode,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
BoundingBoxDecodeCPUKernel, float);
|
||||
BoundingBoxDecodeCpuKernelMod, float);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
BoundingBoxDecode,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat16).AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeFloat16),
|
||||
BoundingBoxDecodeCPUKernel, float16);
|
||||
BoundingBoxDecodeCpuKernelMod, float16);
|
||||
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,7 +20,7 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
void BoundingBoxEncodeCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void BoundingBoxEncodeCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node);
|
||||
|
@ -64,9 +64,9 @@ void BoundingBoxEncodeCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool BoundingBoxEncodeCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool BoundingBoxEncodeCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
auto anchor_box = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
auto groundtruth_box = reinterpret_cast<T *>(inputs[1]->addr);
|
||||
auto deltas = reinterpret_cast<T *>(outputs[0]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -27,10 +27,10 @@ namespace mindspore {
|
|||
namespace kernel {
|
||||
constexpr size_t INPUT_NUMS = 2;
|
||||
template <typename T>
|
||||
class BoundingBoxEncodeCPUKernel : public CPUKernel {
|
||||
class BoundingBoxEncodeCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
BoundingBoxEncodeCPUKernel() = default;
|
||||
~BoundingBoxEncodeCPUKernel() override = default;
|
||||
BoundingBoxEncodeCpuKernelMod() = default;
|
||||
~BoundingBoxEncodeCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -45,12 +45,12 @@ class BoundingBoxEncodeCPUKernel : public CPUKernel {
|
|||
MS_REG_CPU_KERNEL_T(
|
||||
BoundingBoxEncode,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
BoundingBoxEncodeCPUKernel, float);
|
||||
BoundingBoxEncodeCpuKernelMod, float);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
BoundingBoxEncode,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat16).AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeFloat16),
|
||||
BoundingBoxEncodeCPUKernel, float16);
|
||||
BoundingBoxEncodeCpuKernelMod, float16);
|
||||
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,7 +24,7 @@ constexpr size_t kBroadcastToOutputsNum = 1;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void BroadcastToCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void BroadcastToCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
input_shape_ = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0);
|
||||
|
@ -43,7 +43,7 @@ void BroadcastToCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void BroadcastToCPUKernel<T>::CheckArgs() {
|
||||
void BroadcastToCpuKernelMod<T>::CheckArgs() {
|
||||
size_t input_shape_size = input_shape_.size();
|
||||
size_t output_shape_size = output_shape_.size();
|
||||
if (output_shape_size < input_shape_size) {
|
||||
|
@ -71,8 +71,8 @@ void BroadcastToCPUKernel<T>::CheckArgs() {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool BroadcastToCPUKernel<T>::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool BroadcastToCpuKernelMod<T>::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kBroadcastToOutputsNum, kernel_name_);
|
||||
CheckArgs();
|
||||
const auto *input_addr = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -27,10 +27,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class BroadcastToCPUKernel : public CPUKernel {
|
||||
class BroadcastToCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
BroadcastToCPUKernel() = default;
|
||||
~BroadcastToCPUKernel() = default;
|
||||
BroadcastToCpuKernelMod() = default;
|
||||
~BroadcastToCpuKernelMod() = default;
|
||||
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) override;
|
||||
|
@ -45,23 +45,23 @@ class BroadcastToCPUKernel : public CPUKernel {
|
|||
};
|
||||
|
||||
MS_REG_CPU_KERNEL_T(BroadcastTo, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
BroadcastToCPUKernel, float);
|
||||
BroadcastToCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(BroadcastTo, KernelAttr().AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
BroadcastToCPUKernel, int);
|
||||
BroadcastToCpuKernelMod, int);
|
||||
MS_REG_CPU_KERNEL_T(BroadcastTo, KernelAttr().AddInputAttr(kNumberTypeBool).AddOutputAttr(kNumberTypeBool),
|
||||
BroadcastToCPUKernel, bool);
|
||||
BroadcastToCpuKernelMod, bool);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
DynamicBroadcastTo,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeFloat32),
|
||||
BroadcastToCPUKernel, float);
|
||||
BroadcastToCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
DynamicBroadcastTo,
|
||||
KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
BroadcastToCPUKernel, int);
|
||||
BroadcastToCpuKernelMod, int);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
DynamicBroadcastTo,
|
||||
KernelAttr().AddInputAttr(kNumberTypeBool).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeBool),
|
||||
BroadcastToCPUKernel, bool);
|
||||
BroadcastToCpuKernelMod, bool);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -30,7 +30,7 @@ constexpr size_t kCastOutputsNum = 1;
|
|||
} // namespace
|
||||
|
||||
template <typename S, typename T>
|
||||
void Cast(CastCPUKernel<S, T> *content, const S *in, T *out, size_t size) {
|
||||
void Cast(CastCpuKernelMod<S, T> *content, const S *in, T *out, size_t size) {
|
||||
auto task = [&in, &out](size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
out[i] = static_cast<T>(in[i]);
|
||||
|
@ -40,7 +40,7 @@ void Cast(CastCPUKernel<S, T> *content, const S *in, T *out, size_t size) {
|
|||
}
|
||||
|
||||
template <typename S, typename T>
|
||||
void CastCPUKernel<S, T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void CastCpuKernelMod<S, T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
source_dtype_ = AnfAlgo::GetInputDeviceDataType(kernel_node, 0);
|
||||
|
@ -48,8 +48,9 @@ void CastCPUKernel<S, T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename S, typename T>
|
||||
bool CastCPUKernel<S, T>::Launch(const std::vector<kernel::AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool CastCpuKernelMod<S, T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kCastInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kCastOutputsNum, kernel_name_);
|
||||
if (outputs[0]->size == 0) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -27,10 +27,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename S, typename T>
|
||||
class CastCPUKernel : public CPUKernel {
|
||||
class CastCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
CastCPUKernel() = default;
|
||||
~CastCPUKernel() override = default;
|
||||
CastCpuKernelMod() = default;
|
||||
~CastCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -42,161 +42,161 @@ class CastCPUKernel : public CPUKernel {
|
|||
TypeId target_dtype_{kTypeUnknown};
|
||||
};
|
||||
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint8_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint8_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint8_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint8_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint8_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint8_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint8_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint8_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint8_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint8_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint8_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint8_t, bool);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint8_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint8_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint8_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint8_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint8_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint8_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint8_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint8_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint8_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint8_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint8_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint8_t, bool);
|
||||
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint16_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint16_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint16_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint16_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint16_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint16_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint16_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint16_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint16_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint16_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint16_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint16_t, bool);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint16_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint16_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint16_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint16_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint16_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint16_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint16_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint16_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint16_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint16_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint16_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint16_t, bool);
|
||||
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint32_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint32_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint32_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint32_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint32_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint32_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint32_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint32_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint32_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint32_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint32_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint32_t, bool);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint32_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint32_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint32_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint32_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint32_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint32_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint32_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint32_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint32_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint32_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint32_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint32_t, bool);
|
||||
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint64_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint64_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint64_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint64_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint64_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint64_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint64_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint64_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint64_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint64_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint64_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, uint64_t, bool);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint64_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint64_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint64_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint64_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint64_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint64_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint64_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint64_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint64_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint64_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint64_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, uint64_t, bool);
|
||||
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int8_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int8_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int8_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int8_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int8_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int8_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int8_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int8_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int8_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int8_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int8_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int8_t, bool);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int8_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int8_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int8_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int8_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int8_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int8_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int8_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int8_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int8_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int8_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int8_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int8_t, bool);
|
||||
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int16_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int16_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int16_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int16_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int16_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int16_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int16_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int16_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int16_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int16_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int16_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int16_t, bool);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int16_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int16_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int16_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int16_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int16_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int16_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int16_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int16_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int16_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int16_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int16_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int16_t, bool);
|
||||
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int32_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int32_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int32_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int32_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int32_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int32_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int32_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int32_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int32_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int32_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int32_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int32_t, bool);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int32_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int32_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int32_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int32_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int32_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int32_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int32_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int32_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int32_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int32_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int32_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int32_t, bool);
|
||||
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int64_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int64_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int64_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int64_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int64_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int64_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int64_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int64_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int64_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int64_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int64_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, int64_t, bool);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int64_t, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int64_t, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int64_t, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int64_t, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int64_t, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int64_t, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int64_t, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int64_t, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int64_t, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int64_t, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int64_t, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, int64_t, bool);
|
||||
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float16, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float16, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float16, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float16, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float16, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float16, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float16, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float16, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float16, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float16, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float16, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float16, bool);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float16, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float16, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float16, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float16, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float16, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float16, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float16, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float16, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float16, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float16, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float16, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float16, bool);
|
||||
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, float, bool);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, float, bool);
|
||||
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, double, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, double, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, double, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, double, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, double, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, double, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, double, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, double, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, double, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, double, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, double, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, double, bool);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, double, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, double, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, double, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, double, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, double, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, double, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, double, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, double, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, double, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, double, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, double, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, double, bool);
|
||||
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, bool, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, bool, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, bool, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, bool, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, bool, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, bool, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, bool, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, bool, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, bool, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, bool, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, bool, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCPUKernel, bool, bool);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, bool, uint8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, bool, uint16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, bool, uint32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, bool, uint64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, bool, int8_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, bool, int16_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, bool, int32_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, bool, int64_t);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, bool, float16);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, bool, float);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, bool, double);
|
||||
MS_REG_CPU_KERNEL_T_S(Cast, KernelAttr(), CastCpuKernelMod, bool, bool);
|
||||
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -30,7 +30,7 @@ constexpr size_t kIndex2 = 2;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void CheckValidCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void CheckValidCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
anchor_box_shape_ = AnfAlgo::GetInputDeviceShape(kernel_node, 0);
|
||||
|
@ -39,9 +39,9 @@ void CheckValidCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool CheckValidCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool CheckValidCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CheckParams(inputs, outputs);
|
||||
auto anchor_box = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
auto img_metas = reinterpret_cast<T *>(inputs[1]->addr);
|
||||
|
@ -77,8 +77,8 @@ bool CheckValidCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &input
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void CheckValidCPUKernel<T>::CheckParams(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
void CheckValidCpuKernelMod<T>::CheckParams(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
// inputs: anchor_box, img_metas
|
||||
if (inputs.size() != kInputSize) {
|
||||
MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', the number of inputs should be " << kInputSize << ", but got "
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,10 +26,10 @@ namespace mindspore {
|
|||
namespace kernel {
|
||||
constexpr size_t COORDINATE = 4;
|
||||
template <typename T>
|
||||
class CheckValidCPUKernel : public CPUKernel {
|
||||
class CheckValidCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
CheckValidCPUKernel() = default;
|
||||
~CheckValidCPUKernel() override = default;
|
||||
CheckValidCpuKernelMod() = default;
|
||||
~CheckValidCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -46,20 +46,20 @@ class CheckValidCPUKernel : public CPUKernel {
|
|||
MS_REG_CPU_KERNEL_T(
|
||||
CheckValid,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeBool),
|
||||
CheckValidCPUKernel, float);
|
||||
CheckValidCpuKernelMod, float);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
CheckValid,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat16).AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeBool),
|
||||
CheckValidCPUKernel, float16);
|
||||
CheckValidCpuKernelMod, float16);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
CheckValid, KernelAttr().AddInputAttr(kNumberTypeInt16).AddInputAttr(kNumberTypeInt16).AddOutputAttr(kNumberTypeBool),
|
||||
CheckValidCPUKernel, int16_t);
|
||||
CheckValidCpuKernelMod, int16_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
CheckValid, KernelAttr().AddInputAttr(kNumberTypeUInt8).AddInputAttr(kNumberTypeUInt8).AddOutputAttr(kNumberTypeBool),
|
||||
CheckValidCPUKernel, uint8_t);
|
||||
CheckValidCpuKernelMod, uint8_t);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -22,7 +22,7 @@ namespace {
|
|||
constexpr size_t kDimNum = 2;
|
||||
}
|
||||
template <typename T>
|
||||
void CholeskyInverseCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void CholeskyInverseCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
node_wpt_ = kernel_node;
|
||||
size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node);
|
||||
size_t output_num = AnfAlgo::GetOutputTensorNum(kernel_node);
|
||||
|
@ -42,9 +42,9 @@ void CholeskyInverseCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool CholeskyInverseCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool CholeskyInverseCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
auto input_x0 = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
auto output_y = reinterpret_cast<T *>(outputs[0]->addr);
|
||||
auto inputShape = AnfAlgo::GetInputDeviceShape(node_wpt_, 0);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@ constexpr size_t kInputNum = 1;
|
|||
constexpr size_t kOutputNum = 1;
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class CholeskyInverseCPUKernel : public CPUKernel {
|
||||
class CholeskyInverseCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
CholeskyInverseCPUKernel() = default;
|
||||
~CholeskyInverseCPUKernel() override = default;
|
||||
CholeskyInverseCpuKernelMod() = default;
|
||||
~CholeskyInverseCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -39,9 +39,9 @@ class CholeskyInverseCPUKernel : public CPUKernel {
|
|||
CNodePtr node_wpt_;
|
||||
};
|
||||
MS_REG_CPU_KERNEL_T(CholeskyInverse, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
CholeskyInverseCPUKernel, float)
|
||||
CholeskyInverseCpuKernelMod, float)
|
||||
MS_REG_CPU_KERNEL_T(CholeskyInverse, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
CholeskyInverseCPUKernel, double)
|
||||
CholeskyInverseCpuKernelMod, double)
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_CHOLESKYINVERSE_CPU_KERNEL_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,7 +24,7 @@ constexpr size_t kConcatOutputsNum = 1;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void ConcatCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void ConcatCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
cnode_ptr_ = kernel_node;
|
||||
|
@ -36,8 +36,9 @@ void ConcatCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool ConcatCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool ConcatCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
auto node_ = cnode_ptr_.lock();
|
||||
if (!node_) {
|
||||
MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', cnode_ptr_(kernel_node) is expired. Error no: " << node_;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,10 +26,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class ConcatCPUKernel : public CPUKernel {
|
||||
class ConcatCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
ConcatCPUKernel() = default;
|
||||
~ConcatCPUKernel() override = default;
|
||||
ConcatCpuKernelMod() = default;
|
||||
~ConcatCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -40,17 +40,17 @@ class ConcatCPUKernel : public CPUKernel {
|
|||
int axis_{0};
|
||||
};
|
||||
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCPUKernel, float)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCPUKernel, double)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCPUKernel, int8_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCPUKernel, int16_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCPUKernel, int32_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCPUKernel, int64_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCPUKernel, uint8_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCPUKernel, uint16_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCPUKernel, uint32_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCPUKernel, uint64_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCPUKernel, bool)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCpuKernelMod, float)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCpuKernelMod, double)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCpuKernelMod, int8_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCpuKernelMod, int16_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCpuKernelMod, int32_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCpuKernelMod, int64_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCpuKernelMod, uint8_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCpuKernelMod, uint16_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCpuKernelMod, uint32_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCpuKernelMod, uint64_t)
|
||||
MS_REG_CPU_KERNEL_T(Concat, KernelAttr(), ConcatCpuKernelMod, bool)
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,7 +25,7 @@ constexpr size_t kConcatOffsetOutputShapeSize = 2;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void ConcatOffsetCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void ConcatOffsetCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
cnode_ptr_ = kernel_node;
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
|
@ -45,9 +45,9 @@ void ConcatOffsetCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool ConcatOffsetCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool ConcatOffsetCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kConcatOffsetOutputNum, kernel_name_);
|
||||
auto node_ = cnode_ptr_.lock();
|
||||
if (!node_) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class ConcatOffsetCPUKernel : public CPUKernel {
|
||||
class ConcatOffsetCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
ConcatOffsetCPUKernel() = default;
|
||||
~ConcatOffsetCPUKernel() override = default;
|
||||
ConcatOffsetCpuKernelMod() = default;
|
||||
~ConcatOffsetCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -39,16 +39,16 @@ class ConcatOffsetCPUKernel : public CPUKernel {
|
|||
size_t axis_{0};
|
||||
};
|
||||
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCPUKernel, float);
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCPUKernel, int8_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCPUKernel, int16_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCPUKernel, int32_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCPUKernel, int64_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCPUKernel, uint8_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCPUKernel, uint16_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCPUKernel, uint32_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCPUKernel, uint64_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCPUKernel, bool)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCpuKernelMod, int8_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCpuKernelMod, int16_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCpuKernelMod, int32_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCpuKernelMod, int64_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCpuKernelMod, uint8_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCpuKernelMod, uint16_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCpuKernelMod, uint32_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCpuKernelMod, uint64_t)
|
||||
MS_REG_CPU_KERNEL_T(ConcatOffset, KernelAttr(), ConcatOffsetCpuKernelMod, bool)
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,12 +36,12 @@ void CpuDynamicKernel::UpdateArgs() {
|
|||
MS_LOG(INFO) << "Update Args: " << cnode->fullname_with_scope();
|
||||
auto kernel_mod = AnfAlgo::GetKernelMod(cnode);
|
||||
MS_EXCEPTION_IF_NULL(kernel_mod);
|
||||
auto cpu_kernel_mod = dynamic_cast<CPUKernel *>(kernel_mod);
|
||||
auto cpu_kernel_mod = dynamic_cast<NativeCpuKernelMod *>(kernel_mod);
|
||||
MS_EXCEPTION_IF_NULL(cpu_kernel_mod);
|
||||
cpu_kernel_mod->Init(cnode);
|
||||
}
|
||||
|
||||
void CPUKernel::InitInputOutputSize(const CNodePtr &kernel_node) {
|
||||
void NativeCpuKernelMod::InitInputOutputSize(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
input_size_list_.clear();
|
||||
output_size_list_.clear();
|
||||
|
@ -67,7 +67,7 @@ void CPUKernel::InitInputOutputSize(const CNodePtr &kernel_node) {
|
|||
}
|
||||
}
|
||||
|
||||
void CPUKernel::Init(const CNodePtr &kernel_node) {
|
||||
void NativeCpuKernelMod::Init(const CNodePtr &kernel_node) {
|
||||
InitKernel(kernel_node);
|
||||
InitInputOutputSize(kernel_node);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,6 +25,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "backend/kernel_compiler/kernel.h"
|
||||
#include "backend/kernel_compiler/cpu/cpu_kernel_mod.h"
|
||||
#include "backend/session/anf_runtime_algorithm.h"
|
||||
#include "backend/kernel_compiler/common_utils.h"
|
||||
#include "ir/anf.h"
|
||||
|
@ -119,10 +120,10 @@ class CpuDynamicKernel : public device::DynamicKernel {
|
|||
void Execute() final { MS_LOG(EXCEPTION) << "`Execute()` should not invoked with cpu backend"; }
|
||||
};
|
||||
|
||||
class CPUKernel : public kernel::KernelMod {
|
||||
class NativeCpuKernelMod : public CpuKernelMod {
|
||||
public:
|
||||
CPUKernel() = default;
|
||||
~CPUKernel() override = default;
|
||||
NativeCpuKernelMod() = default;
|
||||
~NativeCpuKernelMod() override = default;
|
||||
virtual void Init(const CNodePtr &kernel_node);
|
||||
virtual void InitKernel(const CNodePtr &kernel_node) = 0;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
|
@ -131,9 +132,6 @@ class CPUKernel : public kernel::KernelMod {
|
|||
};
|
||||
virtual bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) = 0;
|
||||
const std::vector<size_t> &GetInputSizeList() const override { return input_size_list_; }
|
||||
const std::vector<size_t> &GetOutputSizeList() const override { return output_size_list_; }
|
||||
const std::vector<size_t> &GetWorkspaceSizeList() const override { return workspace_size_list_; }
|
||||
|
||||
void SetCNodePtr(const CNodePtr &kernel_node) { cnode_ptr_ = kernel_node; }
|
||||
const CNodeWeakPtr &GetCNodePtr() { return cnode_ptr_; }
|
||||
|
@ -144,9 +142,6 @@ class CPUKernel : public kernel::KernelMod {
|
|||
|
||||
protected:
|
||||
virtual void InitInputOutputSize(const CNodePtr &kernel_node);
|
||||
std::vector<size_t> input_size_list_;
|
||||
std::vector<size_t> output_size_list_;
|
||||
std::vector<size_t> workspace_size_list_;
|
||||
CNodeWeakPtr cnode_ptr_;
|
||||
device::DynamicKernelPtr dynamic_kernel_;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -29,20 +29,21 @@ namespace {
|
|||
const std::set<std::string> same_op_name = {"Concat", "Pack", "Stack", "Split", "Transpose",
|
||||
"Unpack", "AddN", "ConcatOffset", "DynamicStitch"};
|
||||
}
|
||||
CPUKernelFactory &CPUKernelFactory::GetInstance() {
|
||||
static CPUKernelFactory instance;
|
||||
NativeCpuKernelModFactory &NativeCpuKernelModFactory::GetInstance() {
|
||||
static NativeCpuKernelModFactory instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void CPUKernelFactory::Register(const std::string &kernel_name, const KernelAttr &kernel_attr,
|
||||
CPUKernelCreator &&kernel_creator) {
|
||||
void NativeCpuKernelModFactory::Register(const std::string &kernel_name, const KernelAttr &kernel_attr,
|
||||
NativeCpuKernelModCreator &&kernel_creator) {
|
||||
(void)name_to_attr_creator_[kernel_name].emplace_back(kernel_attr, kernel_creator);
|
||||
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__APPLE__)
|
||||
MS_LOG(DEBUG) << "CPUKernelFactory register operator: " << kernel_name;
|
||||
MS_LOG(DEBUG) << "NativeCpuKernelModFactory register operator: " << kernel_name;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::shared_ptr<CPUKernel> CPUKernelFactory::Create(const std::string &kernel_name, const CNodePtr &apply_kernel) {
|
||||
std::shared_ptr<NativeCpuKernelMod> NativeCpuKernelModFactory::Create(const std::string &kernel_name,
|
||||
const CNodePtr &apply_kernel) {
|
||||
MS_EXCEPTION_IF_NULL(apply_kernel);
|
||||
auto kernel_info = dynamic_cast<device::KernelInfo *>(apply_kernel->kernel_info());
|
||||
MS_EXCEPTION_IF_NULL(kernel_info);
|
||||
|
@ -55,8 +56,8 @@ std::shared_ptr<CPUKernel> CPUKernelFactory::Create(const std::string &kernel_na
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void CPUKernelFactory::SetKernelAttrs(const std::shared_ptr<kernel::OpInfo> op_info,
|
||||
std::vector<KernelAttr> *kernel_attrs) {
|
||||
void NativeCpuKernelModFactory::SetKernelAttrs(const std::shared_ptr<kernel::OpInfo> op_info,
|
||||
std::vector<KernelAttr> *kernel_attrs) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_attrs);
|
||||
MS_EXCEPTION_IF_NULL(op_info);
|
||||
auto inputs_ptr = op_info->inputs_ptr();
|
||||
|
@ -85,9 +86,10 @@ void CPUKernelFactory::SetKernelAttrs(const std::shared_ptr<kernel::OpInfo> op_i
|
|||
}
|
||||
}
|
||||
|
||||
void CPUKernelFactory::UpdateKernelAttrs(const std::string &kernel_name, const std::vector<KernelAttr> &kernel_attrs) {
|
||||
void NativeCpuKernelModFactory::UpdateKernelAttrs(const std::string &kernel_name,
|
||||
const std::vector<KernelAttr> &kernel_attrs) {
|
||||
size_t attr_size = kernel_attrs.size();
|
||||
std::vector<std::pair<KernelAttr, CPUKernelCreator>> attr_creators(attr_size);
|
||||
std::vector<std::pair<KernelAttr, NativeCpuKernelModCreator>> attr_creators(attr_size);
|
||||
auto iter = name_to_attr_creator_.find(kernel_name);
|
||||
if (iter == name_to_attr_creator_.end()) {
|
||||
MS_LOG(EXCEPTION) << "For '" << kernel_name
|
||||
|
@ -112,8 +114,8 @@ void CPUKernelFactory::UpdateKernelAttrs(const std::string &kernel_name, const s
|
|||
name_to_attr_creator_[kernel_name] = attr_creators;
|
||||
}
|
||||
|
||||
std::pair<bool, size_t> CPUKernelFactory::CPUKernelAttrCheck(const std::string &kernel_name,
|
||||
const KernelBuildInfo &kernel_info) {
|
||||
std::pair<bool, size_t> NativeCpuKernelModFactory::CPUKernelAttrCheck(const std::string &kernel_name,
|
||||
const KernelBuildInfo &kernel_info) {
|
||||
auto iter = name_to_attr_creator_.find(kernel_name);
|
||||
if (iter == name_to_attr_creator_.end()) {
|
||||
MS_LOG(INFO) << "Not registered CPU kernel: op[" << kernel_name << "]!";
|
||||
|
@ -133,7 +135,7 @@ std::pair<bool, size_t> CPUKernelFactory::CPUKernelAttrCheck(const std::string &
|
|||
}
|
||||
kernel_attrs.clear();
|
||||
SetKernelAttrs(op_info_ptr, &kernel_attrs);
|
||||
kernel::CPUKernelFactory::GetInstance().UpdateKernelAttrs(kernel_name, kernel_attrs);
|
||||
kernel::NativeCpuKernelModFactory::GetInstance().UpdateKernelAttrs(kernel_name, kernel_attrs);
|
||||
}
|
||||
for (size_t index = 0; index < kernel_attrs.size(); ++index) {
|
||||
if (CPUKernelSingleAttrCheck(kernel_attrs[index], kernel_info)) {
|
||||
|
@ -143,8 +145,8 @@ std::pair<bool, size_t> CPUKernelFactory::CPUKernelAttrCheck(const std::string &
|
|||
return std::make_pair(false, 0);
|
||||
}
|
||||
|
||||
bool CPUKernelFactory::CPUKernelSingleAttrCheck(const KernelAttr &kernel_attr,
|
||||
const KernelBuildInfo &kernel_info) const {
|
||||
bool NativeCpuKernelModFactory::CPUKernelSingleAttrCheck(const KernelAttr &kernel_attr,
|
||||
const KernelBuildInfo &kernel_info) const {
|
||||
for (size_t i = 0; i < kernel_info.GetInputNum(); ++i) {
|
||||
auto dtype = kernel_attr.GetAllSame() ? kernel_attr.GetInputAttr(0).first : kernel_attr.GetInputAttr(i).first;
|
||||
if (kernel_info.GetInputDeviceType(i) != dtype) {
|
||||
|
@ -164,7 +166,7 @@ bool CPUKernelFactory::CPUKernelSingleAttrCheck(const KernelAttr &kernel_attr,
|
|||
return true;
|
||||
}
|
||||
|
||||
std::vector<KernelAttr> CPUKernelFactory::GetSupportedKernelAttrList(const std::string &kernel_name) {
|
||||
std::vector<KernelAttr> NativeCpuKernelModFactory::GetSupportedKernelAttrList(const std::string &kernel_name) {
|
||||
std::vector<KernelAttr> result;
|
||||
auto iter = name_to_attr_creator_.find(kernel_name);
|
||||
if (iter == name_to_attr_creator_.end()) {
|
||||
|
@ -182,7 +184,7 @@ std::vector<KernelAttr> CPUKernelFactory::GetSupportedKernelAttrList(const std::
|
|||
return result;
|
||||
}
|
||||
|
||||
bool CPUKernelFactory::SearchRegisteredOp(const std::string &kernel_name) const {
|
||||
bool NativeCpuKernelModFactory::SearchRegisteredOp(const std::string &kernel_name) const {
|
||||
auto iter = name_to_attr_creator_.find(kernel_name);
|
||||
return iter != name_to_attr_creator_.end();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -32,52 +32,54 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
using mindspore::device::cpu::KernelAttr;
|
||||
using CPUKernelCreator = std::function<std::shared_ptr<CPUKernel>()>;
|
||||
using NativeCpuKernelModCreator = std::function<std::shared_ptr<NativeCpuKernelMod>()>;
|
||||
|
||||
class CPUKernelFactory {
|
||||
class NativeCpuKernelModFactory {
|
||||
public:
|
||||
static CPUKernelFactory &GetInstance();
|
||||
void Register(const std::string &kernel_name, const KernelAttr &kernel_attr, CPUKernelCreator &&kernel_creator);
|
||||
std::shared_ptr<CPUKernel> Create(const std::string &kernel_name, const CNodePtr &apply_kernel);
|
||||
static NativeCpuKernelModFactory &GetInstance();
|
||||
void Register(const std::string &kernel_name, const KernelAttr &kernel_attr,
|
||||
NativeCpuKernelModCreator &&kernel_creator);
|
||||
std::shared_ptr<NativeCpuKernelMod> Create(const std::string &kernel_name, const CNodePtr &apply_kernel);
|
||||
void SetKernelAttrs(const std::shared_ptr<kernel::OpInfo> op_info, std::vector<KernelAttr> *kernel_attrs);
|
||||
void UpdateKernelAttrs(const std::string &kernel_name, const std::vector<KernelAttr> &kernel_attrs);
|
||||
std::vector<KernelAttr> GetSupportedKernelAttrList(const std::string &kernel_name);
|
||||
bool SearchRegisteredOp(const std::string &kernel_name) const;
|
||||
|
||||
private:
|
||||
CPUKernelFactory() = default;
|
||||
~CPUKernelFactory() = default;
|
||||
DISABLE_COPY_AND_ASSIGN(CPUKernelFactory)
|
||||
NativeCpuKernelModFactory() = default;
|
||||
~NativeCpuKernelModFactory() = default;
|
||||
DISABLE_COPY_AND_ASSIGN(NativeCpuKernelModFactory)
|
||||
std::pair<bool, size_t> CPUKernelAttrCheck(const std::string &kernel_name, const KernelBuildInfo &kernel_info);
|
||||
bool CPUKernelSingleAttrCheck(const KernelAttr &kernel_attr, const KernelBuildInfo &kernel_info) const;
|
||||
std::map<std::string, std::vector<std::pair<KernelAttr, CPUKernelCreator>>> name_to_attr_creator_;
|
||||
std::map<std::string, std::vector<std::pair<KernelAttr, NativeCpuKernelModCreator>>> name_to_attr_creator_;
|
||||
};
|
||||
|
||||
class CPUKernelRegistrar {
|
||||
class NativeCpuKernelRegistrar {
|
||||
public:
|
||||
CPUKernelRegistrar(const std::string &kernel_name, const KernelAttr &kernel_attr, CPUKernelCreator &&kernel_creator) {
|
||||
CPUKernelFactory::GetInstance().Register(kernel_name, kernel_attr, std::move(kernel_creator));
|
||||
NativeCpuKernelRegistrar(const std::string &kernel_name, const KernelAttr &kernel_attr,
|
||||
NativeCpuKernelModCreator &&kernel_creator) {
|
||||
NativeCpuKernelModFactory::GetInstance().Register(kernel_name, kernel_attr, std::move(kernel_creator));
|
||||
}
|
||||
~CPUKernelRegistrar() = default;
|
||||
~NativeCpuKernelRegistrar() = default;
|
||||
};
|
||||
|
||||
#define MS_REG_CPU_KERNEL(OPNAME, ATTR, OPCLASS) MS_REG_CPU_KERNEL_(__COUNTER__, OPNAME, ATTR, OPCLASS)
|
||||
#define MS_REG_CPU_KERNEL_(COUNT, OPNAME, ATTR, OPCLASS) _MS_REG_CPU_KERNEL_(COUNT, OPNAME, ATTR, OPCLASS)
|
||||
#define _MS_REG_CPU_KERNEL_(COUNT, OPNAME, ATTR, OPCLASS) \
|
||||
static_assert(std::is_base_of<CPUKernel, OPCLASS>::value, " must be base of CPUKernel"); \
|
||||
static const CPUKernelRegistrar g_cpu_kernel_##COUNT##_reg(#OPNAME, ATTR, \
|
||||
[]() { return std::make_shared<OPCLASS>(); });
|
||||
#define _MS_REG_CPU_KERNEL_(COUNT, OPNAME, ATTR, OPCLASS) \
|
||||
static_assert(std::is_base_of<NativeCpuKernelMod, OPCLASS>::value, " must be base of NativeCpuKernelMod"); \
|
||||
static const NativeCpuKernelRegistrar g_cpu_kernel_##COUNT##_reg(#OPNAME, ATTR, \
|
||||
[]() { return std::make_shared<OPCLASS>(); });
|
||||
|
||||
#define MS_REG_CPU_KERNEL_T(OPNAME, ATTR, OPCLASS, T) MS_REG_CPU_KERNEL_T_(__COUNTER__, OPNAME, ATTR, OPCLASS, T)
|
||||
#define MS_REG_CPU_KERNEL_T_(COUNT, OPNAME, ATTR, OPCLASS, T) _MS_REG_CPU_KERNEL_T_(COUNT, OPNAME, ATTR, OPCLASS, T)
|
||||
#define _MS_REG_CPU_KERNEL_T_(COUNT, OPNAME, ATTR, OPCLASS, T) \
|
||||
static_assert(std::is_base_of<CPUKernel, OPCLASS<T>>::value, " must be base of CPUKernel"); \
|
||||
static const CPUKernelRegistrar g_cpu_kernel_##COUNT##_##OPNAME##_##T##_reg( \
|
||||
#define _MS_REG_CPU_KERNEL_T_(COUNT, OPNAME, ATTR, OPCLASS, T) \
|
||||
static_assert(std::is_base_of<NativeCpuKernelMod, OPCLASS<T>>::value, " must be base of NativeCpuKernelMod"); \
|
||||
static const NativeCpuKernelRegistrar g_cpu_kernel_##COUNT##_##OPNAME##_##T##_reg( \
|
||||
#OPNAME, ATTR, []() { return std::make_shared<OPCLASS<T>>(); });
|
||||
|
||||
#define MS_REG_CPU_KERNEL_T_S(OPNAME, ATTR, OPCLASS, T, S) \
|
||||
static_assert(std::is_base_of<CPUKernel, OPCLASS<T, S>>::value, " must be base of CPUKernel"); \
|
||||
static const CPUKernelRegistrar g_cpu_kernel_##OPNAME##_##T##_##S##_reg( \
|
||||
#define MS_REG_CPU_KERNEL_T_S(OPNAME, ATTR, OPCLASS, T, S) \
|
||||
static_assert(std::is_base_of<NativeCpuKernelMod, OPCLASS<T, S>>::value, " must be base of NativeCpuKernelMod"); \
|
||||
static const NativeCpuKernelRegistrar g_cpu_kernel_##OPNAME##_##T##_##S##_reg( \
|
||||
#OPNAME, ATTR, []() { return std::make_shared<OPCLASS<T, S>>(); });
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* Copyright 2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_CPU_KERNEL_MOD_H_
|
||||
#define MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_CPU_KERNEL_MOD_H_
|
||||
|
||||
#include "backend/kernel_compiler/kernel.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class CpuKernelMod : public KernelMod {
|
||||
public:
|
||||
CpuKernelMod() = default;
|
||||
~CpuKernelMod() override = default;
|
||||
};
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_CPU_KERNEL_MOD_H_
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,7 +20,7 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
void CropAndResizeCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void CropAndResizeCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node);
|
||||
|
@ -101,9 +101,9 @@ void CropAndResizeCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool CropAndResizeCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool CropAndResizeCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
auto *input_image = reinterpret_cast<T *>(inputs[IMAGE]->addr);
|
||||
auto *input_boxes = reinterpret_cast<float *>(inputs[BOXES]->addr);
|
||||
auto *input_box_index = reinterpret_cast<int *>(inputs[BOX_INDEX]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -41,10 +41,10 @@ constexpr size_t CROP_SIZE = 3;
|
|||
constexpr size_t IMAGE_HEIGHT = 1;
|
||||
constexpr size_t IMAGE_WEIGHT = 2;
|
||||
template <typename T>
|
||||
class CropAndResizeCPUKernel : public CPUKernel {
|
||||
class CropAndResizeCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
CropAndResizeCPUKernel() = default;
|
||||
~CropAndResizeCPUKernel() override = default;
|
||||
CropAndResizeCpuKernelMod() = default;
|
||||
~CropAndResizeCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -69,7 +69,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, float16);
|
||||
CropAndResizeCpuKernelMod, float16);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -78,7 +78,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt64)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, float16);
|
||||
CropAndResizeCpuKernelMod, float16);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -87,7 +87,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, float);
|
||||
CropAndResizeCpuKernelMod, float);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -96,7 +96,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt64)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, float);
|
||||
CropAndResizeCpuKernelMod, float);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -105,7 +105,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, double);
|
||||
CropAndResizeCpuKernelMod, double);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -114,7 +114,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt64)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, double);
|
||||
CropAndResizeCpuKernelMod, double);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -123,7 +123,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, int8_t);
|
||||
CropAndResizeCpuKernelMod, int8_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -132,7 +132,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt64)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, int8_t);
|
||||
CropAndResizeCpuKernelMod, int8_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -141,7 +141,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, int16_t);
|
||||
CropAndResizeCpuKernelMod, int16_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -150,7 +150,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt64)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, int16_t);
|
||||
CropAndResizeCpuKernelMod, int16_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -159,7 +159,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, int8_t);
|
||||
CropAndResizeCpuKernelMod, int8_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -168,7 +168,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt64)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, int32_t);
|
||||
CropAndResizeCpuKernelMod, int32_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -177,7 +177,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, int64_t);
|
||||
CropAndResizeCpuKernelMod, int64_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -186,7 +186,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt64)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, int64_t);
|
||||
CropAndResizeCpuKernelMod, int64_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -195,7 +195,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, uint8_t);
|
||||
CropAndResizeCpuKernelMod, uint8_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -204,7 +204,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt64)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, uint8_t);
|
||||
CropAndResizeCpuKernelMod, uint8_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -213,7 +213,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, uint16_t);
|
||||
CropAndResizeCpuKernelMod, uint16_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(CropAndResize,
|
||||
KernelAttr()
|
||||
|
@ -222,7 +222,7 @@ MS_REG_CPU_KERNEL_T(CropAndResize,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddInputAttr(kNumberTypeInt64)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CropAndResizeCPUKernel, uint16_t);
|
||||
CropAndResizeCpuKernelMod, uint16_t);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -70,7 +70,7 @@ void MatrixFromVector(uint32_t row, uint32_t col, std::vector<std::vector<T>> *a
|
|||
}
|
||||
} // namespace
|
||||
|
||||
void CTCLossCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void CTCLossCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
probs_shape_ = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0);
|
||||
|
@ -100,8 +100,8 @@ void CTCLossCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
|||
blank_index_ = num_class_ - 1;
|
||||
}
|
||||
|
||||
bool CTCLossCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool CTCLossCpuKernelMod::Launch(const std::vector<kernel::AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kCTCLossInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kCTCLossOutputsNum, kernel_name_);
|
||||
if (dtype_ == kNumberTypeFloat16) {
|
||||
|
@ -117,9 +117,9 @@ bool CTCLossCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs, con
|
|||
}
|
||||
|
||||
template <typename TT>
|
||||
void CTCLossCPUKernel::CalculateFwdVar(const std::vector<uint32_t> &label_with_blank,
|
||||
const std::vector<std::vector<TT>> &y,
|
||||
std::vector<std::vector<TT>> *log_alpha_b) const {
|
||||
void CTCLossCpuKernelMod::CalculateFwdVar(const std::vector<uint32_t> &label_with_blank,
|
||||
const std::vector<std::vector<TT>> &y,
|
||||
std::vector<std::vector<TT>> *log_alpha_b) const {
|
||||
int U = label_with_blank.size();
|
||||
int T = (*log_alpha_b)[0].size();
|
||||
TT kLogZero_ = -std::numeric_limits<TT>::infinity();
|
||||
|
@ -157,9 +157,9 @@ void CTCLossCPUKernel::CalculateFwdVar(const std::vector<uint32_t> &label_with_b
|
|||
}
|
||||
|
||||
template <typename TT>
|
||||
void CTCLossCPUKernel::CalculateBwdVar(const std::vector<uint32_t> &label_with_blank,
|
||||
const std::vector<std::vector<TT>> &y,
|
||||
std::vector<std::vector<TT>> *log_beta_b) const {
|
||||
void CTCLossCpuKernelMod::CalculateBwdVar(const std::vector<uint32_t> &label_with_blank,
|
||||
const std::vector<std::vector<TT>> &y,
|
||||
std::vector<std::vector<TT>> *log_beta_b) const {
|
||||
int T = (*log_beta_b)[0].size();
|
||||
int U = label_with_blank.size();
|
||||
if (U > 1) {
|
||||
|
@ -197,11 +197,11 @@ void CTCLossCPUKernel::CalculateBwdVar(const std::vector<uint32_t> &label_with_b
|
|||
}
|
||||
|
||||
template <typename TT>
|
||||
void CTCLossCPUKernel::CalculateGrad(const std::vector<uint32_t> &label_with_blank,
|
||||
const std::vector<std::vector<TT>> &y,
|
||||
const std::vector<std::vector<TT>> &log_alpha_b,
|
||||
const std::vector<std::vector<TT>> &log_beta_b, const TT log_pzx,
|
||||
std::vector<std::vector<TT>> *dy) const {
|
||||
void CTCLossCpuKernelMod::CalculateGrad(const std::vector<uint32_t> &label_with_blank,
|
||||
const std::vector<std::vector<TT>> &y,
|
||||
const std::vector<std::vector<TT>> &log_alpha_b,
|
||||
const std::vector<std::vector<TT>> &log_beta_b, const TT log_pzx,
|
||||
std::vector<std::vector<TT>> *dy) const {
|
||||
auto dy_b = dy;
|
||||
TT kLogZero_ = -std::numeric_limits<TT>::infinity();
|
||||
if (log_pzx <= kLogZero_) {
|
||||
|
@ -226,8 +226,9 @@ void CTCLossCPUKernel::CalculateGrad(const std::vector<uint32_t> &label_with_bla
|
|||
}
|
||||
}
|
||||
|
||||
void CTCLossCPUKernel::GenLabelWithBlank(const uint32_t *seq_len, const std::vector<std::vector<uint32_t>> &batch_label,
|
||||
std::vector<std::vector<uint32_t>> *label_with_blank) const {
|
||||
void CTCLossCpuKernelMod::GenLabelWithBlank(const uint32_t *seq_len,
|
||||
const std::vector<std::vector<uint32_t>> &batch_label,
|
||||
std::vector<std::vector<uint32_t>> *label_with_blank) const {
|
||||
for (size_t b = 0; b < batch_size_; ++b) {
|
||||
std::vector<uint32_t> l;
|
||||
const std::vector<uint32_t> &label = batch_label[b];
|
||||
|
@ -262,8 +263,8 @@ void CTCLossCPUKernel::GenLabelWithBlank(const uint32_t *seq_len, const std::vec
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void CTCLossCPUKernel::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) const {
|
||||
void CTCLossCpuKernelMod::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) const {
|
||||
const auto *inputs_addr = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
const auto *labels_indices_addr = reinterpret_cast<uint64_t *>(inputs[1]->addr);
|
||||
const auto *labels_values_addr = reinterpret_cast<uint32_t *>(inputs[2]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,10 +28,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class CTCLossCPUKernel : public CPUKernel {
|
||||
class CTCLossCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
CTCLossCPUKernel() = default;
|
||||
~CTCLossCPUKernel() override = default;
|
||||
CTCLossCpuKernelMod() = default;
|
||||
~CTCLossCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -77,7 +77,7 @@ MS_REG_CPU_KERNEL(CTCLoss,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddOutputAttr(kNumberTypeFloat16)
|
||||
.AddOutputAttr(kNumberTypeFloat16),
|
||||
CTCLossCPUKernel);
|
||||
CTCLossCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(CTCLoss,
|
||||
KernelAttr()
|
||||
|
@ -87,7 +87,7 @@ MS_REG_CPU_KERNEL(CTCLoss,
|
|||
.AddInputAttr(kNumberTypeInt32)
|
||||
.AddOutputAttr(kNumberTypeFloat32)
|
||||
.AddOutputAttr(kNumberTypeFloat32),
|
||||
CTCLossCPUKernel);
|
||||
CTCLossCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_CTCLOSS_CPU_KERNEL_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -27,7 +27,7 @@ constexpr size_t kCumSumInputsNum = 1;
|
|||
constexpr size_t kCumSumOutputsNum = 1;
|
||||
} // namespace
|
||||
|
||||
void CumSumCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void CumSumCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
shape_ = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0);
|
||||
|
@ -48,7 +48,7 @@ void CumSumCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void CumSumCPUKernel::InitWorkspaceSize() {
|
||||
void CumSumCpuKernelMod::InitWorkspaceSize() {
|
||||
input_size_0_ = sizeof(T);
|
||||
for (size_t i = 0; i < shape_.size(); i++) {
|
||||
input_size_0_ *= shape_[i];
|
||||
|
@ -56,8 +56,8 @@ void CumSumCPUKernel::InitWorkspaceSize() {
|
|||
(void)workspace_size_list_.emplace_back(input_size_0_);
|
||||
}
|
||||
|
||||
void CumSumCPUKernel::InitInputOutputSize(const CNodePtr &kernel_node) {
|
||||
CPUKernel::InitInputOutputSize(kernel_node);
|
||||
void CumSumCpuKernelMod::InitInputOutputSize(const CNodePtr &kernel_node) {
|
||||
NativeCpuKernelMod::InitInputOutputSize(kernel_node);
|
||||
if (dtype_ == kNumberTypeFloat32) {
|
||||
InitWorkspaceSize<float_t>();
|
||||
} else if (dtype_ == kNumberTypeFloat16) {
|
||||
|
@ -75,9 +75,9 @@ void CumSumCPUKernel::InitInputOutputSize(const CNodePtr &kernel_node) {
|
|||
}
|
||||
}
|
||||
|
||||
bool CumSumCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &workspace,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool CumSumCpuKernelMod::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &workspace,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kCumSumInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kCumSumOutputsNum, kernel_name_);
|
||||
Reshape();
|
||||
|
@ -99,7 +99,7 @@ bool CumSumCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
|||
return true;
|
||||
}
|
||||
|
||||
void CumSumCPUKernel::Reshape() {
|
||||
void CumSumCpuKernelMod::Reshape() {
|
||||
dims_[0] = 1;
|
||||
dims_[1] = shape_[IntToSize(axis_)];
|
||||
dims_[2] = 1;
|
||||
|
@ -114,8 +114,8 @@ void CumSumCPUKernel::Reshape() {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void CumSumCPUKernel::LeftMove(const T *input, T *output, size_t dim0, size_t dim1, size_t dim2, size_t stride,
|
||||
size_t stride2, size_t start, size_t end) const {
|
||||
void CumSumCpuKernelMod::LeftMove(const T *input, T *output, size_t dim0, size_t dim1, size_t dim2, size_t stride,
|
||||
size_t stride2, size_t start, size_t end) const {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
size_t k1 = i / dim2 % dim0;
|
||||
size_t k2 = i % dim2;
|
||||
|
@ -133,8 +133,8 @@ void CumSumCPUKernel::LeftMove(const T *input, T *output, size_t dim0, size_t di
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void CumSumCPUKernel::RightMove(const T *input, T *output, size_t dim0, size_t dim1, size_t dim2, size_t stride,
|
||||
size_t stride2, size_t start, size_t end) const {
|
||||
void CumSumCpuKernelMod::RightMove(const T *input, T *output, size_t dim0, size_t dim1, size_t dim2, size_t stride,
|
||||
size_t stride2, size_t start, size_t end) const {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
size_t k1 = i / dim2 % dim0;
|
||||
size_t k2 = i % dim2;
|
||||
|
@ -152,8 +152,8 @@ void CumSumCPUKernel::RightMove(const T *input, T *output, size_t dim0, size_t d
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void CumSumCPUKernel::Copy(T *input, T *output, size_t dim0, size_t dim1, size_t dim2, size_t stride, size_t stride2,
|
||||
size_t start, size_t end) const {
|
||||
void CumSumCpuKernelMod::Copy(T *input, T *output, size_t dim0, size_t dim1, size_t dim2, size_t stride, size_t stride2,
|
||||
size_t start, size_t end) const {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
size_t k1 = i / dim2 % dim0;
|
||||
size_t k2 = i % dim2;
|
||||
|
@ -166,8 +166,8 @@ void CumSumCPUKernel::Copy(T *input, T *output, size_t dim0, size_t dim1, size_t
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void CumSumCPUKernel::CumSumKernelReverse(const T *input, T *output, size_t dim0, size_t dim1, size_t dim2,
|
||||
size_t stride, size_t stride2, size_t start, size_t end) const {
|
||||
void CumSumCpuKernelMod::CumSumKernelReverse(const T *input, T *output, size_t dim0, size_t dim1, size_t dim2,
|
||||
size_t stride, size_t stride2, size_t start, size_t end) const {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
size_t k1 = i / dim2 % dim0;
|
||||
size_t k2 = i % dim2;
|
||||
|
@ -185,8 +185,8 @@ void CumSumCPUKernel::CumSumKernelReverse(const T *input, T *output, size_t dim0
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void CumSumCPUKernel::CumSumKernel(const T *input, T *output, size_t dim0, size_t dim1, size_t dim2, size_t stride,
|
||||
size_t stride2, size_t start, size_t end) const {
|
||||
void CumSumCpuKernelMod::CumSumKernel(const T *input, T *output, size_t dim0, size_t dim1, size_t dim2, size_t stride,
|
||||
size_t stride2, size_t start, size_t end) const {
|
||||
for (size_t i = start; i < end; i++) {
|
||||
size_t k1 = i / dim2 % dim0;
|
||||
size_t k2 = i % dim2;
|
||||
|
@ -204,7 +204,7 @@ void CumSumCPUKernel::CumSumKernel(const T *input, T *output, size_t dim0, size_
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void CumSumCPUKernel::LaunchCumSum(const T *input, T *output, T *workspace, size_t start, size_t end) const {
|
||||
void CumSumCpuKernelMod::LaunchCumSum(const T *input, T *output, T *workspace, size_t start, size_t end) const {
|
||||
start = start / dims_[1];
|
||||
end = end / dims_[1];
|
||||
if (exclusive_) {
|
||||
|
@ -227,9 +227,9 @@ void CumSumCPUKernel::LaunchCumSum(const T *input, T *output, T *workspace, size
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void CumSumCPUKernel::LaunchKernel(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &workspace,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
void CumSumCpuKernelMod::LaunchKernel(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &workspace,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
const auto *input = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
auto *ws = reinterpret_cast<T *>(workspace[0]->addr);
|
||||
auto output = reinterpret_cast<T *>(outputs[0]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class CumSumCPUKernel : public CPUKernel {
|
||||
class CumSumCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
CumSumCPUKernel() = default;
|
||||
~CumSumCPUKernel() override = default;
|
||||
CumSumCpuKernelMod() = default;
|
||||
~CumSumCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -83,12 +83,15 @@ class CumSumCPUKernel : public CPUKernel {
|
|||
};
|
||||
|
||||
MS_REG_CPU_KERNEL(CumSum, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
CumSumCPUKernel);
|
||||
CumSumCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(CumSum, KernelAttr().AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeFloat16),
|
||||
CumSumCPUKernel);
|
||||
MS_REG_CPU_KERNEL(CumSum, KernelAttr().AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32), CumSumCPUKernel);
|
||||
MS_REG_CPU_KERNEL(CumSum, KernelAttr().AddInputAttr(kNumberTypeInt8).AddOutputAttr(kNumberTypeInt8), CumSumCPUKernel);
|
||||
MS_REG_CPU_KERNEL(CumSum, KernelAttr().AddInputAttr(kNumberTypeUInt8).AddOutputAttr(kNumberTypeUInt8), CumSumCPUKernel);
|
||||
CumSumCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(CumSum, KernelAttr().AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
CumSumCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(CumSum, KernelAttr().AddInputAttr(kNumberTypeInt8).AddOutputAttr(kNumberTypeInt8),
|
||||
CumSumCpuKernelMod);
|
||||
MS_REG_CPU_KERNEL(CumSum, KernelAttr().AddInputAttr(kNumberTypeUInt8).AddOutputAttr(kNumberTypeUInt8),
|
||||
CumSumCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_CUMSUM_CPU_KERNEL_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -30,7 +30,7 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
CustomAOTCpuKernel::~CustomAOTCpuKernel() {
|
||||
CustomAOTCpuKernelMod::~CustomAOTCpuKernelMod() {
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
if (handle_ != nullptr) {
|
||||
dlclose(handle_);
|
||||
|
@ -38,7 +38,7 @@ CustomAOTCpuKernel::~CustomAOTCpuKernel() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void CustomAOTCpuKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void CustomAOTCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
const auto &exec_info = AnfAlgo::GetNodeAttr<std::string>(kernel_node, "func_name");
|
||||
if (auto pos = exec_info.find(":"); pos != std::string::npos) {
|
||||
auto path = exec_info.substr(0, pos);
|
||||
|
@ -92,8 +92,8 @@ void CustomAOTCpuKernel::InitKernel(const CNodePtr &kernel_node) {
|
|||
[](auto &str) { return str.c_str(); });
|
||||
}
|
||||
|
||||
bool CustomAOTCpuKernel::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool CustomAOTCpuKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
std::vector<void *> params;
|
||||
|
||||
for (size_t i = 0; i < num_input_; i++) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,10 +24,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
|
||||
class CustomAOTCpuKernel : public CPUKernel {
|
||||
class CustomAOTCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
CustomAOTCpuKernel() : num_input_(0), num_output_(0), handle_(nullptr), aot_func_(nullptr) {}
|
||||
~CustomAOTCpuKernel();
|
||||
CustomAOTCpuKernelMod() : num_input_(0), num_output_(0), handle_(nullptr), aot_func_(nullptr) {}
|
||||
~CustomAOTCpuKernelMod();
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,17 +25,17 @@ constexpr size_t kDebugInputsNum = 1;
|
|||
constexpr size_t kDebugOutputsNum = 1;
|
||||
} // namespace
|
||||
|
||||
void DebugCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void DebugCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
}
|
||||
|
||||
bool DebugCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool DebugCpuKernelMod::Launch(const std::vector<kernel::AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kDebugInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kDebugOutputsNum, kernel_name_);
|
||||
const auto *val = reinterpret_cast<int *>(inputs[0]->addr);
|
||||
MS_LOG(DEBUG) << " launch DebugCountCPUKernel";
|
||||
MS_LOG(DEBUG) << " launch DebugCpuKernelMod";
|
||||
|
||||
auto output = reinterpret_cast<int *>(outputs[0]->addr);
|
||||
size_t elem_num = inputs[0]->size / sizeof(int);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class DebugCPUKernel : public CPUKernel {
|
||||
class DebugCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
DebugCPUKernel() = default;
|
||||
~DebugCPUKernel() override = default;
|
||||
DebugCpuKernelMod() = default;
|
||||
~DebugCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -36,7 +36,8 @@ class DebugCPUKernel : public CPUKernel {
|
|||
const std::vector<AddressPtr> &outputs) override;
|
||||
};
|
||||
|
||||
MS_REG_CPU_KERNEL(Debug, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeInt32), DebugCPUKernel);
|
||||
MS_REG_CPU_KERNEL(Debug, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeInt32),
|
||||
DebugCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,7 +24,7 @@ constexpr size_t kDepthToSpaceOutputsNum = 1;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void DepthToSpaceCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void DepthToSpaceCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
input_shape_ = AnfAlgo::GetInputDeviceShape(kernel_node, 0);
|
||||
|
@ -33,9 +33,9 @@ void DepthToSpaceCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool DepthToSpaceCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> & /* workspace */,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool DepthToSpaceCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> & /* workspace */,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kDepthToSpaceInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kDepthToSpaceOutputsNum, kernel_name_);
|
||||
auto input_addr = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class DepthToSpaceCPUKernel : public CPUKernel {
|
||||
class DepthToSpaceCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
DepthToSpaceCPUKernel() = default;
|
||||
~DepthToSpaceCPUKernel() override = default;
|
||||
DepthToSpaceCpuKernelMod() = default;
|
||||
~DepthToSpaceCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
|
@ -42,43 +42,43 @@ class DepthToSpaceCPUKernel : public CPUKernel {
|
|||
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
DepthToSpace, KernelAttr().SetAllSameAttr(true).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
DepthToSpaceCPUKernel, float);
|
||||
DepthToSpaceCpuKernelMod, float);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
DepthToSpace, KernelAttr().SetAllSameAttr(true).AddInputAttr(kNumberTypeFloat16).AddOutputAttr(kNumberTypeFloat16),
|
||||
DepthToSpaceCPUKernel, float16);
|
||||
DepthToSpaceCpuKernelMod, float16);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(DepthToSpace,
|
||||
KernelAttr().SetAllSameAttr(true).AddInputAttr(kNumberTypeInt8).AddOutputAttr(kNumberTypeInt8),
|
||||
DepthToSpaceCPUKernel, int8_t);
|
||||
DepthToSpaceCpuKernelMod, int8_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(DepthToSpace,
|
||||
KernelAttr().SetAllSameAttr(true).AddInputAttr(kNumberTypeInt16).AddOutputAttr(kNumberTypeInt16),
|
||||
DepthToSpaceCPUKernel, int16_t);
|
||||
DepthToSpaceCpuKernelMod, int16_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(DepthToSpace,
|
||||
KernelAttr().SetAllSameAttr(true).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
DepthToSpaceCPUKernel, int);
|
||||
DepthToSpaceCpuKernelMod, int);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(DepthToSpace,
|
||||
KernelAttr().SetAllSameAttr(true).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
DepthToSpaceCPUKernel, int64_t);
|
||||
DepthToSpaceCpuKernelMod, int64_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(DepthToSpace,
|
||||
KernelAttr().SetAllSameAttr(true).AddInputAttr(kNumberTypeUInt8).AddOutputAttr(kNumberTypeUInt8),
|
||||
DepthToSpaceCPUKernel, uint8_t);
|
||||
DepthToSpaceCpuKernelMod, uint8_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(DepthToSpace,
|
||||
KernelAttr().SetAllSameAttr(true).AddInputAttr(kNumberTypeUInt16).AddOutputAttr(kNumberTypeUInt16),
|
||||
DepthToSpaceCPUKernel, uint16_t);
|
||||
DepthToSpaceCpuKernelMod, uint16_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(DepthToSpace,
|
||||
KernelAttr().SetAllSameAttr(true).AddInputAttr(kNumberTypeUInt32).AddOutputAttr(kNumberTypeUInt32),
|
||||
DepthToSpaceCPUKernel, uint32_t);
|
||||
DepthToSpaceCpuKernelMod, uint32_t);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(DepthToSpace,
|
||||
KernelAttr().SetAllSameAttr(true).AddInputAttr(kNumberTypeUInt64).AddOutputAttr(kNumberTypeUInt64),
|
||||
DepthToSpaceCPUKernel, uint64_t);
|
||||
DepthToSpaceCpuKernelMod, uint64_t);
|
||||
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,7 +28,7 @@ constexpr size_t kDropoutInputsNum = 1;
|
|||
constexpr size_t kDropoutOutputsNum = 2;
|
||||
} // namespace
|
||||
|
||||
void DropoutCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void DropoutCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
input_shape_ = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0);
|
||||
|
@ -44,8 +44,8 @@ void DropoutCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
}
|
||||
|
||||
bool DropoutCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool DropoutCpuKernelMod::Launch(const std::vector<kernel::AddressPtr> &inputs, const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kDropoutInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kDropoutOutputsNum, kernel_name_);
|
||||
if (dtype_ == kNumberTypeFloat16) {
|
||||
|
@ -61,8 +61,8 @@ bool DropoutCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs, con
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void DropoutCPUKernel::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) const {
|
||||
void DropoutCpuKernelMod::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &outputs) const {
|
||||
const auto *input_addr = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
auto *output_addr = reinterpret_cast<T *>(outputs[0]->addr);
|
||||
auto mask_addr = reinterpret_cast<T *>(outputs[1]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class DropoutCPUKernel : public CPUKernel {
|
||||
class DropoutCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
DropoutCPUKernel() = default;
|
||||
~DropoutCPUKernel() override = default;
|
||||
DropoutCpuKernelMod() = default;
|
||||
~DropoutCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -47,7 +47,7 @@ class DropoutCPUKernel : public CPUKernel {
|
|||
uint64_t tensor_size_{1};
|
||||
};
|
||||
|
||||
MS_REG_CPU_KERNEL(Dropout, KernelAttr(), DropoutCPUKernel);
|
||||
MS_REG_CPU_KERNEL(Dropout, KernelAttr(), DropoutCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_DROPOUT_CPU_KERNEL_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,7 +28,7 @@ constexpr size_t kDropoutGradInputsNum = 2;
|
|||
constexpr size_t kDropoutGradOutputsNum = 1;
|
||||
} // namespace
|
||||
|
||||
void DropoutGradCpuBwdKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void DropoutGradBwdCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
auto input_shape = AnfAlgo::GetInputDeviceShape(kernel_node, 0);
|
||||
|
@ -50,8 +50,8 @@ void DropoutGradCpuBwdKernel::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
}
|
||||
|
||||
void DropoutGradCpuBwdKernel::InitInputOutputSize(const CNodePtr &kernel_node) {
|
||||
CPUKernel::InitInputOutputSize(kernel_node);
|
||||
void DropoutGradBwdCpuKernelMod::InitInputOutputSize(const CNodePtr &kernel_node) {
|
||||
NativeCpuKernelMod::InitInputOutputSize(kernel_node);
|
||||
if (dtype_ == kNumberTypeFloat16) {
|
||||
workspace_size_list_.emplace_back(num_count_ * sizeof(float));
|
||||
workspace_size_list_.emplace_back(num_count_ * sizeof(float));
|
||||
|
@ -59,8 +59,8 @@ void DropoutGradCpuBwdKernel::InitInputOutputSize(const CNodePtr &kernel_node) {
|
|||
}
|
||||
}
|
||||
|
||||
bool DropoutGradCpuBwdKernel::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool DropoutGradBwdCpuKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kDropoutGradInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kDropoutGradOutputsNum, kernel_name_);
|
||||
if (dtype_ == kNumberTypeFloat16) {
|
||||
|
@ -77,9 +77,9 @@ bool DropoutGradCpuBwdKernel::Launch(const std::vector<AddressPtr> &inputs, cons
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void DropoutGradCpuBwdKernel::DropoutBackwardKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs, float keep_prob) {
|
||||
void DropoutGradBwdCpuKernelMod::DropoutBackwardKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs, float keep_prob) {
|
||||
auto *output = reinterpret_cast<T *>(outputs[0]->addr);
|
||||
const auto *input = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
const auto *mask = reinterpret_cast<T *>(inputs[1]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -27,10 +27,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class DropoutGradCpuBwdKernel : public CPUKernel {
|
||||
class DropoutGradBwdCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
DropoutGradCpuBwdKernel() = default;
|
||||
~DropoutGradCpuBwdKernel() override = default;
|
||||
DropoutGradBwdCpuKernelMod() = default;
|
||||
~DropoutGradBwdCpuKernelMod() override = default;
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
void InitInputOutputSize(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
|
@ -45,7 +45,7 @@ class DropoutGradCpuBwdKernel : public CPUKernel {
|
|||
TypeId dtype_{kTypeUnknown};
|
||||
};
|
||||
|
||||
MS_REG_CPU_KERNEL(DropoutGrad, KernelAttr(), DropoutGradCpuBwdKernel);
|
||||
MS_REG_CPU_KERNEL(DropoutGrad, KernelAttr(), DropoutGradBwdCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -27,7 +27,7 @@ constexpr size_t kDynamicAssignInputsNum = 2;
|
|||
constexpr size_t kDynamicAssignOutputsNum = 1;
|
||||
} // namespace
|
||||
|
||||
void DynamicAssignCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void DynamicAssignCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
node_wpt_ = kernel_node;
|
||||
|
@ -35,9 +35,9 @@ void DynamicAssignCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
|||
input_x_dtype_size_ = GetTypeByte(TypeIdToType(input_x_dtype_));
|
||||
}
|
||||
|
||||
bool DynamicAssignCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool DynamicAssignCpuKernelMod::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kDynamicAssignInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kDynamicAssignOutputsNum, kernel_name_);
|
||||
if (input_x_dtype_ == kNumberTypeInt32) {
|
||||
|
@ -57,8 +57,8 @@ bool DynamicAssignCPUKernel::Launch(const std::vector<kernel::AddressPtr> &input
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void DynamicAssignCPUKernel::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
void DynamicAssignCpuKernelMod::LaunchKernel(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
auto node = node_wpt_.lock();
|
||||
if (!node) {
|
||||
MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', node_wpt_(kernel_node) is expired. Error no: " << node;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,10 +26,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace kernel {
|
||||
class DynamicAssignCPUKernel : public CPUKernel {
|
||||
class DynamicAssignCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
DynamicAssignCPUKernel() = default;
|
||||
~DynamicAssignCPUKernel() override = default;
|
||||
DynamicAssignCpuKernelMod() = default;
|
||||
~DynamicAssignCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -49,22 +49,22 @@ class DynamicAssignCPUKernel : public CPUKernel {
|
|||
MS_REG_CPU_KERNEL(
|
||||
DynamicAssign,
|
||||
KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
|
||||
DynamicAssignCPUKernel);
|
||||
DynamicAssignCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(
|
||||
DynamicAssign,
|
||||
KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
|
||||
DynamicAssignCPUKernel);
|
||||
DynamicAssignCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(
|
||||
DynamicAssign,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
DynamicAssignCPUKernel);
|
||||
DynamicAssignCpuKernelMod);
|
||||
|
||||
MS_REG_CPU_KERNEL(
|
||||
DynamicAssign,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
DynamicAssignCPUKernel);
|
||||
DynamicAssignCpuKernelMod);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,7 +24,7 @@ constexpr size_t kDynamicShapeOutputNum = 1;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void DynamicShapeCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void DynamicShapeCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
cnode_ptr_ = kernel_node;
|
||||
|
@ -35,9 +35,9 @@ void DynamicShapeCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool DynamicShapeCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool DynamicShapeCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kDynamicShapeOutputNum, kernel_name_);
|
||||
auto node_ = cnode_ptr_.lock();
|
||||
if (node_ == nullptr) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class DynamicShapeCPUKernel : public CPUKernel {
|
||||
class DynamicShapeCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
DynamicShapeCPUKernel() = default;
|
||||
~DynamicShapeCPUKernel() override = default;
|
||||
DynamicShapeCpuKernelMod() = default;
|
||||
~DynamicShapeCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -36,16 +36,16 @@ class DynamicShapeCPUKernel : public CPUKernel {
|
|||
const std::vector<AddressPtr> &outputs) override;
|
||||
};
|
||||
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCPUKernel, float);
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCPUKernel, int8_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCPUKernel, int16_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCPUKernel, int32_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCPUKernel, int64_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCPUKernel, uint8_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCPUKernel, uint16_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCPUKernel, uint32_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCPUKernel, uint64_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCPUKernel, bool)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCpuKernelMod, int8_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCpuKernelMod, int16_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCpuKernelMod, int32_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCpuKernelMod, int64_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCpuKernelMod, uint8_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCpuKernelMod, uint16_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCpuKernelMod, uint32_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCpuKernelMod, uint64_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicShape, KernelAttr(), DynamicShapeCpuKernelMod, bool)
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,7 +26,7 @@ constexpr size_t kDynamicStitchOutputNum = 1;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void DynamicStitchCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void DynamicStitchCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
cnode_ptr_ = kernel_node;
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,8 @@ size_t GetShapeSize(const std::vector<size_t> &shape) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void DynamicStitchCPUKernel<T>::LaunchKernel(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
void DynamicStitchCpuKernelMod<T>::LaunchKernel(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kDynamicStitchOutputNum, kernel_name_);
|
||||
auto node_ = cnode_ptr_.lock();
|
||||
int first_dim_size = 0;
|
||||
|
@ -87,9 +87,9 @@ void DynamicStitchCPUKernel<T>::LaunchKernel(const std::vector<kernel::AddressPt
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool DynamicStitchCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool DynamicStitchCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
LaunchKernel(inputs, outputs);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class DynamicStitchCPUKernel : public CPUKernel {
|
||||
class DynamicStitchCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
DynamicStitchCPUKernel() = default;
|
||||
~DynamicStitchCPUKernel() override = default;
|
||||
DynamicStitchCpuKernelMod() = default;
|
||||
~DynamicStitchCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
|
||||
|
@ -41,16 +41,16 @@ class DynamicStitchCPUKernel : public CPUKernel {
|
|||
size_t input_tuple_num_{1};
|
||||
};
|
||||
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCPUKernel, float);
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCPUKernel, int8_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCPUKernel, int16_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCPUKernel, int32_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCPUKernel, int64_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCPUKernel, uint8_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCPUKernel, uint16_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCPUKernel, uint32_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCPUKernel, uint64_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCPUKernel, bool)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCpuKernelMod, int8_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCpuKernelMod, int16_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCpuKernelMod, int32_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCpuKernelMod, int64_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCpuKernelMod, uint8_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCpuKernelMod, uint16_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCpuKernelMod, uint32_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCpuKernelMod, uint64_t)
|
||||
MS_REG_CPU_KERNEL_T(DynamicStitch, KernelAttr(), DynamicStitchCpuKernelMod, bool)
|
||||
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,7 @@ constexpr size_t kColIndex = 1;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void CholeskyCPUKernel<T>::InitMatrixInfo(const std::vector<size_t> &shape, size_t *row, size_t *col) {
|
||||
void CholeskyCpuKernelMod<T>::InitMatrixInfo(const std::vector<size_t> &shape, size_t *row, size_t *col) {
|
||||
if (shape.empty()) {
|
||||
MS_LOG_EXCEPTION << kernel_name_ << "shape is invalid.";
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ void CholeskyCPUKernel<T>::InitMatrixInfo(const std::vector<size_t> &shape, size
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void CholeskyCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void CholeskyCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
dtype_ = AnfAlgo::GetInputDeviceDataType(kernel_node, 0);
|
||||
|
@ -68,8 +68,8 @@ void CholeskyCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool CholeskyCPUKernel<T>::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool CholeskyCpuKernelMod<T>::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
T *input_value = reinterpret_cast<T *>(inputs[kInputIndex]->addr);
|
||||
Map<Matrix<T, RowMajor>> input(input_value, input_row_, input_col_);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,10 +23,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class CholeskyCPUKernel : public CPUKernel {
|
||||
class CholeskyCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
CholeskyCPUKernel() = default;
|
||||
~CholeskyCPUKernel() override = default;
|
||||
CholeskyCpuKernelMod() = default;
|
||||
~CholeskyCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
|
@ -44,10 +44,10 @@ class CholeskyCPUKernel : public CPUKernel {
|
|||
};
|
||||
|
||||
MS_REG_CPU_KERNEL_T(Cholesky, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
CholeskyCPUKernel, float)
|
||||
CholeskyCpuKernelMod, float)
|
||||
|
||||
MS_REG_CPU_KERNEL_T(Cholesky, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
CholeskyCPUKernel, double)
|
||||
CholeskyCpuKernelMod, double)
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_CHOLESKY_CPU_KERNEL_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -32,7 +32,7 @@ constexpr size_t kColIndex = 1;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void CholeskySolverCPUKernel<T>::InitMatrixInfo(const std::vector<size_t> &shape, size_t *row, size_t *col) {
|
||||
void CholeskySolverCpuKernelMod<T>::InitMatrixInfo(const std::vector<size_t> &shape, size_t *row, size_t *col) {
|
||||
if (shape.empty()) {
|
||||
MS_LOG_EXCEPTION << kernel_name_ << "shape is invalid.";
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ void CholeskySolverCPUKernel<T>::InitMatrixInfo(const std::vector<size_t> &shape
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void CholeskySolverCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void CholeskySolverCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
dtype_ = AnfAlgo::GetInputDeviceDataType(kernel_node, 0);
|
||||
|
@ -67,8 +67,9 @@ void CholeskySolverCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool CholeskySolverCPUKernel<T>::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool CholeskySolverCpuKernelMod<T>::Launch(const std::vector<AddressPtr> &inputs,
|
||||
const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
T *input_value = reinterpret_cast<T *>(inputs[kInputAIndex]->addr);
|
||||
Map<Matrix<T, RowMajor>> input(input_value, input_a_row_, input_a_col_);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,10 +23,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class CholeskySolverCPUKernel : public CPUKernel {
|
||||
class CholeskySolverCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
CholeskySolverCPUKernel() = default;
|
||||
~CholeskySolverCPUKernel() override = default;
|
||||
CholeskySolverCpuKernelMod() = default;
|
||||
~CholeskySolverCpuKernelMod() override = default;
|
||||
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
|
@ -48,11 +48,11 @@ class CholeskySolverCPUKernel : public CPUKernel {
|
|||
MS_REG_CPU_KERNEL_T(
|
||||
CholeskySolver,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
CholeskySolverCPUKernel, float)
|
||||
CholeskySolverCpuKernelMod, float)
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
CholeskySolver,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
CholeskySolverCPUKernel, double)
|
||||
CholeskySolverCpuKernelMod, double)
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_CHOLESKY_CPU_KERNEL_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -41,7 +41,7 @@ template <typename T>
|
|||
using ComplexMatrixSquare = Eigen::Matrix<std::complex<T>, Dynamic, Dynamic, RowMajor>;
|
||||
|
||||
template <typename T, typename C>
|
||||
void EigCPUKernel<T, C>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void EigCpuKernelMod<T, C>::InitKernel(const CNodePtr &kernel_node) {
|
||||
dtype_ = AnfAlgo::GetInputDeviceDataType(kernel_node, 0);
|
||||
compute_eigen_vectors = AnfAlgo::GetNodeAttr<bool>(kernel_node, C_EIEH_VECTOR);
|
||||
auto A_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0);
|
||||
|
@ -53,8 +53,8 @@ void EigCPUKernel<T, C>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T, typename C>
|
||||
void EigCPUKernel<T, C>::InitInputOutputSize(const CNodePtr &kernel_node) {
|
||||
CPUKernel::InitInputOutputSize(kernel_node);
|
||||
void EigCpuKernelMod<T, C>::InitInputOutputSize(const CNodePtr &kernel_node) {
|
||||
NativeCpuKernelMod::InitInputOutputSize(kernel_node);
|
||||
(void)workspace_size_list_.template emplace_back(m_ * m_ * sizeof(T));
|
||||
}
|
||||
|
||||
|
@ -81,8 +81,8 @@ bool SolveComplexMatrix(const Map<MatrixSquare<T>> &A, Map<MatrixSquare<C>> *out
|
|||
}
|
||||
|
||||
template <typename T, typename C>
|
||||
bool EigCPUKernel<T, C>::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool EigCpuKernelMod<T, C>::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kOutputsNum, kernel_name_);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -34,10 +34,10 @@ using double_complex = std::complex<double>;
|
|||
* @tparam C , output Type, complex
|
||||
*/
|
||||
template <typename T, typename C>
|
||||
class EigCPUKernel : public CPUKernel {
|
||||
class EigCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
EigCPUKernel() = default;
|
||||
~EigCPUKernel() override = default;
|
||||
EigCpuKernelMod() = default;
|
||||
~EigCpuKernelMod() override = default;
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) override;
|
||||
|
@ -54,26 +54,26 @@ class EigCPUKernel : public CPUKernel {
|
|||
MS_REG_CPU_KERNEL_T_S(
|
||||
Eig,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeComplex64).AddOutputAttr(kNumberTypeComplex64),
|
||||
EigCPUKernel, float, float_complex);
|
||||
EigCpuKernelMod, float, float_complex);
|
||||
MS_REG_CPU_KERNEL_T_S(Eig,
|
||||
KernelAttr()
|
||||
.AddInputAttr(kNumberTypeFloat64)
|
||||
.AddOutputAttr(kNumberTypeComplex128)
|
||||
.AddOutputAttr(kNumberTypeComplex128),
|
||||
EigCPUKernel, double, double_complex);
|
||||
EigCpuKernelMod, double, double_complex);
|
||||
|
||||
MS_REG_CPU_KERNEL_T_S(Eig,
|
||||
KernelAttr()
|
||||
.AddInputAttr(kNumberTypeComplex64)
|
||||
.AddOutputAttr(kNumberTypeComplex64)
|
||||
.AddOutputAttr(kNumberTypeComplex64),
|
||||
EigCPUKernel, float_complex, float_complex);
|
||||
EigCpuKernelMod, float_complex, float_complex);
|
||||
MS_REG_CPU_KERNEL_T_S(Eig,
|
||||
KernelAttr()
|
||||
.AddInputAttr(kNumberTypeComplex128)
|
||||
.AddOutputAttr(kNumberTypeComplex128)
|
||||
.AddOutputAttr(kNumberTypeComplex128),
|
||||
EigCPUKernel, double_complex, double_complex);
|
||||
EigCpuKernelMod, double_complex, double_complex);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -41,7 +41,7 @@ template <typename T>
|
|||
using ComplexMatrixSquare = Eigen::Matrix<std::complex<T>, Dynamic, Dynamic, RowMajor>;
|
||||
|
||||
template <typename T>
|
||||
void EighCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void EighCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
dtype_ = AnfAlgo::GetInputDeviceDataType(kernel_node, 0);
|
||||
compute_eigen_vectors_ = AnfAlgo::GetNodeAttr<bool>(kernel_node, C_EIEH_VECTOR);
|
||||
lower_ = AnfAlgo::GetNodeAttr<bool>(kernel_node, LOWER);
|
||||
|
@ -54,8 +54,8 @@ void EighCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void EighCPUKernel<T>::InitInputOutputSize(const CNodePtr &kernel_node) {
|
||||
CPUKernel::InitInputOutputSize(kernel_node);
|
||||
void EighCpuKernelMod<T>::InitInputOutputSize(const CNodePtr &kernel_node) {
|
||||
NativeCpuKernelMod::InitInputOutputSize(kernel_node);
|
||||
(void)workspace_size_list_.template emplace_back(m_ * m_ * sizeof(T));
|
||||
}
|
||||
|
||||
|
@ -82,8 +82,8 @@ bool SolveComplexMatrix(const Map<MatrixSquare<T>> &A, Map<MatrixSquare<T>> *out
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool EighCPUKernel<T>::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
bool EighCpuKernelMod<T>::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kOutputsNum, kernel_name_);
|
||||
auto A_addr = reinterpret_cast<T *>(inputs[0]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,10 +33,10 @@ using double_complex = std::complex<double>;
|
|||
* @tparam C , output Type, complex
|
||||
*/
|
||||
template <typename T>
|
||||
class EighCPUKernel : public CPUKernel {
|
||||
class EighCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
EighCPUKernel() = default;
|
||||
~EighCPUKernel() override = default;
|
||||
EighCpuKernelMod() = default;
|
||||
~EighCpuKernelMod() override = default;
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) override;
|
||||
|
@ -54,24 +54,24 @@ class EighCPUKernel : public CPUKernel {
|
|||
MS_REG_CPU_KERNEL_T(
|
||||
Eigh,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
EighCPUKernel, float);
|
||||
EighCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
Eigh,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
EighCPUKernel, double);
|
||||
EighCpuKernelMod, double);
|
||||
|
||||
MS_REG_CPU_KERNEL_T(Eigh,
|
||||
KernelAttr()
|
||||
.AddInputAttr(kNumberTypeComplex64)
|
||||
.AddOutputAttr(kNumberTypeComplex64)
|
||||
.AddOutputAttr(kNumberTypeComplex64),
|
||||
EighCPUKernel, float_complex);
|
||||
EighCpuKernelMod, float_complex);
|
||||
MS_REG_CPU_KERNEL_T(Eigh,
|
||||
KernelAttr()
|
||||
.AddInputAttr(kNumberTypeComplex128)
|
||||
.AddOutputAttr(kNumberTypeComplex128)
|
||||
.AddOutputAttr(kNumberTypeComplex128),
|
||||
EighCPUKernel, double_complex);
|
||||
EighCpuKernelMod, double_complex);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,7 +36,7 @@ constexpr int kZeroThreshold = INT32_MIN;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void LUCPUKernel<T>::InitMatrixInfo(const std::vector<size_t> &shape, size_t *row, size_t *col) {
|
||||
void LUCpuKernelMod<T>::InitMatrixInfo(const std::vector<size_t> &shape, size_t *row, size_t *col) {
|
||||
constexpr size_t lu_min_dim = 1;
|
||||
if (shape.size() <= lu_min_dim) {
|
||||
MS_LOG_EXCEPTION << kernel_name_ << "shape is " << shape.size() << " which is invalid.";
|
||||
|
@ -51,7 +51,7 @@ void LUCPUKernel<T>::InitMatrixInfo(const std::vector<size_t> &shape, size_t *ro
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void LUCPUKernel<T>::InitPivotVecInfo(const std::vector<size_t> &shape, size_t *row, size_t *col) {
|
||||
void LUCpuKernelMod<T>::InitPivotVecInfo(const std::vector<size_t> &shape, size_t *row, size_t *col) {
|
||||
constexpr size_t pivot_min_dim = 1;
|
||||
if (shape.size() < pivot_min_dim) {
|
||||
MS_LOG_EXCEPTION << kernel_name_ << "pivots shape is " << shape.size() << " which is invalid.";
|
||||
|
@ -65,7 +65,7 @@ void LUCPUKernel<T>::InitPivotVecInfo(const std::vector<size_t> &shape, size_t *
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void LUCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void LUCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
dtype_ = AnfAlgo::GetInputDeviceDataType(kernel_node, 0);
|
||||
|
@ -84,22 +84,22 @@ void LUCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void LUCPUKernel<T>::InitInputOutputSize(const CNodePtr &kernel_node) {
|
||||
CPUKernel::InitInputOutputSize(kernel_node);
|
||||
void LUCpuKernelMod<T>::InitInputOutputSize(const CNodePtr &kernel_node) {
|
||||
NativeCpuKernelMod::InitInputOutputSize(kernel_node);
|
||||
size_t lu_size = lu_col_ * sizeof(T);
|
||||
(void)workspace_size_list_.emplace_back(lu_size);
|
||||
(void)workspace_size_list_.emplace_back(lu_size);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T LUCPUKernel<T>::GetPermutatedValue(const T *lu_value, const std::vector<int> &per_value, size_t i, size_t j) {
|
||||
T LUCpuKernelMod<T>::GetPermutatedValue(const T *lu_value, const std::vector<int> &per_value, size_t i, size_t j) {
|
||||
const T *pered_lu_value = lu_value + per_value[i] * lu_col_ + j;
|
||||
return *pered_lu_value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool LUCPUKernel<T>::UpdateMajorPermutation(T *lu_value, std::vector<int> *const per_value, int *pivots, size_t k,
|
||||
size_t rows) {
|
||||
bool LUCpuKernelMod<T>::UpdateMajorPermutation(T *lu_value, std::vector<int> *const per_value, int *pivots, size_t k,
|
||||
size_t rows) {
|
||||
T max_major_value = static_cast<T>(kZeroThreshold);
|
||||
int max_major_index = 0;
|
||||
for (size_t i = k; i < rows; ++i) {
|
||||
|
@ -118,16 +118,16 @@ bool LUCPUKernel<T>::UpdateMajorPermutation(T *lu_value, std::vector<int> *const
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void LUCPUKernel<T>::SetPermutatedValue(T *lu_value, const std::vector<int> &per_value, size_t i, size_t j,
|
||||
const T &value) {
|
||||
void LUCpuKernelMod<T>::SetPermutatedValue(T *lu_value, const std::vector<int> &per_value, size_t i, size_t j,
|
||||
const T &value) {
|
||||
T *per_lu_value = lu_value + per_value[i] * lu_col_ + j;
|
||||
*per_lu_value = value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool LUCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &workspace,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool LUCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &workspace,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
// input matrix of (m,n) PA = LU
|
||||
T *batch_a_value = reinterpret_cast<T *>(inputs[kLUaIndex]->addr);
|
||||
T *batch_lu_value = reinterpret_cast<T *>(outputs[kLuIndex]->addr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,10 +24,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class LUCPUKernel : public CPUKernel {
|
||||
class LUCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
LUCPUKernel() = default;
|
||||
~LUCPUKernel() override = default;
|
||||
LUCpuKernelMod() = default;
|
||||
~LUCpuKernelMod() override = default;
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) override;
|
||||
|
@ -58,14 +58,14 @@ MS_REG_CPU_KERNEL_T(LU,
|
|||
.AddOutputAttr(kNumberTypeFloat32)
|
||||
.AddOutputAttr(kNumberTypeInt32)
|
||||
.AddOutputAttr(kNumberTypeInt32),
|
||||
LUCPUKernel, float);
|
||||
LUCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(LU,
|
||||
KernelAttr()
|
||||
.AddInputAttr(kNumberTypeFloat64)
|
||||
.AddOutputAttr(kNumberTypeFloat64)
|
||||
.AddOutputAttr(kNumberTypeInt32)
|
||||
.AddOutputAttr(kNumberTypeInt32),
|
||||
LUCPUKernel, double);
|
||||
LUCpuKernelMod, double);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -35,7 +35,7 @@ constexpr size_t kColIndex = 1;
|
|||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
void LUSolverCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
void LUSolverCpuKernelMod<T>::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
dtype_ = AnfAlgo::GetInputDeviceDataType(kernel_node, 0);
|
||||
|
@ -74,9 +74,9 @@ void LUSolverCPUKernel<T>::InitKernel(const CNodePtr &kernel_node) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool LUSolverCPUKernel<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool LUSolverCpuKernelMod<T>::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
T *a_value = reinterpret_cast<T *>(inputs[kLUaIndex]->addr);
|
||||
Map<Matrix<T, RowMajor>> input_a(a_value, a_row_, a_col_);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@
|
|||
namespace mindspore {
|
||||
namespace kernel {
|
||||
template <typename T>
|
||||
class LUSolverCPUKernel : public CPUKernel {
|
||||
class LUSolverCpuKernelMod : public NativeCpuKernelMod {
|
||||
public:
|
||||
LUSolverCPUKernel() = default;
|
||||
~LUSolverCPUKernel() override = default;
|
||||
LUSolverCpuKernelMod() = default;
|
||||
~LUSolverCpuKernelMod() override = default;
|
||||
void InitKernel(const CNodePtr &kernel_node) override;
|
||||
bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
|
||||
const std::vector<AddressPtr> &outputs) override;
|
||||
|
@ -47,11 +47,11 @@ class LUSolverCPUKernel : public CPUKernel {
|
|||
MS_REG_CPU_KERNEL_T(
|
||||
LUSolver,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
|
||||
LUSolverCPUKernel, float);
|
||||
LUSolverCpuKernelMod, float);
|
||||
MS_REG_CPU_KERNEL_T(
|
||||
LUSolver,
|
||||
KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
|
||||
LUSolverCPUKernel, double);
|
||||
LUSolverCpuKernelMod, double);
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,7 @@ using Eigen::RowMajor;
|
|||
template <int Major>
|
||||
using DoubleMatrix = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Major>;
|
||||
} // namespace
|
||||
void MatmulDoubleCPUKernel::InitKernel(const CNodePtr &kernel_node) {
|
||||
void MatmulDoubleCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
||||
MS_EXCEPTION_IF_NULL(kernel_node);
|
||||
kernel_name_ = AnfAlgo::GetCNodeName(kernel_node);
|
||||
std::vector<size_t> a_shape = AnfAlgo::GetInputDeviceShape(kernel_node, 0);
|
||||
|
@ -66,9 +66,9 @@ inline void matmul_b(const MatrixBase<Derived> &A, double *b_addr, double *outpu
|
|||
}
|
||||
}
|
||||
|
||||
bool MatmulDoubleCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
bool MatmulDoubleCpuKernelMod::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||
const std::vector<kernel::AddressPtr> &,
|
||||
const std::vector<kernel::AddressPtr> &outputs) {
|
||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kMatMulInputsNum, kernel_name_);
|
||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kMatMulOutputsNum, kernel_name_);
|
||||
const auto a_addr = reinterpret_cast<double *>(inputs[0]->addr);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue