forked from mindspore-Ecosystem/mindspore
!40765 调整plugin/cpu代码以适配Windows MSVC编译工具链
Merge pull request !40765 from iambowen1984/master
This commit is contained in:
commit
569116b7de
|
@ -211,8 +211,9 @@ class ArithmeticCpuTypeFunc : public CpuKernelFunc {
|
|||
{kXlogy, &ArithmeticCpuTypeFunc<T>::Xlogy}};
|
||||
}
|
||||
if (arithmeticMathFuncMap.find(kernel_name_) == arithmeticMathFuncMap.end()) {
|
||||
MS_LOG(EXCEPTION) << "For 'Arithmetic', it only supports operators in " << Map2Str(arithmeticMathFuncMap)
|
||||
<< ", but got " << kernel_name_ << "for " << dtype_desc << ", but got " << kernel_name_ << ".";
|
||||
MS_LOG(EXCEPTION) << "For 'Arithmetic', it only supports operators in "
|
||||
<< Map2Str<std::unordered_map, TypeComputeFunc>(arithmeticMathFuncMap) << ", but got "
|
||||
<< kernel_name_ << "for " << dtype_desc << ", but got " << kernel_name_ << ".";
|
||||
}
|
||||
compute_func_ = arithmeticMathFuncMap.at(kernel_name_);
|
||||
}
|
||||
|
|
|
@ -104,8 +104,9 @@ class ArithLogicCpuTypeFunc : public DeprecatedCpuKernelFunc {
|
|||
arithmetic_logic_func_map = {{kNotEqual, &ArithLogicCpuTypeFunc<T>::NotEqual}};
|
||||
}
|
||||
if (arithmetic_logic_func_map.find(kernel_name_) == arithmetic_logic_func_map.end()) {
|
||||
MS_LOG(EXCEPTION) << "For 'ArithmeticLogic', only supports operators in " << Map2Str(arithmetic_logic_func_map)
|
||||
<< ", but got " << kernel_name_;
|
||||
MS_LOG(EXCEPTION) << "For 'ArithmeticLogic', only supports operators in "
|
||||
<< Map2Str<std::unordered_map, TypeComputeFunc>(arithmetic_logic_func_map) << ", but got "
|
||||
<< kernel_name_;
|
||||
}
|
||||
compute_func_ = arithmetic_logic_func_map.at(kernel_name_);
|
||||
}
|
||||
|
@ -187,7 +188,8 @@ class ArithComplexLogicCpuTypeFunc : public DeprecatedCpuKernelFunc {
|
|||
static const std::unordered_map<std::string, ComplexTypeComputeFunc> arithmetic_logic_func_map{
|
||||
{kEqual, &ArithComplexLogicCpuTypeFunc<T>::Equal}};
|
||||
if (arithmetic_logic_func_map.find(kernel_name_) == arithmetic_logic_func_map.end()) {
|
||||
MS_LOG(EXCEPTION) << "For 'ArithmeticLogic', only supports operators in " << Map2Str(arithmetic_logic_func_map)
|
||||
MS_LOG(EXCEPTION) << "For 'ArithmeticLogic', only supports operators in "
|
||||
<< Map2Str<std::unordered_map, ComplexTypeComputeFunc>(arithmetic_logic_func_map)
|
||||
<< ", but got " << kernel_name_;
|
||||
}
|
||||
compute_func_ = arithmetic_logic_func_map.at(kernel_name_);
|
||||
|
|
|
@ -677,8 +677,11 @@ void ArithmeticSelfCpuKernelFunc::LaunchKernel(const std::vector<AddressPtr> &in
|
|||
|
||||
const auto func_pair = arithmeticSelfFuncMap.find(kernel_name_);
|
||||
if (arithmeticSelfFuncMap.find(kernel_name_) == arithmeticSelfFuncMap.end()) {
|
||||
MS_LOG(EXCEPTION) << "For 'ArithmeticSelf', only supports operators in " << Map2Str(arithmeticSelfFuncMap)
|
||||
<< ", but got " << kernel_name_;
|
||||
MS_LOG(EXCEPTION)
|
||||
<< "For 'ArithmeticSelf', only supports operators in "
|
||||
<< Map2Str<std::unordered_map, std::function<void(ArithmeticSelfCpuKernelFunc *, const T *, T *, size_t)>>(
|
||||
arithmeticSelfFuncMap)
|
||||
<< ", but got " << kernel_name_;
|
||||
}
|
||||
func_pair->second(this, input, output, lens);
|
||||
}
|
||||
|
@ -981,7 +984,9 @@ bool ArithmeticSelfCpuKernelMod::Init(const BaseOperatorPtr &base_operator, cons
|
|||
kernel_name_ = base_operator->name();
|
||||
auto iter = arith_kernel_attr_list_map.find(kernel_name_);
|
||||
if (iter == arith_kernel_attr_list_map.end()) {
|
||||
MS_LOG(ERROR) << "For 'ArithmeticSelf', the kernel name must be in " << kernel::Map2Str(arith_kernel_attr_list_map)
|
||||
MS_LOG(ERROR) << "For 'ArithmeticSelf', the kernel name must be in "
|
||||
<< kernel::Map2Str<std::map, std::vector<std::pair<KernelAttr, ArithFuncCreator>>>(
|
||||
arith_kernel_attr_list_map)
|
||||
<< ", but got " << kernel_name_;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -133,17 +133,17 @@ void ConjugateTransposeCpuKernelMod::LaunchKernel(const std::vector<AddressPtr>
|
|||
|
||||
auto *output_addr = reinterpret_cast<T *>(outputs[0]->addr);
|
||||
transpose_param_.data_num_ = SizeToInt(inputs[0]->size / sizeof(T));
|
||||
int output_shape[SizeToInt(output_shape_.size())];
|
||||
std::vector<int> output_shape(SizeToInt(output_shape_.size()));
|
||||
for (size_t i = 0; i < output_shape_.size(); ++i) {
|
||||
output_shape[i] = SizeToInt(output_shape_[i]);
|
||||
}
|
||||
size_t data_count = (inputs[0]->size) / sizeof(T);
|
||||
if (axes_.size() > kIndex7 || data_count >= kMaxTransposeSerialSize) {
|
||||
ParallelRun(input_addr, output_addr, output_shape, data_count, &transpose_param_);
|
||||
ParallelRun(input_addr, output_addr, output_shape.data(), data_count, &transpose_param_);
|
||||
return;
|
||||
}
|
||||
bool res{static_cast<bool>(NNACL_OK)};
|
||||
res = DoTranspose(input_addr, output_addr, output_shape, &transpose_param_);
|
||||
res = DoTranspose(input_addr, output_addr, output_shape.data(), &transpose_param_);
|
||||
if (res != static_cast<bool>(NNACL_OK)) {
|
||||
MS_LOG(EXCEPTION) << "ConjugateTranspose run failed.";
|
||||
}
|
||||
|
@ -209,17 +209,17 @@ void ConjugateTransposeCpuKernelMod::LaunchComplexKernel(const std::vector<Addre
|
|||
auto task = std::bind(ConjComplexFunc<T>, input_addr, input_addr, 0, transpose_param_.data_num_);
|
||||
ParallelLaunchAutoSearch(task, transpose_param_.data_num_, this, ¶llel_search_info_);
|
||||
|
||||
int output_shape[SizeToInt(output_shape_.size())];
|
||||
std::vector<int> output_shape(SizeToInt(output_shape_.size()));
|
||||
for (size_t i = 0; i < output_shape_.size(); ++i) {
|
||||
output_shape[i] = SizeToInt(output_shape_[i]);
|
||||
}
|
||||
size_t data_count = (inputs[0]->size) / sizeof(T);
|
||||
if (axes_.size() > kIndex7 || data_count >= kMaxTransposeSerialSize) {
|
||||
ParallelRun(input_addr, output_addr, output_shape, data_count, &transpose_param_);
|
||||
ParallelRun(input_addr, output_addr, output_shape.data(), data_count, &transpose_param_);
|
||||
return;
|
||||
}
|
||||
bool res{static_cast<bool>(NNACL_OK)};
|
||||
res = DoTranspose(input_addr, output_addr, output_shape, &transpose_param_);
|
||||
res = DoTranspose(input_addr, output_addr, output_shape.data(), &transpose_param_);
|
||||
if (res != static_cast<bool>(NNACL_OK)) {
|
||||
MS_LOG(EXCEPTION) << "ConjugateTranspose run failed.";
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ bool CrossCpuKernelMod::LaunchKernel(const std::vector<kernel::AddressPtr> &inpu
|
|||
size_t output_data_stride = r_stride[LongToSize(dim_)];
|
||||
const size_t pos = 2;
|
||||
auto cross_shard = [this, &a_stride, &b_stride, &r_stride, &output_data_addr, &input1_data_addr, &input2_data_addr,
|
||||
&output_data_stride, &input1_data_stride, &input2_data_stride](size_t start, size_t end) {
|
||||
&output_data_stride, &input1_data_stride, &input2_data_stride, &pos](size_t start, size_t end) {
|
||||
const size_t input1_data_dim = input1_shape_.size();
|
||||
std::vector<int64_t> position_in_dims(input1_data_dim);
|
||||
int64_t index_in_curr_dim = SizeToLong(start);
|
||||
|
|
|
@ -626,7 +626,8 @@ bool EltWiseGradCpuKernelMod::Init(const BaseOperatorPtr &base_operator, const s
|
|||
kernel_name_ = base_operator->name();
|
||||
auto iter = kernel_attr_list_map.find(kernel_name_);
|
||||
if (iter == kernel_attr_list_map.end()) {
|
||||
MS_LOG(ERROR) << "For 'EltWiseGrad', the kernel name must be in " << kernel::Map2Str(kernel_attr_list_map)
|
||||
MS_LOG(ERROR) << "For 'EltWiseGrad', the kernel name must be in "
|
||||
<< kernel::Map2Str<std::map, std::vector<std::pair<KernelAttr, FuncCreator>>>(kernel_attr_list_map)
|
||||
<< ", but got " << kernel_name_;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,8 @@ class InplaceOpCpuTypeFunc : public CpuKernelFunc {
|
|||
{prim::kPrimInplaceSub->name(), &InplaceOpCpuTypeFunc<T>::InplaceOp<Atomic<Sub>>},
|
||||
};
|
||||
if (inplaceOpFuncMap.find(kernel_name_) == inplaceOpFuncMap.end()) {
|
||||
MS_LOG(EXCEPTION) << "For 'InplaceOp', only supports operators in " << Map2Str(inplaceOpFuncMap) << ", but got "
|
||||
MS_LOG(EXCEPTION) << "For 'InplaceOp', only supports operators in "
|
||||
<< Map2Str<std::unordered_map, TypeComputeFunc>(inplaceOpFuncMap) << ", but got "
|
||||
<< kernel_name_ << ".";
|
||||
}
|
||||
|
||||
|
@ -115,7 +116,8 @@ class InplaceOpCpuTypeFunc : public CpuKernelFunc {
|
|||
if (kernel_name_ != prim::kPrimInplaceUpdate->name() && (indices_set.size() != indices_.size())) {
|
||||
if (inplaceOpFuncMap.find(kernel_name_) == inplaceOpFuncMap.end()) {
|
||||
MS_LOG(EXCEPTION) << "For 'InplaceOp', atomic operations only support operators in "
|
||||
<< Map2Str(inplaceOpFuncMap) << ", but got " << kernel_name_ << ".";
|
||||
<< Map2Str<std::unordered_map, TypeComputeFunc>(inplaceOpFuncMap) << ", but got "
|
||||
<< kernel_name_ << ".";
|
||||
}
|
||||
compute_func_ = inplaceOpAtomicFuncMap.at(kernel_name_);
|
||||
} else {
|
||||
|
|
|
@ -70,7 +70,9 @@ bool EltWiseCpuKernelMod::Init(const BaseOperatorPtr &base_operator, const std::
|
|||
kernel_name_ = base_operator->name();
|
||||
auto iter = kernel_attr_map_.find(kernel_name_);
|
||||
if (iter == kernel_attr_map_.end()) {
|
||||
MS_LOG(ERROR) << "For 'EltWise Op', the kernel name must be in " << kernel::Map2Str(kernel_attr_map_)
|
||||
MS_LOG(ERROR) << "For 'EltWise Op', the kernel name must be in "
|
||||
<< kernel::Map2Str<std::map, std::vector<std::pair<KernelAttr, EltWiseCpuKernelMod::EltWiseFunc>>>(
|
||||
kernel_attr_map_)
|
||||
<< ", but got " << kernel_name_;
|
||||
}
|
||||
if (inputs.empty() || outputs.empty()) {
|
||||
|
@ -124,7 +126,9 @@ int EltWiseCpuKernelMod::Resize(const BaseOperatorPtr &base_operator, const std:
|
|||
std::vector<KernelAttr> EltWiseCpuKernelMod::GetOpSupport() {
|
||||
auto iter = kernel_attr_map_.find(kernel_name_);
|
||||
if (iter == kernel_attr_map_.end()) {
|
||||
MS_LOG(ERROR) << "For 'EltWise Op', the kernel name must be in " << kernel::Map2Str(kernel_attr_map_)
|
||||
MS_LOG(ERROR) << "For 'EltWise Op', the kernel name must be in "
|
||||
<< kernel::Map2Str<std::map, std::vector<std::pair<KernelAttr, EltWiseCpuKernelMod::EltWiseFunc>>>(
|
||||
kernel_attr_map_)
|
||||
<< ", but got " << kernel_name_;
|
||||
return std::vector<KernelAttr>{};
|
||||
}
|
||||
|
|
|
@ -100,7 +100,10 @@ bool NonMaxSuppressionWithOverlapsCpuKernelMod::Launch(const std::vector<kernel:
|
|||
}
|
||||
}
|
||||
float similarity = static_cast<float>(0.0);
|
||||
Candidate next_candidate = {.box_index = 0, .score = static_cast<float>(0.0), .suppress_begin_index = 0};
|
||||
Candidate next_candidate;
|
||||
next_candidate.box_index = 0;
|
||||
next_candidate.score = static_cast<float>(0.0);
|
||||
next_candidate.suppress_begin_index = 0;
|
||||
int32_t cnt = 0;
|
||||
while (cnt < max_output_size_ && !candidate_priority_queue.empty()) {
|
||||
next_candidate = candidate_priority_queue.top();
|
||||
|
|
|
@ -36,8 +36,8 @@ void RankCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
|||
};
|
||||
auto method = common::AnfAlgo::GetNodeAttr<std::string>(kernel_node, METHOD);
|
||||
if (kValidMethods.find(method) == kValidMethods.end()) {
|
||||
MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', the method must be in " << Map2Str(kValidMethods)
|
||||
<< ", but got " << method;
|
||||
MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', the method must be in "
|
||||
<< Map2Str<std::map, Method>(kValidMethods) << ", but got " << method;
|
||||
}
|
||||
method_ = kValidMethods.at(method);
|
||||
|
||||
|
@ -48,8 +48,8 @@ void RankCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
|
|||
};
|
||||
auto option = common::AnfAlgo::GetNodeAttr<std::string>(kernel_node, NA_OPTION);
|
||||
if (kValidOptions.find(option) == kValidOptions.end()) {
|
||||
MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', the option must be in " << Map2Str(kValidOptions)
|
||||
<< ", but got " << option;
|
||||
MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', the option must be in "
|
||||
<< Map2Str<std::map, NaOption>(kValidOptions) << ", but got " << option;
|
||||
}
|
||||
option_ = kValidOptions.at(option);
|
||||
|
||||
|
|
Loading…
Reference in New Issue