MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::plug::tensor Namespace Reference

The tensor Plugin More...

Namespaces

namespace  phase

Classes

struct  PureRead
 A pure re-indexed read: the source tensor, the access map into it (over the read's output coordinates), and the source's element type/rank/shape. More...

Enumerations

%tensor.generate
enum class  generate : flags_t
%tensor.splat
enum class  splat : flags_t
%tensor.id
enum class  id : flags_t
%tensor.map_reduce_post
enum class  map_reduce_post : flags_t
%tensor.map_reduce
enum class  map_reduce : flags_t
%tensor.transpose
enum class  transpose : flags_t
%tensor.transpose_2d
enum class  transpose_2d : flags_t
%tensor.binary
enum class  binary : flags_t
%tensor.map
enum class  map : flags_t
%tensor.select
enum class  select : flags_t
%tensor.unary
enum class  unary : flags_t
%tensor.bmm
enum class  bmm : flags_t
%tensor.conv
enum class  conv : flags_t
%tensor.dot_product
enum class  dot_product : flags_t
%tensor.pool
enum class  pool : flags_t
%tensor.product_2d
enum class  product_2d : flags_t
%tensor.gather
enum class  gather : flags_t
%tensor.scatter
enum class  scatter : flags_t
%tensor.interchange
enum class  interchange : flags_t
%tensor.materialize
enum class  materialize : flags_t
%tensor.mr_tileable
enum class  mr_tileable : flags_t
%tensor.strip_mine_par
enum class  strip_mine_par : flags_t
%tensor.strip_mine_red
enum class  strip_mine_red : flags_t
%tensor.broadcast_in_dim_impl
enum class  broadcast_in_dim_impl : flags_t
%tensor.flip_impl
enum class  flip_impl : flags_t
%tensor.gather_pointwise_elem_impl
enum class  gather_pointwise_elem_impl : flags_t
%tensor.map_impl
enum class  map_impl : flags_t
%tensor.pool_impl
enum class  pool_impl : flags_t
%tensor.repeat_impl
enum class  repeat_impl : flags_t
%tensor.reshape_map
enum class  reshape_map : flags_t
%tensor.reshape_impl
enum class  reshape_impl : flags_t
%tensor.conv_impl
enum class  conv_impl : flags_t
%tensor.dot_product_impl
enum class  dot_product_impl : flags_t
%tensor.bmm_impl
enum class  bmm_impl : flags_t
%tensor.product_2d_impl
enum class  product_2d_impl : flags_t
%tensor.scatter_step_impl
enum class  scatter_step_impl : flags_t
%tensor.slice_impl
enum class  slice_impl : flags_t
%tensor.transpose_impl
enum class  transpose_impl : flags_t
%tensor.transpose_2d_impl
enum class  transpose_2d_impl : flags_t
%tensor.binary_impl
enum class  binary_impl : flags_t
%tensor.select_impl
enum class  select_impl : flags_t
%tensor.unary_impl
enum class  unary_impl : flags_t
%tensor.reassoc
enum class  reassoc : flags_t
%tensor.lower_tensor
enum class  lower_tensor : flags_t
%tensor.lower_map_reduce
enum class  lower_map_reduce : flags_t
%tensor.lower_get_set
enum class  lower_get_set : flags_t
%tensor.fuse_tensor
enum class  fuse_tensor : flags_t
%tensor.lower_to_mem
enum class  lower_to_mem : flags_t

Functions

bool is_copy_comb (const Def *comb)
 Recognizes the (rebuilt) tensor_copy combiner (acc, ys) ↦ ys#0: the result is exactly the single input element, so a map_reduce built on it is a pure re-indexed read of that input.
bool is_identity_post (const Def *post)
 Is post the (rebuilt) CPS identity tensor.id, i.e.
std::optional< PureReadis_pure_read (const Def *value)
 If value is a pure re-indexed read — a copy-combiner map_reduce without reduction loops that writes its full loop domain through the identity output map (reshape/transpose/slice/flip/repeat lower to these) — returns its single access map and source.
const Defop_get (const Def *T, const Def *r, const Def *s, const Def *arr, const Def *index)
const Defop_set (const Def *T, const Def *r, const Def *s, const Def *arr, const Def *index, const Def *x)
template<class Pred>
DefMap< u64count_consumers (const World &world, Pred pred)
 Counts the consumers of every def of world matched by pred.
std::tuple< u64, const Def *, const Def * > fold_shape_and_index (const Def *shapeshape, const Def *index)
void reg_phases (Flags2Phases &phases)
void register_normalizers (Normalizers &normalizers)

Variables

static constexpr plugin_t Plugin_Id = 0x5463d44130000000

%tensor.get

enum class  get : flags_t
const Defnormalize_get (const Def *, const Def *c, const Def *arg)

%tensor.set

enum class  set : flags_t
const Defnormalize_set (const Def *, const Def *c, const Def *arg)

%tensor.shape

enum class  shape : flags_t
const Defnormalize_shape (const Def *, const Def *c, const Def *arg)

%tensor.broadcast

enum class  broadcast : flags_t
const Defnormalize_broadcast (const Def *, const Def *c, const Def *arg)

%tensor.broadcast_in_dim

enum class  broadcast_in_dim : flags_t
const Defnormalize_broadcast_in_dim (const Def *, const Def *, const Def *)

%tensor.concat

enum class  concat : flags_t
const Defnormalize_concat (const Def *, const Def *, const Def *)

%tensor.flip

enum class  flip : flags_t
const Defnormalize_flip (const Def *, const Def *, const Def *)

%tensor.pad

enum class  pad : flags_t
const Defnormalize_pad (const Def *, const Def *c, const Def *arg)

%tensor.repeat

enum class  repeat : flags_t
const Defnormalize_repeat (const Def *, const Def *c, const Def *arg)

%tensor.reshape

enum class  reshape : flags_t
const Defnormalize_reshape (const Def *, const Def *c, const Def *arg)

%tensor.slice

enum class  slice : flags_t
const Defnormalize_slice (const Def *, const Def *c, const Def *arg)

%tensor.fastest_axis

enum class  fastest_axis : flags_t
const Defnormalize_fastest_axis (const Def *, const Def *, const Def *arg)

%tensor.if_static

enum class  if_static : flags_t
const Defnormalize_if_static (const Def *, const Def *, const Def *arg)

Detailed Description


Class Documentation

◆ mim::plug::tensor::PureRead

struct mim::plug::tensor::PureRead

A pure re-indexed read: the source tensor, the access map into it (over the read's output coordinates), and the source's element type/rank/shape.

Definition at line 31 of file tensor.h.

Class Members
const Def * map = nullptr
const Def * R = nullptr
const Def * S = nullptr
const Def * src = nullptr
const Def * T = nullptr

Enumeration Type Documentation

◆ binary

enum class mim::plug::tensor::binary : flags_t
strong

Definition at line 151 of file autogen.h.

◆ binary_impl

Definition at line 391 of file autogen.h.

◆ bmm

enum class mim::plug::tensor::bmm : flags_t
strong

Definition at line 179 of file autogen.h.

◆ bmm_impl

enum class mim::plug::tensor::bmm_impl : flags_t
strong

Definition at line 349 of file autogen.h.

◆ broadcast

Definition at line 73 of file autogen.h.

◆ broadcast_in_dim

Definition at line 81 of file autogen.h.

◆ broadcast_in_dim_impl

Definition at line 279 of file autogen.h.

◆ concat

enum class mim::plug::tensor::concat : flags_t
strong

Definition at line 89 of file autogen.h.

◆ conv

enum class mim::plug::tensor::conv : flags_t
strong

Definition at line 186 of file autogen.h.

◆ conv_impl

Definition at line 335 of file autogen.h.

◆ dot_product

Definition at line 193 of file autogen.h.

◆ dot_product_impl

Definition at line 342 of file autogen.h.

◆ fastest_axis

Definition at line 228 of file autogen.h.

◆ flip

enum class mim::plug::tensor::flip : flags_t
strong

Definition at line 97 of file autogen.h.

◆ flip_impl

Definition at line 286 of file autogen.h.

◆ fuse_tensor

Definition at line 440 of file autogen.h.

◆ gather

enum class mim::plug::tensor::gather : flags_t
strong

Definition at line 214 of file autogen.h.

◆ gather_pointwise_elem_impl

Definition at line 293 of file autogen.h.

◆ generate

enum class mim::plug::tensor::generate : flags_t
strong

Definition at line 14 of file autogen.h.

◆ get

enum class mim::plug::tensor::get : flags_t
strong

Definition at line 28 of file autogen.h.

◆ id

enum class mim::plug::tensor::id : flags_t
strong

Definition at line 52 of file autogen.h.

◆ if_static

Definition at line 236 of file autogen.h.

◆ interchange

Definition at line 244 of file autogen.h.

◆ lower_get_set

Definition at line 433 of file autogen.h.

◆ lower_map_reduce

Definition at line 426 of file autogen.h.

◆ lower_tensor

Definition at line 419 of file autogen.h.

◆ lower_to_mem

Definition at line 447 of file autogen.h.

◆ map

enum class mim::plug::tensor::map : flags_t
strong

Definition at line 158 of file autogen.h.

◆ map_impl

enum class mim::plug::tensor::map_impl : flags_t
strong

Definition at line 300 of file autogen.h.

◆ map_reduce

Definition at line 66 of file autogen.h.

◆ map_reduce_post

Definition at line 59 of file autogen.h.

◆ materialize

Definition at line 251 of file autogen.h.

◆ mr_tileable

Definition at line 258 of file autogen.h.

◆ pad

enum class mim::plug::tensor::pad : flags_t
strong

Definition at line 105 of file autogen.h.

◆ pool

enum class mim::plug::tensor::pool : flags_t
strong

Definition at line 200 of file autogen.h.

◆ pool_impl

Definition at line 307 of file autogen.h.

◆ product_2d

Definition at line 207 of file autogen.h.

◆ product_2d_impl

Definition at line 356 of file autogen.h.

◆ reassoc

enum class mim::plug::tensor::reassoc : flags_t
strong

Definition at line 412 of file autogen.h.

◆ repeat

enum class mim::plug::tensor::repeat : flags_t
strong

Definition at line 113 of file autogen.h.

◆ repeat_impl

Definition at line 314 of file autogen.h.

◆ reshape

enum class mim::plug::tensor::reshape : flags_t
strong

Definition at line 121 of file autogen.h.

◆ reshape_impl

Definition at line 328 of file autogen.h.

◆ reshape_map

Definition at line 321 of file autogen.h.

◆ scatter

enum class mim::plug::tensor::scatter : flags_t
strong

Definition at line 221 of file autogen.h.

◆ scatter_step_impl

Definition at line 363 of file autogen.h.

◆ select

enum class mim::plug::tensor::select : flags_t
strong

Definition at line 165 of file autogen.h.

◆ select_impl

Definition at line 398 of file autogen.h.

◆ set

enum class mim::plug::tensor::set : flags_t
strong

Definition at line 36 of file autogen.h.

◆ shape

enum class mim::plug::tensor::shape : flags_t
strong

Definition at line 44 of file autogen.h.

◆ slice

enum class mim::plug::tensor::slice : flags_t
strong

Definition at line 129 of file autogen.h.

◆ slice_impl

Definition at line 370 of file autogen.h.

◆ splat

enum class mim::plug::tensor::splat : flags_t
strong

Definition at line 21 of file autogen.h.

◆ strip_mine_par

Definition at line 265 of file autogen.h.

◆ strip_mine_red

Definition at line 272 of file autogen.h.

◆ transpose

Definition at line 137 of file autogen.h.

◆ transpose_2d

Definition at line 144 of file autogen.h.

◆ transpose_2d_impl

Definition at line 384 of file autogen.h.

◆ transpose_impl

Definition at line 377 of file autogen.h.

◆ unary

enum class mim::plug::tensor::unary : flags_t
strong

Definition at line 172 of file autogen.h.

◆ unary_impl

Definition at line 405 of file autogen.h.

Function Documentation

◆ count_consumers()

template<class Pred>
DefMap< u64 > mim::plug::tensor::count_consumers ( const World & world,
Pred pred )

Counts the consumers of every def of world matched by pred.

Tuples and packs are transparent argument wrappers, so a wrapped def is charged to the enclosing non-tuple consumer - a shared argument tuple charges each of its users, and a def used twice in one argument list counts twice. A phase whose world does not track uses needs this up front.

Definition at line 81 of file tensor.h.

References count_consumers(), and mim::World::roots().

Referenced by count_consumers(), mim::plug::tensor::phase::Fuse::start(), and mim::plug::tensor::phase::Reassoc::start().

◆ fold_shape_and_index()

std::tuple< u64, const Def *, const Def * > mim::plug::tensor::fold_shape_and_index ( const Def * shape,
const Def * index )

◆ is_copy_comb()

bool mim::plug::tensor::is_copy_comb ( const Def * comb)
inline

Recognizes the (rebuilt) tensor_copy combiner (acc, ys) ↦ ys#0: the result is exactly the single input element, so a map_reduce built on it is a pure re-indexed read of that input.

Definition at line 17 of file tensor.h.

References mim::Def::as_mut(), is_copy_comb(), mim::Lam::isa_ret_arg(), and mim::Def::proj().

Referenced by is_copy_comb(), and is_pure_read().

◆ is_identity_post()

bool mim::plug::tensor::is_identity_post ( const Def * post)
inline

Is post the (rebuilt) CPS identity tensor.id, i.e.

a lam (x, extras) ↦ x that returns its first argument (and hence has no epilogue inputs)?

Definition at line 24 of file tensor.h.

References mim::Def::as_mut(), is_identity_post(), mim::Lam::isa_ret_arg(), and mim::Def::proj().

Referenced by is_identity_post(), and is_pure_read().

◆ is_pure_read()

std::optional< PureRead > mim::plug::tensor::is_pure_read ( const Def * value)
inline

If value is a pure re-indexed read — a copy-combiner map_reduce without reduction loops that writes its full loop domain through the identity output map (reshape/transpose/slice/flip/repeat lower to these) — returns its single access map and source.

fuse_tensor's read-through absorbs exactly these into the consuming op's access maps.

Definition at line 43 of file tensor.h.

References is_copy_comb(), is_identity_post(), is_pure_read(), mim::Axm::isa(), mim::Lit::isa(), and mim::Def::projs().

Referenced by is_pure_read(), normalize_fastest_axis(), mim::plug::tensor::phase::read_through(), and mim::plug::tensor::phase::Fuse::rewrite_imm_App().

◆ normalize_broadcast()

const Def * mim::plug::tensor::normalize_broadcast ( const Def * ,
const Def * c,
const Def * arg )

Definition at line 181 of file normalizers.cpp.

References mim::Lit::isa(), normalize_broadcast(), and mim::Def::projs().

Referenced by normalize_broadcast().

◆ normalize_broadcast_in_dim()

const Def * mim::plug::tensor::normalize_broadcast_in_dim ( const Def * ,
const Def * ,
const Def *  )

Definition at line 199 of file normalizers.cpp.

References normalize_broadcast_in_dim().

Referenced by normalize_broadcast_in_dim().

◆ normalize_concat()

const Def * mim::plug::tensor::normalize_concat ( const Def * ,
const Def * ,
const Def *  )

Definition at line 246 of file normalizers.cpp.

References normalize_concat().

Referenced by normalize_concat().

◆ normalize_fastest_axis()

const Def * mim::plug::tensor::normalize_fastest_axis ( const Def * ,
const Def * ,
const Def * arg )

◆ normalize_flip()

const Def * mim::plug::tensor::normalize_flip ( const Def * ,
const Def * ,
const Def *  )

Definition at line 230 of file normalizers.cpp.

References normalize_flip().

Referenced by normalize_flip().

◆ normalize_get()

const Def * mim::plug::tensor::normalize_get ( const Def * ,
const Def * c,
const Def * arg )

◆ normalize_if_static()

const Def * mim::plug::tensor::normalize_if_static ( const Def * ,
const Def * ,
const Def * arg )

Definition at line 248 of file normalizers.cpp.

References mim::Lit::isa(), normalize_if_static(), and mim::Def::projs().

Referenced by normalize_if_static().

◆ normalize_pad()

const Def * mim::plug::tensor::normalize_pad ( const Def * ,
const Def * c,
const Def * arg )

Definition at line 232 of file normalizers.cpp.

References mim::Lit::isa(), normalize_pad(), and mim::Def::proj().

Referenced by normalize_pad().

◆ normalize_repeat()

const Def * mim::plug::tensor::normalize_repeat ( const Def * ,
const Def * c,
const Def * arg )

Definition at line 201 of file normalizers.cpp.

References normalize_repeat().

Referenced by normalize_repeat().

◆ normalize_reshape()

const Def * mim::plug::tensor::normalize_reshape ( const Def * ,
const Def * c,
const Def * arg )

Definition at line 208 of file normalizers.cpp.

References normalize_reshape().

Referenced by normalize_reshape().

◆ normalize_set()

const Def * mim::plug::tensor::normalize_set ( const Def * ,
const Def * c,
const Def * arg )

◆ normalize_shape()

const Def * mim::plug::tensor::normalize_shape ( const Def * ,
const Def * c,
const Def * arg )

Definition at line 287 of file normalizers.cpp.

References mim::App::arg(), mim::Lit::isa(), normalize_shape(), and mim::Def::type().

Referenced by normalize_shape().

◆ normalize_slice()

const Def * mim::plug::tensor::normalize_slice ( const Def * ,
const Def * c,
const Def * arg )

Definition at line 215 of file normalizers.cpp.

References mim::Lit::isa(), and normalize_slice().

Referenced by normalize_slice().

◆ op_get()

const Def * mim::plug::tensor::op_get ( const Def * T,
const Def * r,
const Def * s,
const Def * arr,
const Def * index )
inline
Note
index comes before arr in the operand tuple, see tensor.get.

Definition at line 64 of file tensor.h.

References op_get(), and mim::Def::world().

Referenced by normalize_get(), and op_get().

◆ op_set()

const Def * mim::plug::tensor::op_set ( const Def * T,
const Def * r,
const Def * s,
const Def * arr,
const Def * index,
const Def * x )
inline
Note
index comes before arr in the operand tuple, see tensor.get.

Definition at line 70 of file tensor.h.

References op_set(), and mim::Def::world().

Referenced by normalize_set(), and op_set().

◆ reg_phases()

void mim::plug::tensor::reg_phases ( Flags2Phases & phases)

Definition at line 16 of file tensor.cpp.

References mim::Phase::hook(), and reg_phases().

Referenced by mim_get_plugin(), and reg_phases().

◆ register_normalizers()

void mim::plug::tensor::register_normalizers ( Normalizers & normalizers)

Variable Documentation

◆ Plugin_Id

plugin_t mim::plug::tensor::Plugin_Id = 0x5463d44130000000
staticconstexpr

Definition at line 10 of file autogen.h.