66 :
TensorList(tensors.begin(), tensors.end()) {}
92 :
TensorList(tensors.begin(), tensors.end()) {}
99 template <
class InputIterator>
101 int64_t
size = std::distance(begin, end);
104 "Empty input tensors cannot initialize a tensorlist.");
113 std::for_each(begin, end, [&](
const Tensor& tensor) ->
void {
116 "Tensors must have the same shape {}, but got {}.",
117 element_shape_, tensor.GetShape());
122 Dtype dtype = begin->GetDtype();
123 std::for_each(begin, end, [&](
const Tensor& tensor) ->
void {
126 "Tensors must have the same dtype {}, but got {}.",
127 dtype.ToString(), tensor.GetDtype().ToString());
132 Device device = begin->GetDevice();
133 std::for_each(begin, end, [&](
const Tensor& tensor) ->
void {
136 "Tensors must have the same device {}, but got {}.",
137 device.ToString(), tensor.GetDevice().ToString());
146 for (
auto iter = begin; iter != end; ++iter, ++i) {
198 void Resize(int64_t new_size);
246 "TensorList has element shape {}, but is expected to have "
255 "TensorList has device {}, but is expected to be {}.",
276 int64_t reserved_size,
277 const Tensor& internal_tensor,
#define LogError(...)
Definition: Logging.h:48
std::string ToString() const
Returns string representation of device, e.g. "CPU:0", "CUDA:0".
Definition: Device.cpp:88
Definition: SizeVector.h:69
SizeVector GetShape() const
Definition: Tensor.h:1126
Device GetDevice() const override
Definition: Tensor.cpp:1403
Dtype GetDtype() const
Definition: Tensor.h:1163
Definition: TensorList.h:39
TensorList(const TensorList &other)=default
int64_t reserved_size_
Definition: TensorList.h:317
std::string ToString() const
Definition: TensorList.cpp:185
static TensorList Concatenate(const TensorList &a, const TensorList &b)
Definition: TensorList.cpp:121
TensorList operator+(const TensorList &other) const
Concatenate two tensorlists.
Definition: TensorList.h:220
TensorList()
Useful to support operator[] in a map.
Definition: TensorList.h:42
static int64_t ComputeReserveSize(int64_t size)
Definition: TensorList.cpp:156
Dtype GetDtype() const
Definition: TensorList.h:262
TensorList(int64_t size, const SizeVector &element_shape, Dtype dtype, const Device &device=Device("CPU:0"))
Definition: TensorList.h:75
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:274
TensorList(const std::vector< Tensor > &tensors)
Definition: TensorList.h:65
void Extend(const TensorList &other)
Definition: TensorList.cpp:94
SizeVector element_shape_
The shape for each element tensor in the tensorlist.
Definition: TensorList.h:301
int64_t GetReservedSize() const
Definition: TensorList.h:266
void CopyFrom(const TensorList &other)
Definition: TensorList.cpp:62
TensorList Clone() const
Definition: TensorList.cpp:56
void Resize(int64_t new_size)
Definition: TensorList.cpp:74
TensorList(InputIterator begin, InputIterator end)
Definition: TensorList.h:100
void ResizeWithExpand(int64_t new_size)
Definition: TensorList.cpp:140
TensorList(const std::initializer_list< Tensor > &tensors)
Definition: TensorList.h:91
TensorList(TensorList &&other)=default
static TensorList FromTensor(const Tensor &tensor, bool inplace=false)
Definition: TensorList.cpp:28
TensorList & operator+=(const TensorList &other)
Definition: TensorList.h:226
bool is_resizable_
Definition: TensorList.h:325
void PushBack(const Tensor &tensor)
Definition: TensorList.cpp:83
TensorList & operator=(TensorList &&other) &=default
Tensor internal_tensor_
The internal tensor for data storage.
Definition: TensorList.h:320
Device GetDevice() const
Definition: TensorList.h:260
void AssertDevice(const Device &expected_device) const
Definition: TensorList.h:252
bool IsResizable() const
Definition: TensorList.h:270
TensorList & operator=(const TensorList &other) &=default
Tensor AsTensor() const
Return the reference of the contained valid tensors with shared memory.
Definition: TensorList.cpp:70
int64_t size_
Definition: TensorList.h:306
int64_t GetSize() const
Definition: TensorList.h:264
void AssertElementShape(const SizeVector &expected_element_shape) const
Definition: TensorList.h:243
void Clear()
Definition: TensorList.cpp:134
const Tensor & GetInternalTensor() const
Definition: TensorList.h:268
SizeVector GetElementShape() const
Definition: TensorList.h:241
TensorList(const SizeVector &element_shape, Dtype dtype, const Device &device=Device("CPU:0"))
Definition: TensorList.h:50
Tensor operator[](int64_t index) const
Definition: TensorList.cpp:128
SizeVector Concat(const SizeVector &l_shape, const SizeVector &r_shape)
Concatenate two shapes.
Definition: ShapeUtil.cpp:199
const Dtype Float32
Definition: Dtype.cpp:42
Definition: PinholeCameraIntrinsic.cpp:16