62 const int64_t&
size = 0);
78 TensorList(
const std::initializer_list<Tensor>& tensors,
83 template <
class InputIterator>
178 template <
class InputIterator>
180 int64_t
size = std::distance(first, last);
183 "Empty input tensors cannot initialize a TensorList.");
192 std::next(first), last, first->GetShape(),
199 dtype_ = first->GetDtype();
200 bool dtype_consistent = std::accumulate(
201 std::next(first), last,
true,
202 [&](
bool same_type,
const Tensor& tensor) {
203 return same_type && (dtype_ == tensor.
GetDtype());
205 if (!dtype_consistent) {
207 "Inconsistent tensor dtypes in tensors are not supported " 217 for (
auto iter = first; iter != last; ++iter, ++i) {
228 int64_t new_dim_size = 1);
Dtype GetDtype() const
Definition: Tensor.h:742
int64_t GetReservedSize() const
Definition: TensorList.h:172
Device GetDevice() const
Definition: TensorList.h:166
TensorList & operator+=(const TensorList &other)
Definition: TensorList.h:150
Dtype dtype_
Definition: TensorList.h:239
SizeVector GetShape() const
Definition: TensorList.h:164
static TensorList Concatenate(const TensorList &a, const TensorList &b)
Definition: TensorList.cpp:144
int64_t GetSize() const
Definition: TensorList.h:170
Device device_
Definition: TensorList.h:240
void Extend(const TensorList &other)
Definition: TensorList.cpp:150
SizeVector shape_
Definition: TensorList.h:237
Definition: TensorList.h:49
void LogError(const char *format, const Args &... args)
Definition: Console.h:174
std::string ToString() const
Definition: TensorList.cpp:249
Tensor operator[](int64_t index) const
Definition: TensorList.cpp:190
int64_t size_
Definition: TensorList.h:252
void ConstructFromIterators(InputIterator first, InputIterator last)
Definition: TensorList.h:179
void ShallowCopyFrom(const TensorList &other)
Shallow copy.
Definition: TensorList.cpp:101
void PushBack(const Tensor &tensor)
Definition: TensorList.cpp:128
int size
Definition: FilePCD.cpp:57
Tensor internal_tensor_
The internal tensor for data storage.
Definition: TensorList.h:255
TensorList & operator=(const TensorList &other) &
Definition: TensorList.cpp:96
void Resize(int64_t n)
Definition: TensorList.cpp:114
Definition: SizeVector.h:40
void ExpandTensor(int64_t new_reserved_size)
Expand the size of the internal tensor.
Definition: TensorList.cpp:198
TensorList(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"), const int64_t &size=0)
Definition: TensorList.cpp:32
static SizeVector ExpandFrontDim(const SizeVector &shape, int64_t new_dim_size=1)
Definition: TensorList.cpp:213
void Clear()
Clear the tensor list by discarding all data and creating a empty one.
Definition: TensorList.cpp:195
int64_t reserved_size_
Definition: TensorList.h:247
void CopyFrom(const TensorList &other)
Deep copy.
Definition: TensorList.cpp:87
Definition: Open3DViewer.h:29
TensorList operator+(const TensorList &other) const
Concatenate two TensorLists.
Definition: TensorList.h:141
static TensorList FromTensor(const Tensor &tensor, bool inplace=false)
Factory constructor from a raw tensor.
Definition: TensorList.cpp:81
Tensor AsTensor() const
Return the reference of the contained valid tensors with shared memory.
Definition: TensorList.cpp:110
int64_t ReserveSize(int64_t n)
Definition: TensorList.cpp:220
SizeVector BroadcastedShape(const SizeVector &l_shape, const SizeVector &r_shape)
Returns the broadcasted shape of two shapes.
Definition: ShapeUtil.cpp:72
const Tensor & GetInternalTensor() const
Definition: TensorList.h:174
TensorList(InputIterator first, InputIterator last, const Device &device=Device("CPU:0"))
Definition: TensorList.h:84
Dtype GetDtype() const
Definition: TensorList.h:168
Dtype
Definition: Dtype.h:49
SizeVector GetShape() const
Definition: Tensor.h:722