Base class for targets of sp::runSpecialised()
More...
#include <Specialisable.hpp>
Base class for targets of sp::runSpecialised()
The valid*()
functions define predicated which are used to prune specialisation trees. When a valid*()
function returns false
, the corresponding branch of the expansion tree instead throws RejectedSpecialisationException
.
◆ ScalarsToSpecialise
A list of special scalar values to generate optimised code paths for.
◆ UsefulTensorType
template<typename T , int Rank, typename Opts >
Given a tensor type produced by the specailiser, transform it to the type of tensor argument to actually use for this operator.
This allows you to fuse together cases that don't make any useful difference.
In contrast to validTensorTypes()
(which may be overridden to make certain specialisations not work at all), this version allows you to combine multiple branches of the tree together to point to the same kernel. Usually, this is useful for fusing lots of "slow" cases together.
The default is an identity transform.
◆ onInvalidScalarType()
static void sp::Specialisable::onInvalidScalarType |
( |
| ) |
|
|
static |
Called when a branch for which validScalarTypes()
returned false is actually executed. Must throw.
◆ onInvalidTensorRank()
static void sp::Specialisable::onInvalidTensorRank |
( |
| ) |
|
|
static |
Called when a branch for which validTensorRanks()
returned false is actually executed. Must throw.
◆ onInvalidTensorType()
static void sp::Specialisable::onInvalidTensorType |
( |
| ) |
|
|
static |
Called when a branch for which validTensorTypes()
returned false is actually executed. Must throw.
◆ shouldSpecialiseArgument()
template<typename T >
constexpr static bool sp::Specialisable::shouldSpecialiseArgument |
( |
int |
| ) |
|
|
staticconstexpr |
Should the specialiser attempt to specialise the argument at the given position in the argument list, which is of type T
?
The default implementation always returns true.
◆ validScalarTypes()
template<typename KnownTensorTypes , typename... ScalarTypes>
constexpr static bool sp::Specialisable::validScalarTypes |
( |
| ) |
|
|
staticconstexpr |
- Template Parameters
-
KnownTensorTypes | An sp::TypeList<...> where ... is a list of the currently-known Tensor types about to be passed to the operator. This tuple may be of length zero, but only if the operator function has a scalar argument that occurs before any Tensor arguments. |
ScalarTypes | All of the scalar types about to be passed to the function, in order. Since scalar types are known immediately (unlike tensor types/ranks), this routine gets the whole lot at once, which should simplify implementations. |
- Returns
- false if the expansion should be pruned, true otherwise.
◆ validTensorRanks()
template<int... Ranks>
constexpr static bool sp::Specialisable::validTensorRanks |
( |
| ) |
|
|
staticconstexpr |
- Template Parameters
-
Ranks | A prefix of the list of Tensor ranks about to be used as arguments to the operator, in arg-order. The function is never called with a zero-length argument pack. |
- Returns
- false if the given list of ranks is not valid for this operator, true otherwise.
◆ validTensorTypes()
template<typename... Types>
constexpr static bool sp::Specialisable::validTensorTypes |
( |
| ) |
|
|
staticconstexpr |
- Template Parameters
-
Types | A prefix of the list of Tensor types about to be used as arguments to the operator, in arg-order. The function is never called with a zero-length argument pack. |
- Returns
- false if the given list of types is not valid for this operator, true otherwise.
◆ DesiresPitchedness
constexpr static bool sp::Specialisable::DesiresPitchedness = true |
|
staticconstexpr |
True if we should attempt to set the pitchedness flag of TensorLike
s.
◆ MaxPackMode
constexpr static PackMode sp::Specialisable::MaxPackMode = PackMode::FULL |
|
staticconstexpr |
The maximum Tensor
packing mode that's worth optimising for.
Note that, for 1D tensors, FULL and PARTIAL are equivalent.