dlinear
0.0.1
Delta-complete SMT solver for linear programming
|
Public Member Functions | |
Tensor (std::initializer_list< std::int64_t > dims) | |
Construct a tensor with the given dims . | |
Tensor (std::int64_t value) | |
Construct a tensor with the given value . | |
Tensor (float value) | |
Construct a tensor with the given value . | |
Tensor (const std::vector< std::int64_t > &dims) | |
Construct a tensor with the given dims . | |
Tensor (xt::xarray< Expression > values) | |
Construct a tensor with the given values . | |
Tensor (const ::onnx::TensorProto &tensor) | |
Construct a tensor with the given tensor . | |
Tensor (const ::onnx::ValueInfoProto &value_info, const std::string &name) | |
Construct a tensor with the given value_info . | |
const xt::xarray< Expression > & | values () const |
Get read-only access to the values of the tensor. | |
std::size_t | size () const |
Get read-only access to the size of the tensor. | |
std::size_t | ndim () const |
Get read-only access to the number of dimensions of the tensor. | |
std::vector< std::int64_t > | dims () const |
Get read-only access to the dimensions of the tensor. | |
std::int64_t | dim (std::size_t i) const |
Get the dimension at index i of the tensor. | |
bool | SameDim (const Tensor &o) const |
Check whether the two tensors have the same dimension. | |
bool | Equal (const Tensor &o) const |
Compare two tensor to determine if they are equal. | |
Tensor & | Flatten (std::int64_t axis) |
Flatten the tensor along the given axis . | |
Tensor & | Transpose (const std::vector< std::int64_t > &perm={}) |
Transpose the tensor with the given perm . | |
Tensor & | Reshape (std::initializer_list< std::int64_t > dims) |
Reshape the tensor with the given dims . | |
Tensor & | Reshape (const Tensor &tensor_dim, bool allow_zero) |
Reshape the tensor with the given tensor_dim . | |
Tensor & | Unsqueeze (const Tensor &axes) |
Insert single-dimensional entries to the shape of an input tensor. | |
Tensor & | Abs () |
Apply the Abs function to the tensor. | |
Tensor & | Elementwise (const std::function< Expression(Expression)> &f) |
Apply the f function to each element of the tensor. | |
Tensor & | Slice (const std::vector< std::int64_t > &starts, const std::vector< std::int64_t > &ends, const std::vector< std::int64_t > &axes={}, const std::vector< std::int64_t > &steps={}) |
Slice the tensor with the given starts , ends , axes , and steps . | |
Tensor & | Slice (const Tensor &starts, const Tensor &ends, const Tensor &axes={}, const Tensor &steps={}) |
Slice the tensor with the given starts , ends , axes , and steps . | |
Tensor | Concat (const Tensor &rhs, std::int64_t axis) |
Concatenate the tensor with the given rhs along the given axis . | |
Tensor | Concat (const std::vector< Tensor > &rhs, std::int64_t axis) |
Concatenate the tensors with the given rhs along the given axis . | |
Tensor | Gather (const Tensor &indices, std::int64_t axis) |
Gather the tensor with the given indices along the given axis . | |
Tensor | MatMul (const Tensor &tensor) const |
Matrix multiplication of two tensors. | |
Tensor | Convolution (const Tensor &w, const std::vector< std::int64_t > &dilations, std::int64_t group, const std::vector< std::int64_t > &kernel_shape, const std::vector< std::int64_t > &pads, const std::vector< std::int64_t > &strides) const |
Convolution of two tensors. | |
xt::xarray< Expression > | Convolution (const ImageView &image, const KernelView &kernel, const std::vector< std::size_t > &new_shape, const std::vector< std::int64_t > &dilations, std::int64_t group, const std::vector< std::int64_t > &pads, const std::vector< std::int64_t > &strides) const |
Convolution of two tensors. | |
Tensor | Pad (const std::vector< std::int64_t > &pads) const |
Pad the tensor with the given pads . | |
Private Member Functions | |
std::size_t | ComputeOffset (std::initializer_list< std::int64_t > dims) const |
Given a set of indices dims , compute the offset of the tensor. | |
std::size_t | ComputeOffset (const std::int64_t *dims, std::size_t size) const |
Given a set of indices dims , compute the offset of the tensor. | |
Private Attributes | |
xt::xarray< Expression > | values_ |
Internal storage of the values of the tensor. | |
dlinear::onnx::Tensor::Tensor | ( | std::initializer_list< std::int64_t > | dims | ) |
Construct a tensor with the given dims
.
dims | dimensions of the tensor |
Definition at line 56 of file Tensor.cpp.
|
explicit |
Construct a tensor with the given value
.
value | single value of the tensor |
Definition at line 58 of file Tensor.cpp.
|
explicit |
Construct a tensor with the given value
.
value | single value of the tensor |
Definition at line 60 of file Tensor.cpp.
|
explicit |
Construct a tensor with the given dims
.
dims | dimensions of the tensor |
Definition at line 62 of file Tensor.cpp.
|
explicit |
Construct a tensor with the given values
.
values | xarray of expressions |
Definition at line 64 of file Tensor.cpp.
|
explicit |
Construct a tensor with the given tensor
.
tensor | tensor proto from the ONNX model |
Definition at line 72 of file Tensor.cpp.
|
explicit |
Construct a tensor with the given value_info
.
value_info | value info proto from the ONNX model |
name | prefix name to give to the variables in the tensor |
Definition at line 66 of file Tensor.cpp.
Tensor & dlinear::onnx::Tensor::Abs | ( | ) |
Apply the Abs function to the tensor.
Definition at line 216 of file Tensor.cpp.
|
nodiscardprivate |
Given a set of indices dims
, compute the offset of the tensor.
dims | set of indices |
size | size of the set of indices |
Definition at line 603 of file Tensor.cpp.
|
nodiscardprivate |
Given a set of indices dims
, compute the offset of the tensor.
dims | set of indices |
Definition at line 599 of file Tensor.cpp.
Concatenate the tensors with the given rhs
along the given axis
.
rhs | other tensors to concatenate with |
axis | Which axis to concat on. A negative value means counting dimensions from the back Accepted range is \([-r, r-1]\) where \(r = \text{rank(inputs)}\) |
Definition at line 258 of file Tensor.cpp.
Concatenate the tensor with the given rhs
along the given axis
.
rhs | other tensor to concatenate with |
axis | Which axis to concat on. A negative value means counting dimensions from the back Accepted range is \([-r, r-1]\) where \(r = \text{rank(inputs)}\) |
Definition at line 254 of file Tensor.cpp.
|
nodiscard |
Convolution of two tensors.
image | input tensor |
kernel | convolution kernel |
new_shape | shape of the output tensor |
dilations | dilation value along each spatial axis of the filter |
group | number of groups input channels and output channels are divided into |
pads | padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. pads format should be as follow \([x1_{begin}, x2_{begin} \dots x1_{end}, x2_{end} \dots]\), where \(xi_{begin}\) is the number of pixels added at the beginning of axis \(i\) and \(xi_{end}\) is the number of pixels added at the end of axis \(i\). |
strides | stride along each spatial axis |
Definition at line 352 of file Tensor.cpp.
|
nodiscard |
Convolution of two tensors.
w | convolution kernel with shape \([M, C, k_1, k_2, \dots, k_n]\) |
dilations | dilation value along each spatial axis of the filter |
group | number of groups input channels and output channels are divided into |
kernel_shape | shape of the convolution kernel. If not present, should be inferred from input W |
pads | padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. pads format should be as follow \([x1_{begin}, x2_{begin} \dots x1_{end}, x2_{end} \dots]\), where \(xi_{begin}\) is the number of pixels added at the beginning of axis \(i\) and \(xi_{end}\) is the number of pixels added at the end of axis \(i\). |
strides | stride along each spatial axis |
Definition at line 302 of file Tensor.cpp.
|
nodiscard |
Get the dimension at index i
of the tensor.
If the dimension requested is not present, it will return 1.
i | index of the dimension |
i
is out of bounds Definition at line 142 of file Tensor.cpp.
|
nodiscard |
Get read-only access to the dimensions of the tensor.
Definition at line 140 of file Tensor.cpp.
Tensor & dlinear::onnx::Tensor::Elementwise | ( | const std::function< Expression(Expression)> & | f | ) |
Apply the f
function to each element of the tensor.
f | function to apply to each element |
Definition at line 221 of file Tensor.cpp.
|
nodiscard |
Compare two tensor to determine if they are equal.
o | other object to compare against |
Definition at line 152 of file Tensor.cpp.
Tensor & dlinear::onnx::Tensor::Flatten | ( | std::int64_t | axis | ) |
Flatten the tensor along the given axis
.
axis | axis to flatten along |
Definition at line 160 of file Tensor.cpp.
Gather the tensor with the given indices
along the given axis
.
indices | tensor of any rank \(q\). All index values are expected to be within bounds \([-s, s-1]\) along axis of size \(s\). It is an error if any of the index values are out of bounds |
axis | which axis to concat on. A negative value means counting dimensions from the back Accepted range is \([-r, r-1]\) where \(r = \text{rank(inputs)}\) |
Definition at line 265 of file Tensor.cpp.
Matrix multiplication of two tensors.
tensor | tensor to multiply with |
Definition at line 436 of file Tensor.cpp.
|
inlinenodiscard |
|
nodiscard |
Pad the tensor with the given pads
.
pads | padding for the beginning and ending along each spatial axis |
Definition at line 412 of file Tensor.cpp.
Reshape the tensor with the given tensor_dim
.
tensor_dim | tensor containing the dimensions to reshape the tensor |
allow_zero | whether to allow zero in the dimensions |
Definition at line 185 of file Tensor.cpp.
Tensor & dlinear::onnx::Tensor::Reshape | ( | std::initializer_list< std::int64_t > | dims | ) |
Reshape the tensor with the given dims
.
dims | dimensions to reshape the tensor |
Definition at line 181 of file Tensor.cpp.
|
nodiscard |
Check whether the two tensors have the same dimension.
o | tensor to compare with |
Definition at line 147 of file Tensor.cpp.
|
inlinenodiscard |
Tensor & dlinear::onnx::Tensor::Slice | ( | const std::vector< std::int64_t > & | starts, |
const std::vector< std::int64_t > & | ends, | ||
const std::vector< std::int64_t > & | axes = {}, | ||
const std::vector< std::int64_t > & | steps = {} ) |
Slice the tensor with the given starts
, ends
, axes
, and steps
.
starts | 1-D tensor of starting indices of corresponding axis in axes |
ends | 1-D tensor of ending indices (exclusive) of corresponding axis in axes |
axes | 1-D tensor of axes that starts and ends apply to. Negative value means counting dimensions from the back. Accepted range is \([-r, r-1]\) where \(r = \text{rank(input)}\). Behavior is undefined if an axis is repeated. |
steps | 1-D tensor of slice step of corresponding axis in axes . Negative value means slicing backward. Cannot be 0. Defaults to 1. |
Definition at line 230 of file Tensor.cpp.
Tensor & dlinear::onnx::Tensor::Slice | ( | const Tensor & | starts, |
const Tensor & | ends, | ||
const Tensor & | axes = {}, | ||
const Tensor & | steps = {} ) |
Slice the tensor with the given starts
, ends
, axes
, and steps
.
starts | 1-D tensor of starting indices of corresponding axis in axes |
ends | 1-D tensor of ending indices (exclusive) of corresponding axis in axes |
axes | 1-D tensor of axes that starts and ends apply to. Negative value means counting dimensions from the back. Accepted range is \([-r, r-1]\) where \(r = \text{rank(input)}\). Behavior is undefined if an axis is repeated |
steps | 1-D tensor of slice step of corresponding axis in axes . Negative value means slicing backward. Cannot be 0. Defaults to 1 |
Definition at line 226 of file Tensor.cpp.
Tensor & dlinear::onnx::Tensor::Transpose | ( | const std::vector< std::int64_t > & | perm = {} | ) |
Transpose the tensor with the given perm
.
perm | permutation of the dimensions |
Definition at line 211 of file Tensor.cpp.
Insert single-dimensional entries to the shape of an input tensor.
axes | axes along which the tensor will be unsqueezed |
Definition at line 171 of file Tensor.cpp.
|
inlinenodiscard |