Speclib  0.1.2
The library for writing better CUDA libraries
sp::TensorDescriptor< Type, Rank > Struct Template Reference

A fully dynamic entity that can be converted into a proper Tensor at runtime. More...

#include <TensorDescriptor.hpp>

Public Member Functions

constexpr int getRank () const
 
template<typename NewType , int NewRank, typename std::enable_if< std::is_same< NewType, Type >()||!KnownType(), int >::type = 0, typename std::enable_if< NewRank==Rank||!KnownRank(), int >::type = 0>
 operator TensorDescriptor< NewType, NewRank > () const
 Type conversion operator between TensorDescriptor types. More...
 

Static Public Member Functions

static constexpr bool KnownType ()
 Is the type known at compile-time? More...
 
static constexpr bool KnownRank ()
 Is the rank known at compile-time? More...
 

Public Attributes

Type * data
 
cudaDataType_t type
 
std::vector< int > dims
 
std::vector< int > strides
 

Detailed Description

template<typename Type = void, int Rank = -1>
struct sp::TensorDescriptor< Type, Rank >

A fully dynamic entity that can be converted into a proper Tensor at runtime.

This is useful for implementing APIs that imperatively build a description of a tensor before passing it to the library.

This object is not TensorLike and provides no means of accessing the data. It simply stores the size, stride, data type, and base pointer of the tensor the user is describing. The expectation is that this will be fed through a runSpecialised call at some point to convert it into a proper Tensor using TensorDescriptorSpecialiser.

The template parameters may be used when some information is known at compile-time to generate smaller branch trees.

Template Parameters
TypeThe data type, if known. void if this is not known until runtime.
RankThe dimensionality of the tensor, if known. -1 if this is not known until runtime.

Member Function Documentation

◆ KnownRank()

template<typename Type = void, int Rank = -1>
static constexpr bool sp::TensorDescriptor< Type, Rank >::KnownRank ( )
staticconstexpr

Is the rank known at compile-time?

◆ KnownType()

template<typename Type = void, int Rank = -1>
static constexpr bool sp::TensorDescriptor< Type, Rank >::KnownType ( )
staticconstexpr

Is the type known at compile-time?

◆ operator TensorDescriptor< NewType, NewRank >()

template<typename Type = void, int Rank = -1>
template<typename NewType , int NewRank, typename std::enable_if< std::is_same< NewType, Type >()||!KnownType(), int >::type = 0, typename std::enable_if< NewRank==Rank||!KnownRank(), int >::type = 0>
sp::TensorDescriptor< Type, Rank >::operator TensorDescriptor< NewType, NewRank > ( ) const

Type conversion operator between TensorDescriptor types.

Permits conversions that increase specialisedness, but forbids those that discard information. Conversion from unknown-type to known-type is allowed, but not the reverse, for example.