mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-08 00:23:03 +00:00
parent
c6cbda3257
commit
704523c2d8
1 changed files with 4 additions and 1 deletions
|
|
@ -1288,10 +1288,12 @@ Graph::Graph(const Model& owning_model,
|
|||
|
||||
// Remove sparse_initializers from protobuf to save memory as they are converted to dense now
|
||||
graph_proto_->mutable_sparse_initializer()->Clear();
|
||||
#if GOOGLE_PROTOBUF_VERSION < 5026000
|
||||
const int sparse_num_cleared = graph_proto_->sparse_initializer().ClearedCount();
|
||||
for (int i = 0; i < sparse_num_cleared; ++i) {
|
||||
delete graph_proto_->mutable_sparse_initializer()->ReleaseCleared();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -3646,15 +3648,16 @@ void Graph::CleanAllInitializedTensors() noexcept {
|
|||
#if !defined(DISABLE_SPARSE_TENSORS)
|
||||
sparse_tensor_names_.clear();
|
||||
#endif
|
||||
|
||||
// Clearing RepeatedPtrFields does not free objects' memory. The memory is retained
|
||||
// and can be reused. Need to explicitly release the cleared objects and free the
|
||||
// memory.
|
||||
graph_proto_->mutable_initializer()->Clear();
|
||||
#if GOOGLE_PROTOBUF_VERSION < 5026000
|
||||
const int num_cleared = graph_proto_->initializer().ClearedCount();
|
||||
for (int i = 0; i < num_cleared; i++) {
|
||||
delete graph_proto_->mutable_initializer()->ReleaseCleared();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
const ONNX_NAMESPACE::TensorProto* Graph::GetConstantInitializer(const std::string& initializer_name,
|
||||
|
|
|
|||
Loading…
Reference in a new issue