85 :
TensorList(tensors.begin(), tensors.end()) {}
93 :
TensorList(tensors.begin(), tensors.end()) {}
100 template <
class InputIterator>
102 int64_t
size = std::distance(begin, end);
105 "Empty input tensors cannot initialize a tensorlist.");
114 std::for_each(begin, end, [&](
const Tensor& tensor) ->
void {
117 "Tensors must have the same shape {}, but got {}.",
123 Dtype dtype = begin->GetDtype();
124 std::for_each(begin, end, [&](
const Tensor& tensor) ->
void {
127 "Tensors must have the same dtype {}, but got {}.",
133 Device device = begin->GetDevice();
134 std::for_each(begin, end, [&](
const Tensor& tensor) ->
void {
137 "Tensors must have the same device {}, but got {}.",
147 for (
auto iter = begin; iter != end; ++iter, ++i) {
148 internal_tensor_[i] = *iter;
203 void Resize(int64_t new_size);
251 "TensorList has element shape {}, but is expected to have " 260 "TensorList has device {}, but is expected to be {}.",
281 int64_t reserved_size,
282 const Tensor& internal_tensor,
static TensorList FromTensor(const Tensor &tensor, bool inplace=false)
Definition: TensorList.cpp:47
SizeVector GetElementShape() const
Definition: TensorList.h:246
bool is_resizable_
Definition: TensorList.h:330
TensorList & operator=(const TensorList &other) &=default
int64_t reserved_size_
Definition: TensorList.h:322
int64_t GetSize() const
Definition: TensorList.h:269
const Tensor & GetInternalTensor() const
Definition: TensorList.h:273
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:267
TensorList(InputIterator begin, InputIterator end)
Definition: TensorList.h:101
std::string ToString() const
Definition: Dtype.h:77
Definition: TensorList.h:58
Device GetDevice() const
Definition: Tensor.cpp:944
Definition: SizeVector.h:41
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:279
Dtype GetDtype() const
Definition: Tensor.h:943
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:265
TensorList(const std::vector< Tensor > &tensors)
Definition: TensorList.h:84
TensorList operator+(const TensorList &other) const
Concatenate two tensorlists.
Definition: TensorList.h:225
Tensor internal_tensor_
The internal tensor for data storage.
Definition: TensorList.h:325
TensorList(const std::initializer_list< Tensor > &tensors)
Definition: TensorList.h:92
bool IsResizable() const
Definition: TensorList.h:275
TensorList & operator+=(const TensorList &other)
Definition: TensorList.h:231
void ShallowCopyFrom(const TensorList &other)
Definition: TensorList.cpp:89
void AssertDevice(const Device &expected_device) const
Definition: TensorList.h:257
static const Dtype Float32
Definition: Dtype.h:42
void AssertElementShape(const SizeVector &expected_element_shape) const
Definition: TensorList.h:248
SizeVector GetShape() const
Definition: Tensor.h:923
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:306
int64_t size_
Definition: TensorList.h:311
void Extend(const TensorList &other)
Definition: TensorList.cpp:129
int64_t GetReservedSize() const
Definition: TensorList.h:271
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