Class AMSTensor¶
Defined in File AMSTensor.hpp
Class Documentation¶
-
class AMSTensor¶
Public Types
-
using IntDimType = long int¶
Public Functions
-
inline IntDimType elements() const¶
-
inline IntDimType element_size() const¶
-
inline AMSResourceType location() const¶
-
inline ams::ArrayRef<IntDimType> strides() const¶
-
inline ams::ArrayRef<IntDimType> shape() const¶
-
inline bool contiguous() const¶
-
AMSTensor(const AMSTensor&) = delete¶
Deleted copy assignment operator to prevent copying of tensors.
-
AMSTensor &operator=(const AMSTensor&) = delete¶
Move constructor for AMSTensor, transfers ownership of data.
- Parameters:
other – [inout] The tensor to move from. It will be left in a valid but unspecified state.
-
AMSTensor(AMSTensor &&other) noexcept¶
Move assignment operator for AMSTensor, transfers ownership of data.
- Parameters:
other – [inout] The tensor to move from. It will be left in a valid but unspecified state.
- Returns:
A reference to the updated tensor after move assignment.
-
template<typename T>
inline T *data() const¶ Retrieves a typed pointer to the underlying data.
- Template Parameters:
T – The data type to retrieve.
- Returns:
A typed pointer to the tensor’s data.
-
inline void *raw_data() const¶
-
AMSTensor transpose(IntDimType axis1 = 0, IntDimType axis2 = 1) const¶
Creates a transposed view of the tensor by swapping two specified axes.
- Parameters:
axis1 – [in] The first axis to swap in the transposition.
axis2 – [in] The second axis to swap in the transposition.
- Throws:
std::out_of_range – if any axis is out of bounds.
- Returns:
A new AMSTensor that is a transposed view of the original tensor.
Public Static Functions
-
template<typename ScalarType>
static AMSTensor create(ams::ArrayRef<IntDimType> shapes, ams::ArrayRef<IntDimType> strides, AMSResourceType location)¶ Creates a new AMSTensor and allocates the tensor memory.
- Parameters:
shapes – [in] The shape of the tensor.
strides – [in] The strides of the tensor.
dType – [in] The data type of the tensor elements.
location – [in] The memory location (e.g., CPU, GPU).
- Returns:
A new AMSTensor with allocated memory.
-
template<typename ScalarType>
static AMSTensor view(ScalarType *data, ams::ArrayRef<IntDimType> shapes, ams::ArrayRef<IntDimType> strides, AMSResourceType location)¶ Creates a view on an existing memory buffer.
- Parameters:
data – [in] Pointer to the existing data to be viewed.
shapes – [in] The shape of the view tensor.
strides – [in] The strides of the view tensor.
dType – [in] The data type of the tensor elements.
location – [in] The memory location (e.g., CPU, GPU).
- Returns:
A new AMSTensor that acts as a view of the existing data.
-
using IntDimType = long int¶