@@ -119,7 +119,7 @@ void TensorSerializer::SerializeWithChunkSize(
119
119
CAFFE_ENFORCE (typeMeta.Match <Tensor>());
120
120
const auto & tensor = *static_cast <const Tensor*>(pointer);
121
121
if (chunk_size == kNoChunking ) {
122
- chunk_size = tensor.size () + 1 ; // to account for empty tensors
122
+ chunk_size = tensor.numel () + 1 ; // to account for empty tensors
123
123
} else if (chunk_size == kDefaultChunkSize ) {
124
124
chunk_size = FLAGS_caffe2_tensor_chunk_size;
125
125
}
@@ -147,7 +147,7 @@ void TensorSerializer::SerializeWithChunkSize(
147
147
processChunk (chunkStart);
148
148
}
149
149
};
150
- if (tensor.size () > chunk_size) {
150
+ if (tensor.numel () > chunk_size) {
151
151
for (int i = 0 ; i < FLAGS_caffe2_max_tensor_serializer_threads; ++i) {
152
152
futures.emplace_back (std::async (std::launch::async, task));
153
153
}
@@ -158,11 +158,11 @@ void TensorSerializer::SerializeWithChunkSize(
158
158
// Serialize whole vector. If vector is empty, it's shape still needs to be
159
159
// serialized in empty proto
160
160
for (size_t chunkBegin = 0 ;
161
- chunkBegin < std::max (tensor.size (), static_cast <int64_t >(1 ));
161
+ chunkBegin < std::max (tensor.numel (), static_cast <int64_t >(1 ));
162
162
chunkBegin += chunk_size) {
163
163
VLOG (2 ) << " Starting a chunk at " << chunkBegin;
164
164
#ifndef __ANDROID__
165
- if (tensor.size () > chunk_size) {
165
+ if (tensor.numel () > chunk_size) {
166
166
chunkQueue.Push (chunkBegin);
167
167
} else {
168
168
// Sync mode for small tensors
@@ -189,13 +189,13 @@ void TensorSerializer::Serialize(
189
189
size_t chunkBegin,
190
190
int32_t chunkSize) {
191
191
CAFFE_ENFORCE (
192
- chunkBegin <= input.size (),
192
+ chunkBegin <= input.numel (),
193
193
" Chunk begin is out of tensor: " ,
194
194
chunkBegin,
195
195
' ' ,
196
- input.size ());
197
- if (chunkBegin + chunkSize > input.size ()) {
198
- chunkSize = input.size () - chunkBegin;
196
+ input.numel ());
197
+ if (chunkBegin + chunkSize > input.numel ()) {
198
+ chunkSize = input.numel () - chunkBegin;
199
199
}
200
200
201
201
if (chunkSize != 0 ) {
@@ -408,19 +408,19 @@ void TensorDeserializer::Deserialize(const TensorProto& proto, Tensor* tensor) {
408
408
tensor->Resize (dims);
409
409
410
410
int64_t chunkBegin = 0 ;
411
- auto chunkEnd = tensor->size ();
411
+ auto chunkEnd = tensor->numel ();
412
412
if (proto.has_segment ()) {
413
413
chunkBegin = proto.segment ().begin ();
414
414
chunkEnd = proto.segment ().end ();
415
415
}
416
416
CAFFE_ENFORCE (
417
- 0 <= chunkBegin && chunkBegin <= chunkEnd && chunkEnd <= tensor->size (),
417
+ 0 <= chunkBegin && chunkBegin <= chunkEnd && chunkEnd <= tensor->numel (),
418
418
" Invalid chunk " ,
419
419
chunkBegin,
420
420
' ' ,
421
421
chunkEnd,
422
422
" with total tensor size " ,
423
- tensor->size ());
423
+ tensor->numel ());
424
424
auto chunkSize = chunkEnd - chunkBegin;
425
425
426
426
switch (proto.data_type ()) {
0 commit comments