@@ -730,23 +730,23 @@ Status ReadTensor(const Message& message, std::shared_ptr<Tensor>* out) {
730730namespace {
731731
732732Status ReadSparseCOOIndex (const flatbuf::SparseTensor* sparse_tensor, int64_t ndim,
733- int64_t length , io::RandomAccessFile* file,
733+ int64_t non_zero_length , io::RandomAccessFile* file,
734734 std::shared_ptr<SparseIndex>* out) {
735735 auto * sparse_index = sparse_tensor->sparseIndex_as_SparseTensorIndexCOO ();
736736 auto * indices_buffer = sparse_index->indicesBuffer ();
737737 std::shared_ptr<Buffer> indices_data;
738738 RETURN_NOT_OK (
739739 file->ReadAt (indices_buffer->offset (), indices_buffer->length (), &indices_data));
740- std::vector<int64_t > shape ({length , ndim});
740+ std::vector<int64_t > shape ({non_zero_length , ndim});
741741 const int64_t elsize = sizeof (int64_t );
742- std::vector<int64_t > strides ({elsize, elsize * length });
742+ std::vector<int64_t > strides ({elsize, elsize * non_zero_length });
743743 *out = std::make_shared<SparseCOOIndex>(
744744 std::make_shared<SparseCOOIndex::CoordsTensor>(indices_data, shape, strides));
745745 return Status::OK ();
746746}
747747
748748Status ReadSparseCSRIndex (const flatbuf::SparseTensor* sparse_tensor, int64_t ndim,
749- int64_t length , io::RandomAccessFile* file,
749+ int64_t non_zero_length , io::RandomAccessFile* file,
750750 std::shared_ptr<SparseIndex>* out) {
751751 auto * sparse_index = sparse_tensor->sparseIndex_as_SparseMatrixIndexCSR ();
752752
@@ -761,7 +761,7 @@ Status ReadSparseCSRIndex(const flatbuf::SparseTensor* sparse_tensor, int64_t nd
761761 file->ReadAt (indices_buffer->offset (), indices_buffer->length (), &indices_data));
762762
763763 std::vector<int64_t > indptr_shape ({ndim + 1 });
764- std::vector<int64_t > indices_shape ({length });
764+ std::vector<int64_t > indices_shape ({non_zero_length });
765765 *out = std::make_shared<SparseCSRIndex>(
766766 std::make_shared<SparseCSRIndex::IndexTensor>(indptr_data, indptr_shape),
767767 std::make_shared<SparseCSRIndex::IndexTensor>(indices_data, indices_shape));
@@ -771,7 +771,7 @@ Status ReadSparseCSRIndex(const flatbuf::SparseTensor* sparse_tensor, int64_t nd
771771Status MakeSparseTensorWithSparseCOOIndex (
772772 const std::shared_ptr<DataType>& type, const std::vector<int64_t >& shape,
773773 const std::vector<std::string>& dim_names,
774- const std::shared_ptr<SparseCOOIndex>& sparse_index, int64_t length ,
774+ const std::shared_ptr<SparseCOOIndex>& sparse_index, int64_t non_zero_length ,
775775 const std::shared_ptr<Buffer>& data, std::shared_ptr<SparseTensorBase>* out) {
776776 auto * sparse_tensor =
777777 new SparseTensor<SparseCOOIndex>(sparse_index, type, data, shape, dim_names);
@@ -782,7 +782,7 @@ Status MakeSparseTensorWithSparseCOOIndex(
782782Status MakeSparseTensorWithSparseCSRIndex (
783783 const std::shared_ptr<DataType>& type, const std::vector<int64_t >& shape,
784784 const std::vector<std::string>& dim_names,
785- const std::shared_ptr<SparseCSRIndex>& sparse_index, int64_t length ,
785+ const std::shared_ptr<SparseCSRIndex>& sparse_index, int64_t non_zero_length ,
786786 const std::shared_ptr<Buffer>& data, std::shared_ptr<SparseTensorBase>* out) {
787787 auto * sparse_tensor =
788788 new SparseTensor<SparseCSRIndex>(sparse_index, type, data, shape, dim_names);
@@ -797,11 +797,11 @@ Status ReadSparseTensor(const Buffer& metadata, io::RandomAccessFile* file,
797797 std::shared_ptr<DataType> type;
798798 std::vector<int64_t > shape;
799799 std::vector<std::string> dim_names;
800- int64_t length ;
800+ int64_t non_zero_length ;
801801 SparseTensorFormat::type sparse_tensor_format_id;
802802
803803 RETURN_NOT_OK (internal::GetSparseTensorMetadata (metadata, &type, &shape, &dim_names,
804- &length , &sparse_tensor_format_id));
804+ &non_zero_length , &sparse_tensor_format_id));
805805
806806 auto message = flatbuf::GetMessage (metadata.data ());
807807 auto sparse_tensor = reinterpret_cast <const flatbuf::SparseTensor*>(message->header ());
@@ -817,17 +817,17 @@ Status ReadSparseTensor(const Buffer& metadata, io::RandomAccessFile* file,
817817 switch (sparse_tensor_format_id) {
818818 case SparseTensorFormat::COO:
819819 RETURN_NOT_OK (
820- ReadSparseCOOIndex (sparse_tensor, shape.size (), length , file, &sparse_index));
820+ ReadSparseCOOIndex (sparse_tensor, shape.size (), non_zero_length , file, &sparse_index));
821821 return MakeSparseTensorWithSparseCOOIndex (
822822 type, shape, dim_names, std::dynamic_pointer_cast<SparseCOOIndex>(sparse_index),
823- length , data, out);
823+ non_zero_length , data, out);
824824
825825 case SparseTensorFormat::CSR:
826826 RETURN_NOT_OK (
827- ReadSparseCSRIndex (sparse_tensor, shape.size (), length , file, &sparse_index));
827+ ReadSparseCSRIndex (sparse_tensor, shape.size (), non_zero_length , file, &sparse_index));
828828 return MakeSparseTensorWithSparseCSRIndex (
829829 type, shape, dim_names, std::dynamic_pointer_cast<SparseCSRIndex>(sparse_index),
830- length , data, out);
830+ non_zero_length , data, out);
831831
832832 default :
833833 return Status::Invalid (" Unsupported sparse index format" );
0 commit comments