!14970 fix codex for cpu backend

From: @caojian05
Reviewed-by: @wuxuejian,@oacjiewen
Signed-off-by: @wuxuejian
This commit is contained in:
mindspore-ci-bot 2021-04-12 20:11:16 +08:00 committed by Gitee
commit eade4b2593
4 changed files with 10 additions and 8 deletions

View File

@ -15,10 +15,10 @@
*/
#include "backend/kernel_compiler/cpu/gathernd_cpu_kernel.h"
#include "runtime/device/cpu/cpu_device_address.h"
#define MAX_INT (((unsigned int)(-1)) >> 1)
namespace mindspore {
namespace kernel {
void GatherNdCPUKernel::InitKernel(const CNodePtr &kernel_node) {
input_shapes_ = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0);
indices_shapes_ = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 1);
@ -83,11 +83,14 @@ bool GatherNdCPUKernel::LaunchKernel(const std::vector<AddressPtr> &inputs, cons
size_t output_dim1 = dims_[1];
size_t indices_dim1 = dims_[2];
int num = output_dim0 * output_dim1;
size_t num = output_dim0 * output_dim1;
if (num > MAX_INT) {
MS_LOG(EXCEPTION) << "Exceed MAX_INT: " << MAX_INT << ", dim0: " << output_dim0 << ", dim1: " << output_dim1;
}
for (int write_index = 0; write_index < num; write_index++) {
int i = write_index / output_dim1 % output_dim0;
int j = write_index % output_dim1;
for (size_t write_index = 0; write_index < num; write_index++) {
size_t i = write_index / output_dim1 % output_dim0;
size_t j = write_index % output_dim1;
int read_index = 0;
for (size_t k = 0; k < indices_dim1; k++) {

View File

@ -47,7 +47,6 @@ MS_REG_CPU_KERNEL(Range, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutput
RangeCPUKernel);
MS_REG_CPU_KERNEL(Range, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
RangeCPUKernel);
} // namespace kernel
} // namespace mindspore

View File

@ -56,7 +56,7 @@ void ResizeBilinearGradCPUKernel::LaunchKernel(const std::vector<AddressPtr> &in
auto ret = memset_s(output_addr, outputs[0]->size, 0, outputs[0]->size);
if (ret != EOK) {
MS_LOG(ERROR) << "Output buffer memset failed, ret:" << ret;
MS_LOG(EXCEPTION) << "Output buffer memset failed, ret:" << ret;
}
size_t batch_size = shape_[0];

View File

@ -62,7 +62,7 @@ void ResizeNearestNeighborGradCPUKernel::LaunchKernel(const std::vector<AddressP
auto ret = memset_s(output_addr, outputs[0]->size, 0, outputs[0]->size);
if (ret != EOK) {
MS_LOG(ERROR) << "Output buffer memset failed, ret:" << ret;
MS_LOG(EXCEPTION) << "Output buffer memset failed, ret:" << ret;
}
size_t in_hw_size = in_width_ * in_height_;