File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -1288,10 +1288,12 @@ Graph::Graph(const Model& owning_model,
12881288
12891289 // Remove sparse_initializers from protobuf to save memory as they are converted to dense now
12901290 graph_proto_->mutable_sparse_initializer ()->Clear ();
1291+ #if GOOGLE_PROTOBUF_VERSION < 5026000
12911292 const int sparse_num_cleared = graph_proto_->sparse_initializer ().ClearedCount ();
12921293 for (int i = 0 ; i < sparse_num_cleared; ++i) {
12931294 delete graph_proto_->mutable_sparse_initializer ()->ReleaseCleared ();
12941295 }
1296+ #endif
12951297 }
12961298#endif
12971299
@@ -3646,15 +3648,16 @@ void Graph::CleanAllInitializedTensors() noexcept {
36463648#if !defined(DISABLE_SPARSE_TENSORS)
36473649 sparse_tensor_names_.clear ();
36483650#endif
3649-
36503651 // Clearing RepeatedPtrFields does not free objects' memory. The memory is retained
36513652 // and can be reused. Need to explicitly release the cleared objects and free the
36523653 // memory.
36533654 graph_proto_->mutable_initializer ()->Clear ();
3655+ #if GOOGLE_PROTOBUF_VERSION < 5026000
36543656 const int num_cleared = graph_proto_->initializer ().ClearedCount ();
36553657 for (int i = 0 ; i < num_cleared; i++) {
36563658 delete graph_proto_->mutable_initializer ()->ReleaseCleared ();
36573659 }
3660+ #endif
36583661}
36593662
36603663const ONNX_NAMESPACE::TensorProto* Graph::GetConstantInitializer (const std::string& initializer_name,
You can’t perform that action at this time.
0 commit comments