Skip to content

Commit

Permalink
[fix] skip loading empty constants
Browse files Browse the repository at this point in the history
  • Loading branch information
ouonline committed Mar 19, 2024
1 parent 5309be1 commit 6b4eb13
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ppl/nn/engines/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ RetCode LoadConstants(const ir::Graph& graph, Device* device, map<edgeid_t, Runt
omit_data = (data_omitted_constants->find(eid) != data_omitted_constants->end());
}

if (!omit_data) {
if (constant_ref->second.data.GetSize() == 0) {
if (tensor_shape.CalcBytesIncludingPadding() == 0) {
omit_data = true;
} else {
LOG(ERROR) << "constant [" << edge->GetName() << "] data size is 0 but shape size is not 0.";
return RC_INVALID_VALUE;
}
}
}

RuntimeConstantInfo& constant_info = ret_pair.first->second;
auto status = GenericLoadConstant(constant_ref->second.data.GetData(), constant_ref->second.data.GetSize(),
tensor_shape, device, &constant_info, omit_data);
Expand Down

0 comments on commit 6b4eb13

Please sign in to comment.