19 const std::string& func_name) {
22 "TensorList::{}: TensorList is not resizable. Typically this "
23 "tensorlist is created with shared memory from a Tensor.",
30 if (shape.
size() == 0) {
35 int64_t
size = shape[0];
40 "Tensor must be contiguous for inplace tensorlist "
50 internal_tensor.
Slice(0, 0,
size) = tensor;
51 return TensorList(element_shape,
size, reserved_size, internal_tensor,
78 int64_t old_size =
size_;
112 int64_t other_size = other.
GetSize();
145 Tensor new_internal_tensor(
162 if (n > (base << 61)) {
166 for (
int i = 63; i >= 0; --i) {
168 if (((base << i) & n) > 0) {
169 if (n == (base << i)) {
172 return (base << (i + 1));
176 return (base << (i + 2));
187 "TensorList[size: {}, element_shape: {}, dtype: {}, device: {}]",
filament::Texture::InternalFormat format
#define AssertTensorDevice(tensor,...)
#define AssertTensorDtype(tensor,...)
#define AssertTensorShape(tensor,...)
std::string ToString() const
Returns string representation of device, e.g. "CPU:0", "CUDA:0".
std::string ToString() const
std::string ToString() const
Tensor AsTensor() const
Return the reference of the contained valid tensors with shared memory.
TensorList()
Useful to support operator[] in a map.
void CopyFrom(const TensorList &other)
static TensorList Concatenate(const TensorList &a, const TensorList &b)
std::string ToString() const
SizeVector GetElementShape() const
static TensorList FromTensor(const Tensor &tensor, bool inplace=false)
Tensor internal_tensor_
The internal tensor for data storage.
void Extend(const TensorList &other)
void Resize(int64_t new_size)
SizeVector element_shape_
The shape for each element tensor in the tensorlist.
void ResizeWithExpand(int64_t new_size)
void PushBack(const Tensor &tensor)
Tensor operator[](int64_t index) const
static int64_t ComputeReserveSize(int64_t size)
bool IsContiguous() const
Device GetDevice() const override
Tensor Clone() const
Copy Tensor to the same device.
static Tensor Empty(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor with uninitialized values.
SizeVector GetShape() const
void Fill(S v)
Fill the whole Tensor with a scalar value, the scalar will be casted to the Tensor's Dtype.
Tensor Slice(int64_t dim, int64_t start, int64_t stop, int64_t step=1) const
SizeVector Concat(const SizeVector &l_shape, const SizeVector &r_shape)
Concatenate two shapes.
int64_t WrapDim(int64_t dim, int64_t max_dim, bool inclusive)
Wrap around negative dim.
static void AssertIsResizable(const TensorList &tensorlist, const std::string &func_name)
Asserts that the tensor list is resizable.
Generic file read and write utility for python interface.