!47837 Fix IsClose coredump problem

Merge pull request !47837 from zhanzhan/isclose
This commit is contained in:
i-robot 2023-01-18 08:22:38 +00:00 committed by Gitee
commit 2795accd48
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 10 additions and 0 deletions

View File

@ -66,6 +66,11 @@ int IsCloseCpuKernelMod::Resize(const BaseOperatorPtr &base_operator, const std:
auto input_shape = LongVecToSizeVec(inputs.at(kIndex0)->GetShapeVector());
auto other_shape = LongVecToSizeVec(inputs.at(kIndex1)->GetShapeVector());
auto output_shape = LongVecToSizeVec(outputs.at(kIndex0)->GetShapeVector());
has_null_input_ = CheckNullInput(input_shape);
has_null_input_ = has_null_input_ || CheckNullInput(other_shape);
if (has_null_input_) {
return KRET_OK;
}
is_need_broadcast_ = input_shape != other_shape;
if (is_need_broadcast_) {
GetBroadCastIndex(input_shape, output_shape, &index_list1_);
@ -83,6 +88,10 @@ bool IsCloseCpuKernelMod::LaunchKernel(const std::vector<AddressPtr> &inputs, co
auto other = reinterpret_cast<T *>(inputs[kIndex1]->addr);
auto output = reinterpret_cast<bool *>(outputs[kIndex0]->addr);
if (has_null_input_) {
return true;
}
CTask task;
if (!is_need_broadcast_) {
task = [this, &input, &other, &output](size_t start, size_t end) {

View File

@ -58,6 +58,7 @@ class IsCloseCpuKernelMod : public NativeCpuKernelMod, public MatchKernelHelper<
std::vector<size_t> index_list1_{};
std::vector<size_t> index_list2_{};
bool is_need_broadcast_{false};
bool has_null_input_{false};
};
} // namespace kernel
} // namespace mindspore