Cytnx icon indicating copy to clipboard operation
Cytnx copied to clipboard

Feature Request: Add get_blocks() support for DenseUniTensor

Open Chan-Sing-Hong opened this issue 8 months ago • 0 comments

In Cytnx v1.0.0, the method get_blocks() is only available for SparseUniTensor. Attempting to use it on a DenseUniTensor results in the following error:

RuntimeError: 
# Cytnx error occur at virtual std::vector<cytnx::Tensor> cytnx::DenseUniTensor::get_blocks() const
# error: [ERROR][DenseUniTensor] cannot use get_blocks(), use get_block() instead!

For consistency, it would be helpful if DenseUniTensor also supported get_blocks() — returning a list with its single block:

E.g.

# Sparse case with N blocks
A = SparseUniTensor(...)
A.get_blocks()  # returns [A.get_block(0), A.get_block(1), ..., A.get_block(N-1)]

# Dense case with only 1 block
A = DenseUniTensor(...)
A.get_blocks()  # returns [A.get_block()]

This would allow writing generic code that works for both SparseUniTensor and DenseUniTensor.

Chan-Sing-Hong avatar Apr 14 '25 06:04 Chan-Sing-Hong