!48446 Fix the Histogram exception, that is, when the input data is null Tensor, resulting in an error Segmentation fault

Merge pull request !48446 from 刘勇琪/master
This commit is contained in:
i-robot 2023-02-08 03:36:17 +00:00 committed by Gitee
commit 8943349d2e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 3 additions and 0 deletions

View File

@ -81,6 +81,9 @@ bool HistogramCPUKernelMod::Launch(const std::vector<AddressPtr> &inputs, const
template <typename T, typename InterType>
void HistogramCPUKernelMod::LaunchKernel(const std::vector<AddressPtr> &inputs,
const std::vector<AddressPtr> &outputs) {
if (inputs[kIndex0]->size == 0) {
return;
}
auto x_data = reinterpret_cast<T *>(inputs[kIndex0]->addr);
auto y_data = reinterpret_cast<int32_t *>(outputs[kIndex0]->addr);
size_t x_num = inputs[kIndex0]->size / sizeof(T);