85 :
TensorList(tensors.begin(), tensors.end()) {}
111 :
TensorList(tensors.begin(), tensors.end()) {}
118 template <
class InputIterator>
120 int64_t size = std::distance(begin, end);
123 "Empty input tensors cannot initialize a tensorlist.");
132 std::for_each(begin, end, [&](
const Tensor& tensor) ->
void {
135 "Tensors must have the same shape {}, but got {}.",
141 Dtype dtype = begin->GetDtype();
142 std::for_each(begin, end, [&](
const Tensor& tensor) ->
void {
145 "Tensors must have the same dtype {}, but got {}.",
151 Device device = begin->GetDevice();
152 std::for_each(begin, end, [&](
const Tensor& tensor) ->
void {
155 "Tensors must have the same device {}, but got {}.",
165 for (
auto iter = begin; iter != end; ++iter, ++i) {
166 internal_tensor_[i] = *iter;
221 void Resize(int64_t new_size);
269 "TensorList has element shape {}, but is expected to have " 278 "TensorList has device {}, but is expected to be {}.",
299 int64_t reserved_size,
300 const Tensor& internal_tensor,
static TensorList FromTensor(const Tensor &tensor, bool inplace=false)
Definition: TensorList.cpp:47
SizeVector GetElementShape() const
Definition: TensorList.h:264
TensorList(int64_t size, const SizeVector &element_shape, Dtype dtype, const Device &device=Device("CPU:0"))
Definition: TensorList.h:94
bool is_resizable_
Definition: TensorList.h:348
TensorList & operator=(const TensorList &other) &=default
int64_t reserved_size_
Definition: TensorList.h:340
int64_t GetSize() const
Definition: TensorList.h:287
const Tensor & GetInternalTensor() const
Definition: TensorList.h:291
void LogError(const char *format, const Args &... args)
Definition: Console.h:176
TensorList()
Useful to support operator[] in a map.
Definition: TensorList.h:61
Tensor AsTensor() const
Return the reference of the contained valid tensors with shared memory.
Definition: TensorList.cpp:95
void CopyFrom(const TensorList &other)
Definition: TensorList.cpp:81
Dtype GetDtype() const
Definition: TensorList.h:285
TensorList(InputIterator begin, InputIterator end)
Definition: TensorList.h:119
std::string ToString() const
Definition: Dtype.h:77
Definition: TensorList.h:58
Device GetDevice() const
Definition: Tensor.cpp:955
Definition: SizeVector.h:102
SizeVector Concat(const SizeVector &l_shape, const SizeVector &r_shape)
Concatenate two shapes.
Definition: ShapeUtil.cpp:218
TensorList(const SizeVector element_shape, int64_t size, int64_t reserved_size, const Tensor &internal_tensor, bool is_resizable)
Fully specified constructor.
Definition: TensorList.h:297
Dtype GetDtype() const
Definition: Tensor.h:965
int size
Definition: FilePCD.cpp:59
TensorList(const SizeVector &element_shape, Dtype dtype, const Device &device=Device("CPU:0"))
Definition: TensorList.h:69
TensorList Copy() const
Definition: TensorList.cpp:75
static TensorList Concatenate(const TensorList &a, const TensorList &b)
Definition: TensorList.cpp:156
static int64_t ComputeReserveSize(int64_t size)
Definition: TensorList.cpp:191
Device GetDevice() const
Definition: TensorList.h:283
TensorList(const std::vector< Tensor > &tensors)
Definition: TensorList.h:84
TensorList operator+(const TensorList &other) const
Concatenate two tensorlists.
Definition: TensorList.h:243
Tensor internal_tensor_
The internal tensor for data storage.
Definition: TensorList.h:343
TensorList(const std::initializer_list< Tensor > &tensors)
Definition: TensorList.h:110
bool IsResizable() const
Definition: TensorList.h:293
TensorList & operator+=(const TensorList &other)
Definition: TensorList.h:249
void ShallowCopyFrom(const TensorList &other)
Definition: TensorList.cpp:89
void AssertDevice(const Device &expected_device) const
Definition: TensorList.h:275
static const Dtype Float32
Definition: Dtype.h:42
void AssertElementShape(const SizeVector &expected_element_shape) const
Definition: TensorList.h:266
SizeVector GetShape() const
Definition: Tensor.h:945
void ResizeWithExpand(int64_t new_size)
Definition: TensorList.cpp:175
Definition: PinholeCameraIntrinsic.cpp:35
void PushBack(const Tensor &tensor)
Definition: TensorList.cpp:108
SizeVector element_shape_
The shape for each element tensor in the tensorlist.
Definition: TensorList.h:324
int64_t size_
Definition: TensorList.h:329
void Extend(const TensorList &other)
Definition: TensorList.cpp:129
int64_t GetReservedSize() const
Definition: TensorList.h:289
void Clear()
Definition: TensorList.cpp:169
std::string ToString() const
Definition: Device.h:73
std::string ToString() const
Definition: TensorList.cpp:220
Tensor operator[](int64_t index) const
Definition: TensorList.cpp:163
void Resize(int64_t new_size)
Definition: TensorList.cpp:99