forked from mindspore-Ecosystem/mindspore
!6538 fix malloc data failed
Merge pull request !6538 from zhaozhenlong/lite/issue/nullptr
This commit is contained in:
commit
9c4c299e6d
|
@ -38,12 +38,13 @@ int BatchNorm::UnPackAttr(const Primitive &prim, const std::vector<AnfNodePtr> &
|
|||
}
|
||||
if (this->primitive_->value.value == nullptr) {
|
||||
auto attr = new (std::nothrow) schema::FusedBatchNormT();
|
||||
attr->epsilon = GetValue<float>(prim.GetAttr("epsilon"));
|
||||
this->primitive_->value.value = attr;
|
||||
if (this->primitive_->value.value == nullptr) {
|
||||
MS_LOG(ERROR) << "new primitiveT value failed";
|
||||
if (attr == nullptr) {
|
||||
MS_LOG(ERROR) << "new FusedBatchNormT failed";
|
||||
delete this->primitive_;
|
||||
return RET_ERROR;
|
||||
}
|
||||
attr->epsilon = GetValue<float>(prim.GetAttr("epsilon"));
|
||||
this->primitive_->value.value = attr;
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
|
|
@ -1536,6 +1536,11 @@ OpParameter *PopulateL2NormParameter(const mindspore::lite::PrimitiveC *primitiv
|
|||
auto axis_vec = param->GetAxis();
|
||||
l2_norm_parameter->axis_num_ = axis_vec.size();
|
||||
l2_norm_parameter->axis_ = reinterpret_cast<int *>(malloc(axis_vec.size() * sizeof(int)));
|
||||
if (l2_norm_parameter->axis_ == nullptr) {
|
||||
MS_LOG(ERROR) << "malloc axis_ data failed";
|
||||
free(l2_norm_parameter);
|
||||
return nullptr;
|
||||
}
|
||||
for (size_t i = 0; i < axis_vec.size(); i++) {
|
||||
l2_norm_parameter->axis_[i] = axis_vec[i];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue