| 79 | typename StorageP = Storage<POS>, |
| 80 | typename DimDesc = DefaultDescriptor<TF::DIM>> |
| 81 | class sparse_tensor_t |
| 82 | : public detail::tensor_impl_t< |
| 83 | VAL, TF::DIM, DimDesc, detail::SparseTensorData<VAL, CRD, POS, TF>> { |
| 84 | public: |
| 85 | using sparse_tensor = bool; |
| 86 | using val_type = VAL; |
| 87 | using crd_type = CRD; |
| 88 | using pos_type = POS; |
| 89 | using Format = TF; |
| 90 | |
| 91 | static constexpr int DIM = TF::DIM; |
| 92 | static constexpr int LVL = TF::LVL; |
| 93 | |
| 94 | // |
| 95 | // Constructs a sparse tensor with given shape and contents. |
| 96 | // |
| 97 | // The storage format is defined through the template. The contents |
| 98 | // consist of a buffer for the values (primary storage), and LVL times |
| 99 | // a buffer with the coordinates and LVL times a buffer with the positions |
| 100 | // (secondary storage). The semantics of these contents depend on the |
| 101 | // used storage format. |
| 102 | // |
| 103 | // Most users should *not* use this constructor directly, since it depends |
| 104 | // on intricate knowledge of the storage formats. Instead, users should |
| 105 | // use the "make_sparse_tensor" methods that provide factory methods in |
| 106 | // terms of storage formats that are more familiar (COO, CSR, etc). |
| 107 | // |
| 108 | __MATX_INLINE__ |
| 109 | sparse_tensor_t(const typename DimDesc::shape_type (&shape)[DIM], |
| 110 | StorageV &&vals, StorageC (&&crd)[LVL], StorageP (&&pos)[LVL]) |
| 111 | : detail::tensor_impl_t<VAL, DIM, DimDesc, |
| 112 | detail::SparseTensorData<VAL, CRD, POS, TF>>( |
| 113 | shape) { |
| 114 | values_ = std::move(vals); |
| 115 | for (int l = 0; l < LVL; l++) { |
| 116 | coordinates_[l] = std::move(crd[l]); |
| 117 | positions_[l] = std::move(pos[l]); |
| 118 | } |
| 119 | SetSparseDataImpl(); |
| 120 | } |
| 121 | |
| 122 | // Default destructor. |
| 123 | __MATX_INLINE__ ~sparse_tensor_t() = default; |
nothing calls this directly
no test coverage detected