|
Tannic
A C++ Tensor Library
|
Expression template for inserting singleton dimensions into a tensor. More...
#include <views.hpp>
Public Member Functions | |
| template<Integral... Axes> | |
| constexpr | Unsqueeze (typename Trait< Source >::Reference source, Axes... axes) |
| Construct an unsqueezed view of the source tensor. | |
| constexpr type | dtype () const |
| constexpr Shape const & | shape () const |
| constexpr Strides const & | strides () const |
| std::ptrdiff_t | offset () const |
| Tensor | forward () const |
Expression template for inserting singleton dimensions into a tensor.
| Source | The expression or tensor type being unsqueezed. |
The Unsqueeze view adds new dimensions of size 1 at specified axes. This changes only the tensor metadata (shape and strides), not the underlying storage.
Example:
|
inlineconstexpr |
Construct an unsqueezed view of the source tensor.
| Axes | Integral indices where new dimensions of size 1 should be inserted. |
| source | Reference to the source expression or tensor. |
| axes | One or more dimension indices (negative indices allowed). |
Example:
unsqueeze(X, 0) inserts a new axis before the first dimension.unsqueeze(X, -1) inserts a new axis after the last dimension.| Exception | if any normalized axis index is invalid. |
|
inlineconstexpr |
This is forwarded directly from the source expression. Unsqueezing does not alter the tensor’s dtype.
| Tensor tannic::expression::Unsqueeze< Source >::forward |
|
inline |
This is forwarded from the source tensor since unsqueezing does not change the starting position of the data.
|
inlineconstexpr |
Calculation:
Example:
|
inlineconstexpr |
Calculation: