Browse Source

!14540 memcpy_s function reports errors when tensor is greater than 2147483647 bit.

From: @wangyanling10
Reviewed-by: @wuxuejian,@liangchenghui
Signed-off-by: @wuxuejian
pull/14540/MERGE
mindspore-ci-bot Gitee 4 years ago
parent
commit
77f9adf9e3
2 changed files with 7 additions and 3 deletions
  1. +6
    -2
      mindspore/ccsrc/backend/kernel_compiler/cpu/slice_cpu_kernel.cc
  2. +1
    -1
      mindspore/nn/loss/loss.py

+ 6
- 2
mindspore/ccsrc/backend/kernel_compiler/cpu/slice_cpu_kernel.cc View File

@@ -191,8 +191,12 @@ void SliceCPUKernel::CopyDataToOutput(const std::vector<kernel::AddressPtr> &inp
MS_LOG(EXCEPTION) << id << " output memory out of bounds.";
}

auto ret = memcpy_s(output_addr + out_offset, out_buff_size - out_offset * sizeof(T), input_addr + in_offset,
copy_num * sizeof(T));
size_t buff_size = out_buff_size - out_offset * sizeof(T);
size_t copy_size = copy_num * sizeof(T);
if (buff_size < copy_size) {
MS_LOG(EXCEPTION) << "output buffer is not enough. memcpy failed!";
}
auto ret = memcpy_s(output_addr + out_offset, copy_size, input_addr + in_offset, copy_size);
if (ret != EOK) {
MS_LOG(EXCEPTION) << "memcpy failed. ret:" << ret;
}


+ 1
- 1
mindspore/nn/loss/loss.py View File

@@ -814,7 +814,7 @@ class BCELoss(_Loss):
ValueError: If shape of `inputs` is not the same as `labels` or `weight` (if given).

Supported Platforms:
``Ascend`` ``GPU``
``Ascend`` ``GPU`` ``CPU``

Examples:
>>> weight = Tensor(np.array([[1.0, 2.0, 3.0], [4.0, 3.3, 2.2]]), mindspore.float32)


Loading…
Cancel
Save