Speclib  0.1.2
The library for writing better CUDA libraries
sp::TensorExprSpecialiser Struct Reference

Specialise an entire TensorExpr. More...

#include <TensorExpr.hpp>

Inheritance diagram for sp::TensorExprSpecialiser:
[legend]

Static Public Member Functions

template<typename T >
static constexpr bool test ()
 
template<template< typename... > typename Node, typename... Operands, int... ChildIdx, typename Fn , typename... Stuff>
static auto optimiseNode (const Node< Operands... > &expr, sp::int_sequence< ChildIdx... >, Fn &fn, Stuff &&... stuff)
 
template<template< typename... > typename Node, typename... Operands, typename... Stuff>
static auto run (const Node< Operands... > expr, Stuff &&... stuff)
 
- Static Public Member Functions inherited from sp::Specialiser
template<typename T >
static constexpr bool test ()
 Return true iff the specialiser is able to specialise arguments of type T. More...
 
template<typename... O, typename ArgType , typename... Stuff>
static auto run (const ArgType &thisArg, Stuff &&... stuff)
 Specialise an argument. More...
 

Detailed Description

Specialise an entire TensorExpr.

This does two things:

  • Attempts to apply TensorSpecialiser and ScalarSpecialiser to leaf nodes of the TensorExpr, producing a more optimal TensorExpr.
  • Performs very simple constexpr expression simplification steps on the TensorExpr (such as eliminating multiplication by zero). This is pointful (compared to just letting the optimiser do it) because sometimes it lets us skip the kernel launch entirely, and having the compiler figure out when it's safe to do that is quite nontrivial.