From bc6cdb0cf6ca03f418943c227145f5f95c6137ea Mon Sep 17 00:00:00 2001 From: liu-yongqi-63 Date: Mon, 6 Feb 2023 16:31:02 +0800 Subject: [PATCH] Fix the Histogram exception, that is, when the input data is null Tensor, resulting in an error Segmentation fault --- .../ccsrc/plugin/device/cpu/kernel/histogram_cpu_kernel.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mindspore/ccsrc/plugin/device/cpu/kernel/histogram_cpu_kernel.cc b/mindspore/ccsrc/plugin/device/cpu/kernel/histogram_cpu_kernel.cc index 53a3fd5ab62..7157e8490da 100644 --- a/mindspore/ccsrc/plugin/device/cpu/kernel/histogram_cpu_kernel.cc +++ b/mindspore/ccsrc/plugin/device/cpu/kernel/histogram_cpu_kernel.cc @@ -81,6 +81,9 @@ bool HistogramCPUKernelMod::Launch(const std::vector &inputs, const template void HistogramCPUKernelMod::LaunchKernel(const std::vector &inputs, const std::vector &outputs) { + if (inputs[kIndex0]->size == 0) { + return; + } auto x_data = reinterpret_cast(inputs[kIndex0]->addr); auto y_data = reinterpret_cast(outputs[kIndex0]->addr); size_t x_num = inputs[kIndex0]->size / sizeof(T);