Builder C++-API

Contents

Builder C++-API#

Common#

Common Classes#

builder_error#

class builder_error : public std::exception#

Builder exception enhanced with location.

Public Functions

inline builder_error(status code, location const &loc)#

ctor; taking location and status code

inline auto code() const noexcept#

Get status code.

inline location const &loc() const noexcept#

Get location.

inline char const *what() const noexcept override#

Get explanatory string.

Common Functions#

is_dynamic_value#

inline bool tinytc::is_dynamic_value(std::int64_t i)#

Check if mode i is dynamic (‘?’)

Common Typedefs#

location#

using tinytc::location = ::tinytc_location#

Alias for tinytc_location in namespace tinytc.

position#

using tinytc::position = ::tinytc_position#

Alias for tinytc_position in namespace tinytc.

Common Variables#

dynamic#

static std::int64_t tinytc::dynamic = TINYTC_DYNAMIC#

Attribute#

Attribute Functions#

get_dictionary_attr_with_sorted#

inline tinytc_attr_t tinytc::get_dictionary_attr_with_sorted(tinytc_compiler_context_t ctx, array_view<tinytc_named_attr_t> items)#

Get dictionary attribute.

The list of items must be sorted by name and each name must only appear once.

Parameters:
  • ctx – compiler context

  • items – named items array

Returns:

Attribute

sort_items#

inline void tinytc::sort_items(mutable_array_view<tinytc_named_attr_t> items)#

Sort list of items.

Each name must only appear once.

Parameters:

items – named items array

Attribute Structures#

getter<array_attr>#

template<>
struct getter<array_attr>#

getter specialization for array_attr

Public Functions

inline tinytc_attr_t operator()(tinytc_compiler_context_t ctx, array_view<tinytc_attr_t> array)#

Get array attribute.

Parameters:
  • ctx – compiler context

  • array – attribute array

Returns:

Attribute

getter<boolean_attr>#

template<>
struct getter<boolean_attr>#

getter specialization for boolean_attr

Public Functions

inline tinytc_attr_t operator()(tinytc_compiler_context_t ctx, bool value)#

Get boolean attribute.

Parameters:
  • ctx – compiler context

  • value – boolean value

Returns:

Attribute

getter<dictionary_attr>#

template<>
struct getter<dictionary_attr>#

getter specialization for dictionary_attr

Public Functions

inline tinytc_attr_t operator()(tinytc_compiler_context_t ctx, mutable_array_view<tinytc_named_attr_t> items)#

Get dictionary attribute.

Each name must only appear once.

Parameters:
  • ctx – compiler context

  • items – named items array

Returns:

Attribute

getter<integer_attr>#

template<>
struct getter<integer_attr>#

getter specialization for integer_attr

Public Functions

inline tinytc_attr_t operator()(tinytc_compiler_context_t ctx, std::int64_t value)#

Get integer attribute.

Parameters:
  • ctx – compiler context

  • value – integer value

Returns:

Attribute

getter<string_attr>#

template<>
struct getter<string_attr>#

getter specialization for string_attr

Public Functions

inline tinytc_attr_t operator()(tinytc_compiler_context_t ctx, std::string_view str)#

Get string attribute.

Parameters:
  • ctx – compiler context

  • str – string

Returns:

Attribute

Data Type#

Data Type Functions#

get_compiler_context(const_tinytc_type_t)#

inline shared_handle<tinytc_compiler_context_t> tinytc::get_compiler_context(const_tinytc_type_t ty)#

Get context.

Parameters:

ty – type

Returns:

Compiler context

to_type#

template<typename T>
tinytc_type_t tinytc::to_type(tinytc_compiler_context_t ctx)#

Returns an appropriate tinytc type for C++ type T

Specializations exist for bool, int8_t, int16_t, int32_t, int64_t, bfloat16, half, float, double, std::complex<float>, std::complex<double>

Data Type Builder#

Data Type Builder Functions#

get#

template<typename T, typename ...Args>
inline auto tinytc::get(Args&&... args)#

Get type.

Parameters:

args – Arguments forwarded to getter

Returns:

Type

Data Type Builder Structures#

getter<boolean_type>#

template<>
struct getter<boolean_type>#

getter specialization for boolean_type

Public Functions

inline tinytc_type_t operator()(tinytc_compiler_context_t ctx)#

Bool type

Parameters:

ctx – compiler context

Returns:

Instruction

getter<i8_type>#

template<>
struct getter<i8_type>#

getter specialization for i8_type

Public Functions

inline tinytc_type_t operator()(tinytc_compiler_context_t ctx)#

Signed 8 bit integer type

Parameters:

ctx – compiler context

Returns:

Instruction

getter<i16_type>#

template<>
struct getter<i16_type>#

getter specialization for i16_type

Public Functions

inline tinytc_type_t operator()(tinytc_compiler_context_t ctx)#

Signed 16 bit integer type

Parameters:

ctx – compiler context

Returns:

Instruction

getter<i32_type>#

template<>
struct getter<i32_type>#

getter specialization for i32_type

Public Functions

inline tinytc_type_t operator()(tinytc_compiler_context_t ctx)#

Signed 32 bit integer type

Parameters:

ctx – compiler context

Returns:

Instruction

getter<i64_type>#

template<>
struct getter<i64_type>#

getter specialization for i64_type

Public Functions

inline tinytc_type_t operator()(tinytc_compiler_context_t ctx)#

Signed 64 bit integer type

Parameters:

ctx – compiler context

Returns:

Instruction

getter<index_type>#

template<>
struct getter<index_type>#

getter specialization for index_type

Public Functions

inline tinytc_type_t operator()(tinytc_compiler_context_t ctx)#

Integer type for indices

Parameters:

ctx – compiler context

Returns:

Instruction

getter<bf16_type>#

template<>
struct getter<bf16_type>#

getter specialization for bf16_type

Public Functions

inline tinytc_type_t operator()(tinytc_compiler_context_t ctx)#

Brain floating point (16 bit)

Parameters:

ctx – compiler context

Returns:

Instruction

getter<f16_type>#

template<>
struct getter<f16_type>#

getter specialization for f16_type

Public Functions

inline tinytc_type_t operator()(tinytc_compiler_context_t ctx)#

Half precision floating point (16 bit)

Parameters:

ctx – compiler context

Returns:

Instruction

getter<f32_type>#

template<>
struct getter<f32_type>#

getter specialization for f32_type

Public Functions

inline tinytc_type_t operator()(tinytc_compiler_context_t ctx)#

Single precision floating point (32 bit)

Parameters:

ctx – compiler context

Returns:

Instruction

getter<f64_type>#

template<>
struct getter<f64_type>#

getter specialization for f64_type

Public Functions

inline tinytc_type_t operator()(tinytc_compiler_context_t ctx)#

Double precision floating point (64 bit)

Parameters:

ctx – compiler context

Returns:

Instruction

getter<c32_type>#

template<>
struct getter<c32_type>#

getter specialization for c32_type

Public Functions

inline tinytc_type_t operator()(tinytc_compiler_context_t ctx)#

Single precision floating point (32 bit)

Parameters:

ctx – compiler context

Returns:

Instruction

getter<c64_type>#

template<>
struct getter<c64_type>#

getter specialization for c64_type

Public Functions

inline tinytc_type_t operator()(tinytc_compiler_context_t ctx)#

Double precision floating point (64 bit)

Parameters:

ctx – compiler context

Returns:

Instruction

getter<coopmatrix_type>#

template<>
struct getter<coopmatrix_type>#

getter specialization for coopmatrix_type

Public Functions

inline tinytc_type_t operator()(tinytc_type_t component_ty, std::int64_t rows, std::int64_t cols, matrix_use use)#

Coopmatrix type

Parameters:
  • component_ty – component type

  • rows – number of rows

  • cols – number of columns

  • use – matrix use

Returns:

Instruction

getter<group_type>#

template<>
struct getter<group_type>#

getter specialization for group_type

Public Functions

inline tinytc_type_t operator()(tinytc_type_t element_ty, std::int64_t size, std::int64_t offset)#

Group type

Parameters:
  • element_ty – element type

  • size – group size

  • offset – offset added on element access

Returns:

Instruction

getter<memref_type>#

template<>
struct getter<memref_type>#

getter specialization for memref_type

Public Functions

inline tinytc_type_t operator()(tinytc_type_t element_ty, array_view<std::int64_t> shape, array_view<std::int64_t> stride, address_space addrspace)#

Memref type

Parameters:
  • element_ty – element type

  • shape – tensor shape; can be {}

  • stride – tensor stride; can be {}

  • addrspace – address space

Returns:

Instruction

getter<void_type>#

template<>
struct getter<void_type>#

getter specialization for void_type

Public Functions

inline tinytc_type_t operator()(tinytc_compiler_context_t ctx)#

Void type

Parameters:

ctx – compiler context

Returns:

Instruction

Function#

Function Functions#

create_func#

inline unique_handle<tinytc_func_t> tinytc::create_func(std::string_view name, array_view<tinytc_type_t> param_type_list, tinytc_type_t ty, location const &loc = {})#

Create function.

Parameters:
  • name – Function name

  • param_type_list – List of parameter types

  • ty – Result type (must be void for host-callable function)

  • loc – Source code location

Returns:

Function

get_body#

inline tinytc_region_t tinytc::get_body(tinytc_func_t f)#

Get function body.

Parameters:

f – function

Returns:

Region

set_attr(tinytc_func_t,tinytc_attr_t)#

inline void tinytc::set_attr(tinytc_func_t f, tinytc_attr_t a)#

Set function attributes.

Parameters:
  • f – function

  • a – attribute

set_parameter_attr#

inline void tinytc::set_parameter_attr(tinytc_func_t f, std::size_t param_no, tinytc_attr_t a)#

Set attribute of function parameter.

Parameters:
  • f – function

  • param_no – parameter number

  • a – attribute

Instruction#

Instruction Functions#

get_parent_region#

inline tinytc_region_t tinytc::get_parent_region(tinytc_inst_t in)#

Get parent region of instruction.

Parameters:

in – Instruction

Returns:

Region

get_regions#

inline std::size_t tinytc::get_regions(tinytc_inst_t in, mutable_array_view<tinytc_region_t> regs)#

Get child regions.

May be called with empty view (vals = {}) to get the number of child regions.

Parameters:
  • in – Instruction

  • regs – view on buffer that stores results

Returns:

Minimum of view size and actual number of child regions

get_values#

inline std::size_t tinytc::get_values(tinytc_inst_t in, mutable_array_view<tinytc_value_t> vals)#

Get result values.

May be called with empty view (vals = {}) to get the number of results.

Parameters:
  • in – Instruction

  • vals – view on buffer that stores results

Returns:

Minimum of view size and actual number of result values

set_attr(tinytc_inst_t,tinytc_attr_t)#

inline void tinytc::set_attr(tinytc_inst_t in, tinytc_attr_t a)#

Set attribute.

Parameters:
  • in – Instruction

  • a – attribute

Instruction Builder#

Instruction Builder Functions#

create#

template<typename T, typename ...Args>
inline unique_handle<tinytc_inst_t> tinytc::create(Args&&... args)#

Create instruction.

Parameters:

args – Arguments forwarded to creator

Returns:

Instruction

Instruction Builder Structures#

creator<abs_inst>#

template<>
struct creator<abs_inst>#

creator specialization for abs_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Absolute value instruction

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of abs_inst instruction.

creator<add_inst>#

template<>
struct creator<add_inst>#

creator specialization for add_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Addition instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of add_inst instruction.

creator<alloca_inst>#

template<>
struct creator<alloca_inst>#

creator specialization for alloca_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_type_t result, location const &loc = {})#

Alloca instruction

Parameters:
  • result – memref type of allocated variable

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of alloca_inst instruction.

creator<and_inst>#

template<>
struct creator<and_inst>#

creator specialization for and_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Bitwise and instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of and_inst instruction.

creator<atomic_add_inst>#

template<>
struct creator<atomic_add_inst>#

creator specialization for atomic_add_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(memory_scope scope, memory_semantics semantics, tinytc_value_t val, tinytc_value_t operand, array_view<tinytc_value_t> index_list, tinytc_type_t result, location const &loc = {})#

Atomic add instruction

Parameters:
  • scope – memory scope

  • semantics – memory semantics

  • val – value to store

  • operand – operand

  • index_list – indices; can be {}

  • result – atomically updated value

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of atomic_add_inst instruction.

creator<atomic_load_inst>#

template<>
struct creator<atomic_load_inst>#

creator specialization for atomic_load_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(memory_scope scope, memory_semantics semantics, tinytc_value_t operand, array_view<tinytc_value_t> index_list, tinytc_type_t result, location const &loc = {})#

Atomic load instruction

Parameters:
  • scope – memory scope

  • semantics – memory semantics

  • operand – tensor or group of tensors

  • index_list – indices; can be {}

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of atomic_load_inst instruction.

creator<atomic_max_inst>#

template<>
struct creator<atomic_max_inst>#

creator specialization for atomic_max_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(memory_scope scope, memory_semantics semantics, tinytc_value_t val, tinytc_value_t operand, array_view<tinytc_value_t> index_list, tinytc_type_t result, location const &loc = {})#

Atomic max instruction

Parameters:
  • scope – memory scope

  • semantics – memory semantics

  • val – value to store

  • operand – operand

  • index_list – indices; can be {}

  • result – atomically updated value

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of atomic_max_inst instruction.

creator<atomic_min_inst>#

template<>
struct creator<atomic_min_inst>#

creator specialization for atomic_min_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(memory_scope scope, memory_semantics semantics, tinytc_value_t val, tinytc_value_t operand, array_view<tinytc_value_t> index_list, tinytc_type_t result, location const &loc = {})#

Atomic min instruction

Parameters:
  • scope – memory scope

  • semantics – memory semantics

  • val – value to store

  • operand – operand

  • index_list – indices; can be {}

  • result – atomically updated value

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of atomic_min_inst instruction.

creator<atomic_store_inst>#

template<>
struct creator<atomic_store_inst>#

creator specialization for atomic_store_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(memory_scope scope, memory_semantics semantics, tinytc_value_t val, tinytc_value_t operand, array_view<tinytc_value_t> index_list, location const &loc = {})#

Atomic store instruction

Parameters:
  • scope – memory scope

  • semantics – memory semantics

  • val – value to store

  • operand – operand

  • index_list – indices; can be {}

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of atomic_store_inst instruction.

creator<axpby_inst>#

template<>
struct creator<axpby_inst>#

creator specialization for axpby_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(bool atomic, transpose tA, tinytc_value_t alpha, tinytc_value_t A, tinytc_value_t beta, tinytc_value_t B, location const &loc = {})#

AXPBY instruction

Parameters:
  • atomic – atomic flag

  • tA – transpose A

  • alpha – alpha scalar

  • A – A tensor

  • beta – beta scalar

  • B – B tensor

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of axpby_inst instruction.

creator<barrier_inst>#

template<>
struct creator<barrier_inst>#

creator specialization for barrier_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_address_spaces_t fence_flags, location const &loc = {})#

Barrier instruction

Parameters:
  • fence_flags – address space(s) of memory fence; set to 0 for no fence

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of barrier_inst instruction.

creator<cast_inst>#

template<>
struct creator<cast_inst>#

creator specialization for cast_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Cast instruction

Parameters:
  • a – operand

  • result – target type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cast_inst instruction.

creator<conj_inst>#

template<>
struct creator<conj_inst>#

creator specialization for conj_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Complex conjugate instruction

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of conj_inst instruction.

creator<constant_inst>#

template<>
struct creator<constant_inst>#

creator specialization for constant_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(bool value, tinytc_type_t ty, location const &loc = {})#

Create boolean constant.

Parameters:
  • value – Constant

  • ty – Data type

  • loc – Source code location

Returns:

Instruction

inline unique_handle<tinytc_inst_t> operator()(std::complex<double> value, tinytc_type_t ty, location const &loc = {})#

Create complex constant.

Parameters:
  • value – Complex constant

  • ty – Data type

  • loc – Source code location

Returns:

Instruction

inline unique_handle<tinytc_inst_t> operator()(double value, tinytc_type_t ty, location const &loc = {})#

Create floating constant.

Parameters:
  • value – Constant

  • ty – Data type

  • loc – Source code location

Returns:

Instruction

inline unique_handle<tinytc_inst_t> operator()(std::int32_t value, tinytc_type_t ty, location const &loc = {})#

Create integer constant.

Parameters:
  • value – Constant

  • ty – Data type

  • loc – Source code location

Returns:

Instruction

inline unique_handle<tinytc_inst_t> operator()(std::int64_t value, tinytc_type_t ty, location const &loc = {})#

Create integer constant.

Parameters:
  • value – Constant

  • ty – Data type

  • loc – Source code location

Returns:

Instruction

inline unique_handle<tinytc_inst_t> one(tinytc_type_t ty, location const &loc = {})#

Create multiplicative identity constant (“1”) for the given data type.

Parameters:
  • ty – Scalar data type

  • loc – Source code location

Returns:

Instruction

inline unique_handle<tinytc_inst_t> zero(tinytc_type_t ty, location const &loc = {})#

Create additive identity constant (“0”) for the given data type.

Parameters:
  • ty – Scalar data type

  • loc – Source code location

Returns:

Instruction

creator<cooperative_matrix_apply_inst>#

template<>
struct creator<cooperative_matrix_apply_inst>#

creator specialization for cooperative_matrix_apply_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Cooperative matrix apply instruction

Parameters:
  • a – matrix

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cooperative_matrix_apply_inst instruction.

creator<cooperative_matrix_atomic_add_inst>#

template<>
struct creator<cooperative_matrix_atomic_add_inst>#

creator specialization for cooperative_matrix_atomic_add_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(transpose t, checked_flag checked, memory_scope scope, memory_semantics semantics, tinytc_value_t val, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, tinytc_type_t result, location const &loc = {})#

Cooperative matrix atomic add instruction

Parameters:
  • t – transposed store

  • checked – boundary check

  • scope – memory scope

  • semantics – memory semantics

  • val – value to store

  • operand – matrix

  • pos0 – row offset

  • pos1 – column offset

  • result – atomically updated matrix

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cooperative_matrix_atomic_add_inst instruction.

creator<cooperative_matrix_atomic_load_inst>#

template<>
struct creator<cooperative_matrix_atomic_load_inst>#

creator specialization for cooperative_matrix_atomic_load_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(transpose t, checked_flag checked, memory_scope scope, memory_semantics semantics, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, tinytc_type_t result, location const &loc = {})#

Cooperative matrix atomic load instruction

Parameters:
  • t – transposed load

  • checked – boundary check

  • scope – memory scope

  • semantics – memory semantics

  • operand – matrix

  • pos0 – row offset

  • pos1 – column offset

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cooperative_matrix_atomic_load_inst instruction.

creator<cooperative_matrix_atomic_max_inst>#

template<>
struct creator<cooperative_matrix_atomic_max_inst>#

creator specialization for cooperative_matrix_atomic_max_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(transpose t, checked_flag checked, memory_scope scope, memory_semantics semantics, tinytc_value_t val, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, tinytc_type_t result, location const &loc = {})#

Cooperative matrix atomic max instruction

Parameters:
  • t – transposed store

  • checked – boundary check

  • scope – memory scope

  • semantics – memory semantics

  • val – value to store

  • operand – matrix

  • pos0 – row offset

  • pos1 – column offset

  • result – atomically updated matrix

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cooperative_matrix_atomic_max_inst instruction.

creator<cooperative_matrix_atomic_min_inst>#

template<>
struct creator<cooperative_matrix_atomic_min_inst>#

creator specialization for cooperative_matrix_atomic_min_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(transpose t, checked_flag checked, memory_scope scope, memory_semantics semantics, tinytc_value_t val, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, tinytc_type_t result, location const &loc = {})#

Cooperative matrix atomic min instruction

Parameters:
  • t – transposed store

  • checked – boundary check

  • scope – memory scope

  • semantics – memory semantics

  • val – value to store

  • operand – matrix

  • pos0 – row offset

  • pos1 – column offset

  • result – atomically updated matrix

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cooperative_matrix_atomic_min_inst instruction.

creator<cooperative_matrix_atomic_store_inst>#

template<>
struct creator<cooperative_matrix_atomic_store_inst>#

creator specialization for cooperative_matrix_atomic_store_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(transpose t, checked_flag checked, memory_scope scope, memory_semantics semantics, tinytc_value_t val, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, location const &loc = {})#

Cooperative matrix atomic store instruction

Parameters:
  • t – transposed store

  • checked – boundary check

  • scope – memory scope

  • semantics – memory semantics

  • val – value to store

  • operand – matrix

  • pos0 – row offset

  • pos1 – column offset

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of cooperative_matrix_atomic_store_inst instruction.

creator<cooperative_matrix_extract_inst>#

template<>
struct creator<cooperative_matrix_extract_inst>#

creator specialization for cooperative_matrix_extract_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(std::int64_t index, tinytc_value_t mat, tinytc_type_t result, location const &loc = {})#

Cooperative matrix extract instruction

Parameters:
  • index – index

  • mat – matrix

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cooperative_matrix_extract_inst instruction.

creator<cooperative_matrix_insert_inst>#

template<>
struct creator<cooperative_matrix_insert_inst>#

creator specialization for cooperative_matrix_insert_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(std::int64_t index, tinytc_value_t val, tinytc_value_t mat, tinytc_type_t result, location const &loc = {})#

Cooperative matrix insert instruction

Parameters:
  • index – index

  • val – value to insert

  • mat – matrix

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cooperative_matrix_insert_inst instruction.

creator<cooperative_matrix_load_inst>#

template<>
struct creator<cooperative_matrix_load_inst>#

creator specialization for cooperative_matrix_load_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(transpose t, checked_flag checked, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, tinytc_type_t result, location const &loc = {})#

Cooperative matrix load instruction

Parameters:
  • t – transposed load

  • checked – boundary check

  • operand – matrix

  • pos0 – row offset

  • pos1 – column offset

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cooperative_matrix_load_inst instruction.

creator<cooperative_matrix_mul_add_inst>#

template<>
struct creator<cooperative_matrix_mul_add_inst>#

creator specialization for cooperative_matrix_mul_add_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_value_t c, tinytc_type_t result, location const &loc = {})#

Cooperative matrix mul add instruction

Parameters:
  • a – a matrix

  • b – b matrix

  • c – c matrix

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cooperative_matrix_mul_add_inst instruction.

creator<cooperative_matrix_prefetch_inst>#

template<>
struct creator<cooperative_matrix_prefetch_inst>#

creator specialization for cooperative_matrix_prefetch_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(std::int32_t cache_level, std::int32_t rows, std::int32_t cols, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, location const &loc = {})#

Cooperative matrix prefetch instruction

Parameters:
  • cache_level – cache level; 0 is closest to the core

  • rows – number of rows

  • cols – number of columns

  • operand – matrix

  • pos0 – row offset

  • pos1 – column offset

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of cooperative_matrix_prefetch_inst instruction.

creator<cooperative_matrix_reduce_add_inst>#

template<>
struct creator<cooperative_matrix_reduce_add_inst>#

creator specialization for cooperative_matrix_reduce_add_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(reduce_mode mode, tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Cooperative matrix reduce add instruction

Parameters:
  • mode – reduce mode

  • a – matrix

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cooperative_matrix_reduce_add_inst instruction.

creator<cooperative_matrix_reduce_max_inst>#

template<>
struct creator<cooperative_matrix_reduce_max_inst>#

creator specialization for cooperative_matrix_reduce_max_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(reduce_mode mode, tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Cooperative matrix reduce max instruction

Parameters:
  • mode – reduce mode

  • a – matrix

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cooperative_matrix_reduce_max_inst instruction.

creator<cooperative_matrix_reduce_min_inst>#

template<>
struct creator<cooperative_matrix_reduce_min_inst>#

creator specialization for cooperative_matrix_reduce_min_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(reduce_mode mode, tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Cooperative matrix reduce min instruction

Parameters:
  • mode – reduce mode

  • a – matrix

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cooperative_matrix_reduce_min_inst instruction.

creator<cooperative_matrix_scale_inst>#

template<>
struct creator<cooperative_matrix_scale_inst>#

creator specialization for cooperative_matrix_scale_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Cooperative matrix scale instruction

Parameters:
  • a – scalar

  • b – matrix

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cooperative_matrix_scale_inst instruction.

creator<cooperative_matrix_store_inst>#

template<>
struct creator<cooperative_matrix_store_inst>#

creator specialization for cooperative_matrix_store_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(transpose t, checked_flag checked, tinytc_value_t val, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, location const &loc = {})#

Cooperative matrix store instruction

Parameters:
  • t – transposed store

  • checked – boundary check

  • val – value to store

  • operand – matrix

  • pos0 – row offset

  • pos1 – column offset

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of cooperative_matrix_store_inst instruction.

creator<cos_inst>#

template<>
struct creator<cos_inst>#

creator specialization for cos_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Cosine instruction

Parameters:
  • a – argument

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of cos_inst instruction.

creator<cumsum_inst>#

template<>
struct creator<cumsum_inst>#

creator specialization for cumsum_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(bool atomic, std::int64_t mode, tinytc_value_t alpha, tinytc_value_t A, tinytc_value_t beta, tinytc_value_t B, location const &loc = {})#

Cumsum instruction

Parameters:
  • atomic – atomic flag

  • mode – sum mode

  • alpha – alpha scalar

  • A – A tensor

  • beta – beta scalar

  • B – B tensor

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of cumsum_inst instruction.

creator<div_inst>#

template<>
struct creator<div_inst>#

creator specialization for div_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Division instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of div_inst instruction.

creator<equal_inst>#

template<>
struct creator<equal_inst>#

creator specialization for equal_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Equal instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of equal_inst instruction.

creator<exp2_inst>#

template<>
struct creator<exp2_inst>#

creator specialization for exp2_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Base-2 exponential instruction

Parameters:
  • a – argument

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of exp2_inst instruction.

creator<exp_inst>#

template<>
struct creator<exp_inst>#

creator specialization for exp_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Base-e exponential instruction

Parameters:
  • a – argument

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of exp_inst instruction.

creator<expand_inst>#

template<>
struct creator<expand_inst>#

creator specialization for expand_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(std::int64_t expanded_mode, array_view<std::int64_t> static_expand_shape, tinytc_value_t operand, array_view<tinytc_value_t> expand_shape, tinytc_type_t result, location const &loc = {})#

Expand instruction

Parameters:
  • expanded_mode – expanded mode

  • static_expand_shape – static expand shape; can be {}

  • operand – tensor

  • expand_shape – dynamic expand shape; can be {}

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of expand_inst instruction.

creator<for_inst>#

template<>
struct creator<for_inst>#

creator specialization for for_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t from, tinytc_value_t to, tinytc_value_t step, array_view<tinytc_value_t> iter_init, array_view<tinytc_type_t> results, location const &loc = {})#

Create for loop

Parameters:
  • from – loop begin (inclusive)

  • to – loop end (exclusive)

  • step – loop step; can be {}

  • iter_init – array of initial values; can be {}

  • results – array of return types; can be {}

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 2147483647#

Maximum number of results of for_inst instruction.

creator<foreach_inst>#

template<>
struct creator<foreach_inst>#

creator specialization for foreach_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(array_view<tinytc_value_t> from, array_view<tinytc_value_t> to, location const &loc = {})#

Create foreach loop

Parameters:
  • from – array of loop begin (inclusive); can be {}

  • to – array of loop end (exclusive); can be {}

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of foreach_inst instruction.

creator<foreach_tile_inst>#

template<>
struct creator<foreach_tile_inst>#

creator specialization for foreach_tile_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(array_view<std::int64_t> tile_shape, array_view<tinytc_value_t> from, array_view<tinytc_value_t> to, location const &loc = {})#

Create tiled foreach loop

Parameters:
  • tile_shape – tile shape; can be {}

  • from – array of loop begin (inclusive); can be {}

  • to – array of loop end (exclusive); can be {}

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of foreach_tile_inst instruction.

creator<fuse_inst>#

template<>
struct creator<fuse_inst>#

creator specialization for fuse_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(std::int64_t from, std::int64_t to, tinytc_value_t operand, tinytc_type_t result, location const &loc = {})#

Fuse instruction

Parameters:
  • from – first mode to fuse

  • to – last mode to fuse

  • operand – tensor

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of fuse_inst instruction.

creator<gemm_inst>#

template<>
struct creator<gemm_inst>#

creator specialization for gemm_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(bool atomic, transpose tA, transpose tB, tinytc_value_t alpha, tinytc_value_t A, tinytc_value_t B, tinytc_value_t beta, tinytc_value_t C, location const &loc = {})#

GEMM instruction

Parameters:
  • atomic – atomic flag

  • tA – transpose A

  • tB – transpose B

  • alpha – alpha scalar

  • A – A tensor

  • B – B tensor

  • beta – beta scalar

  • C – C tensor

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of gemm_inst instruction.

creator<gemv_inst>#

template<>
struct creator<gemv_inst>#

creator specialization for gemv_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(bool atomic, transpose tA, tinytc_value_t alpha, tinytc_value_t A, tinytc_value_t B, tinytc_value_t beta, tinytc_value_t C, location const &loc = {})#

GEMV instruction

Parameters:
  • atomic – atomic flag

  • tA – transpose A

  • alpha – alpha scalar

  • A – A tensor

  • B – B tensor

  • beta – beta scalar

  • C – C tensor

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of gemv_inst instruction.

creator<ger_inst>#

template<>
struct creator<ger_inst>#

creator specialization for ger_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(bool atomic, tinytc_value_t alpha, tinytc_value_t A, tinytc_value_t B, tinytc_value_t beta, tinytc_value_t C, location const &loc = {})#

GER instruction

Parameters:
  • atomic – atomic flag

  • alpha – alpha scalar

  • A – A tensor

  • B – B tensor

  • beta – beta scalar

  • C – C tensor

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of ger_inst instruction.

creator<greater_than_equal_inst>#

template<>
struct creator<greater_than_equal_inst>#

creator specialization for greater_than_equal_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Greater than or equal instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of greater_than_equal_inst instruction.

creator<greater_than_inst>#

template<>
struct creator<greater_than_inst>#

creator specialization for greater_than_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Greater instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of greater_than_inst instruction.

creator<group_id_inst>#

template<>
struct creator<group_id_inst>#

creator specialization for group_id_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(comp3 mode, tinytc_type_t result, location const &loc = {})#

Group ID instruction

Parameters:
  • mode – mode

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of group_id_inst instruction.

creator<hadamard_inst>#

template<>
struct creator<hadamard_inst>#

creator specialization for hadamard_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(bool atomic, tinytc_value_t alpha, tinytc_value_t A, tinytc_value_t B, tinytc_value_t beta, tinytc_value_t C, location const &loc = {})#

Hadamard instruction

Parameters:
  • atomic – atomic flag

  • alpha – alpha scalar

  • A – A tensor

  • B – B tensor

  • beta – beta scalar

  • C – C tensor

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of hadamard_inst instruction.

creator<if_inst>#

template<>
struct creator<if_inst>#

creator specialization for if_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t condition, array_view<tinytc_type_t> results, location const &loc = {})#

If instruction

Parameters:
  • condition – condition

  • results – return type array; can be {}

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 2147483647#

Maximum number of results of if_inst instruction.

creator<im_inst>#

template<>
struct creator<im_inst>#

creator specialization for im_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Imaginary part instruction

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of im_inst instruction.

creator<less_than_equal_inst>#

template<>
struct creator<less_than_equal_inst>#

creator specialization for less_than_equal_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Less than or equal instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of less_than_equal_inst instruction.

creator<less_than_inst>#

template<>
struct creator<less_than_inst>#

creator specialization for less_than_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Less than instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of less_than_inst instruction.

creator<lifetime_stop_inst>#

template<>
struct creator<lifetime_stop_inst>#

creator specialization for lifetime_stop_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t object, location const &loc = {})#

Lifetime stop instruction

Parameters:
  • object – stack object whose lifetime ends

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of lifetime_stop_inst instruction.

creator<load_inst>#

template<>
struct creator<load_inst>#

creator specialization for load_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t operand, array_view<tinytc_value_t> index_list, tinytc_type_t result, location const &loc = {})#

Load instruction

Parameters:
  • operand – tensor or group of tensors

  • index_list – indices; can be {}

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of load_inst instruction.

creator<max_inst>#

template<>
struct creator<max_inst>#

creator specialization for max_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Max instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of max_inst instruction.

creator<min_inst>#

template<>
struct creator<min_inst>#

creator specialization for min_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Min instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of min_inst instruction.

creator<mul_inst>#

template<>
struct creator<mul_inst>#

creator specialization for mul_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Multiplication instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of mul_inst instruction.

creator<native_cos_inst>#

template<>
struct creator<native_cos_inst>#

creator specialization for native_cos_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Cosine instruction (native)

Parameters:
  • a – argument

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of native_cos_inst instruction.

creator<native_exp2_inst>#

template<>
struct creator<native_exp2_inst>#

creator specialization for native_exp2_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Base-2 exponential instruction (native)

Parameters:
  • a – argument

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of native_exp2_inst instruction.

creator<native_exp_inst>#

template<>
struct creator<native_exp_inst>#

creator specialization for native_exp_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Base-e exponential instruction (native)

Parameters:
  • a – argument

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of native_exp_inst instruction.

creator<native_sin_inst>#

template<>
struct creator<native_sin_inst>#

creator specialization for native_sin_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Sine instruction (native)

Parameters:
  • a – argument

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of native_sin_inst instruction.

creator<neg_inst>#

template<>
struct creator<neg_inst>#

creator specialization for neg_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Negation instruction

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of neg_inst instruction.

creator<not_equal_inst>#

template<>
struct creator<not_equal_inst>#

creator specialization for not_equal_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Not equal instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of not_equal_inst instruction.

creator<not_inst>#

template<>
struct creator<not_inst>#

creator specialization for not_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Bitwise not instruction

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of not_inst instruction.

creator<num_groups_inst>#

template<>
struct creator<num_groups_inst>#

creator specialization for num_groups_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(comp3 mode, tinytc_type_t result, location const &loc = {})#

Number of groups instruction

Parameters:
  • mode – mode

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of num_groups_inst instruction.

creator<num_subgroups_inst>#

template<>
struct creator<num_subgroups_inst>#

creator specialization for num_subgroups_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(comp3 mode, tinytc_type_t result, location const &loc = {})#

Number of subgroups instruction

Parameters:
  • mode – mode

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of num_subgroups_inst instruction.

creator<or_inst>#

template<>
struct creator<or_inst>#

creator specialization for or_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Bitwise or instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of or_inst instruction.

creator<parallel_inst>#

template<>
struct creator<parallel_inst>#

creator specialization for parallel_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(location const &loc = {})#

Parallel instruction

Parameters:

loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of parallel_inst instruction.

creator<re_inst>#

template<>
struct creator<re_inst>#

creator specialization for re_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Real part instruction

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of re_inst instruction.

creator<rem_inst>#

template<>
struct creator<rem_inst>#

creator specialization for rem_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Remainder instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of rem_inst instruction.

creator<shl_inst>#

template<>
struct creator<shl_inst>#

creator specialization for shl_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Shift-left instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of shl_inst instruction.

creator<shr_inst>#

template<>
struct creator<shr_inst>#

creator specialization for shr_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Shift-right instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of shr_inst instruction.

creator<sin_inst>#

template<>
struct creator<sin_inst>#

creator specialization for sin_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Sine instruction

Parameters:
  • a – argument

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of sin_inst instruction.

creator<size_inst>#

template<>
struct creator<size_inst>#

creator specialization for size_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(std::int64_t mode, tinytc_value_t operand, tinytc_type_t result, location const &loc = {})#

Size instruction

Parameters:
  • mode – mode for which size is extracted

  • operand – tensor

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of size_inst instruction.

creator<store_inst>#

template<>
struct creator<store_inst>#

creator specialization for store_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t val, tinytc_value_t operand, array_view<tinytc_value_t> index_list, location const &loc = {})#

Store instruction

Parameters:
  • val – value to store

  • operand – operand

  • index_list – indices; can be {}

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of store_inst instruction.

creator<sub_inst>#

template<>
struct creator<sub_inst>#

creator specialization for sub_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Subtraction instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of sub_inst instruction.

creator<subgroup_broadcast_inst>#

template<>
struct creator<subgroup_broadcast_inst>#

creator specialization for subgroup_broadcast_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t idx, tinytc_type_t result, location const &loc = {})#

Subgroup broadcast instruction

Parameters:
  • a – operand

  • idx – subgroup local index

  • result – result index

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subgroup_broadcast_inst instruction.

creator<subgroup_exclusive_scan_add_inst>#

template<>
struct creator<subgroup_exclusive_scan_add_inst>#

creator specialization for subgroup_exclusive_scan_add_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Subgroup exclusive scan add

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subgroup_exclusive_scan_add_inst instruction.

creator<subgroup_exclusive_scan_max_inst>#

template<>
struct creator<subgroup_exclusive_scan_max_inst>#

creator specialization for subgroup_exclusive_scan_max_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Subgroup exclusive scan max

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subgroup_exclusive_scan_max_inst instruction.

creator<subgroup_exclusive_scan_min_inst>#

template<>
struct creator<subgroup_exclusive_scan_min_inst>#

creator specialization for subgroup_exclusive_scan_min_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Subgroup exclusive scan min

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subgroup_exclusive_scan_min_inst instruction.

creator<subgroup_id_inst>#

template<>
struct creator<subgroup_id_inst>#

creator specialization for subgroup_id_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(comp3 mode, tinytc_type_t result, location const &loc = {})#

Subgroup id instruction

Parameters:
  • mode – mode

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subgroup_id_inst instruction.

creator<subgroup_inclusive_scan_add_inst>#

template<>
struct creator<subgroup_inclusive_scan_add_inst>#

creator specialization for subgroup_inclusive_scan_add_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Subgroup inclusive scan add

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subgroup_inclusive_scan_add_inst instruction.

creator<subgroup_inclusive_scan_max_inst>#

template<>
struct creator<subgroup_inclusive_scan_max_inst>#

creator specialization for subgroup_inclusive_scan_max_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Subgroup inclusive scan max

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subgroup_inclusive_scan_max_inst instruction.

creator<subgroup_inclusive_scan_min_inst>#

template<>
struct creator<subgroup_inclusive_scan_min_inst>#

creator specialization for subgroup_inclusive_scan_min_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Subgroup inclusive scan min

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subgroup_inclusive_scan_min_inst instruction.

creator<subgroup_linear_id_inst>#

template<>
struct creator<subgroup_linear_id_inst>#

creator specialization for subgroup_linear_id_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_type_t result, location const &loc = {})#

Subgroup linear id instruction

Parameters:
  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subgroup_linear_id_inst instruction.

creator<subgroup_local_id_inst>#

template<>
struct creator<subgroup_local_id_inst>#

creator specialization for subgroup_local_id_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_type_t result, location const &loc = {})#

Subgroup local id instruction

Parameters:
  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subgroup_local_id_inst instruction.

creator<subgroup_reduce_add_inst>#

template<>
struct creator<subgroup_reduce_add_inst>#

creator specialization for subgroup_reduce_add_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Subgroup reduce add

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subgroup_reduce_add_inst instruction.

creator<subgroup_reduce_max_inst>#

template<>
struct creator<subgroup_reduce_max_inst>#

creator specialization for subgroup_reduce_max_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Subgroup reduce max

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subgroup_reduce_max_inst instruction.

creator<subgroup_reduce_min_inst>#

template<>
struct creator<subgroup_reduce_min_inst>#

creator specialization for subgroup_reduce_min_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_type_t result, location const &loc = {})#

Subgroup reduce min

Parameters:
  • a – operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subgroup_reduce_min_inst instruction.

creator<subgroup_size_inst>#

template<>
struct creator<subgroup_size_inst>#

creator specialization for subgroup_size_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_type_t result, location const &loc = {})#

Subgroup size instruction

Parameters:
  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subgroup_size_inst instruction.

creator<subview_inst>#

template<>
struct creator<subview_inst>#

creator specialization for subview_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(array_view<std::int64_t> static_offsets, array_view<std::int64_t> static_sizes, tinytc_value_t operand, array_view<tinytc_value_t> offsets, array_view<tinytc_value_t> sizes, tinytc_type_t result, location const &loc = {})#

Subview instruction

Parameters:
  • static_offsets – static offsets (need to add value to dynamic offsets if static_offsets[i] == TINYTC_DYNAMIC); can be {}

  • static_sizes – static sizes (need to add value to dynamic sizes if static_sizes[i] == TINYTC_DYNAMIC); can be {}

  • operand – operand

  • offsets – dynamic offsets; can be {}

  • sizes – dynamic sizes; can be {}

  • result – resulting memref type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of subview_inst instruction.

creator<sum_inst>#

template<>
struct creator<sum_inst>#

creator specialization for sum_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(bool atomic, transpose tA, tinytc_value_t alpha, tinytc_value_t A, tinytc_value_t beta, tinytc_value_t B, location const &loc = {})#

Sum instruction

Parameters:
  • atomic – atomic flag

  • tA – transpose A

  • alpha – alpha scalar

  • A – A tensor

  • beta – beta scalar

  • B – B tensor

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of sum_inst instruction.

creator<xor_inst>#

template<>
struct creator<xor_inst>#

creator specialization for xor_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, location const &loc = {})#

Bitwise xor instruction

Parameters:
  • a – left-hand operand

  • b – right-hand operand

  • result – result type

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 1#

Maximum number of results of xor_inst instruction.

creator<yield_inst>#

template<>
struct creator<yield_inst>#

creator specialization for yield_inst

Public Functions

inline unique_handle<tinytc_inst_t> operator()(array_view<tinytc_value_t> yielded_vals, location const &loc = {})#

Yield instruction

Parameters:
  • yielded_vals – yielded values; can be {}

  • loc – Source code location; can be {}

Returns:

Instruction

Public Static Attributes

static std::int32_t max_returned_values = 0#

Maximum number of results of yield_inst instruction.

Program#

Program Functions#

add_function#

inline void tinytc::add_function(tinytc_prog_t prg, unique_handle<tinytc_func_t> &&fun)#

Append function to program.

Parameters:
  • prg – program

  • fun – function

create_prog#

inline shared_handle<tinytc_prog_t> tinytc::create_prog(tinytc_compiler_context_t ctx, location const &loc = {})#

Create program.

Parameters:
  • ctx – Compiler context

  • loc – Source code location

Returns:

Program

Recipe#

Recipe Functions#

create_small_gemm_batched#

inline shared_handle<tinytc_recipe_t> tinytc::create_small_gemm_batched(tinytc_core_info_t info, tinytc_type_t number_ty, transpose tA, transpose tB, std::int64_t M, std::int64_t N, std::int64_t K, std::int64_t ldA, std::int64_t strideA, std::int64_t ldB, std::int64_t strideB, std::int64_t ldC, std::int64_t strideC)#

Create small GEMM batched recipe.

Cf. tinytc_recipe_small_gemm_batched_create

Parameters:
  • info – Core info

  • number_ty – Number type of \(\alpha\), A, B, \(\beta\), C

  • tA – Operation applied on A

  • tB – Operation applied on B

  • M – Number of rows of A and C

  • N – Number of columns of B and C

  • K – Number of columns of A, number of rows of B

  • ldA – Leading dimension of an A matrix

  • strideA – Stride of A-matrices

  • ldB – Leading dimension of an B matrix

  • strideB – Stride of B-matrices

  • ldC – Leading dimension of an C matrix

  • strideC – Stride of C-matrices

Returns:

Small GEMM batched recipe

create_tall_and_skinny#

inline shared_handle<tinytc_recipe_t> tinytc::create_tall_and_skinny(tinytc_core_info_t info, tinytc_type_t number_ty, std::int64_t N, std::int64_t K, std::int32_t M_block_size = 0)#

Create tall and skinny recipe.

Cf. tinytc_recipe_tall_and_skinny_create

Parameters:
  • info – Core info

  • number_ty – Number type of \(\alpha\), A, B, \(\beta\), C

  • N – Number of columns of B and C

  • K – Number of columns of A, number of rows of B

  • M_block_size – Chunk size for M-mode

Returns:

Tall and skinny recipe

create_tall_and_skinny_specialized#

inline shared_handle<tinytc_recipe_t> tinytc::create_tall_and_skinny_specialized(tinytc_core_info_t info, tinytc_type_t number_ty, std::int64_t M, std::int64_t N, std::int64_t K, std::int64_t ldA, std::int64_t ldB, std::int64_t ldC, std::int32_t alignA, std::int32_t alignB, std::int32_t alignC, std::int32_t M_block_size = 0)#

Create tall and skinny recipe with additional specialization constants.

Cf. tinytc_recipe_tall_and_skinny_create_specialized

Parameters:
  • info – Core info

  • number_ty – Number type of \(\alpha\), A, B, \(\beta\), C

  • M – Number of rows of A and C; can be dynamic

  • N – Number of columns of B and C

  • K – Number of columns of A, number of rows of B

  • ldA – Leading dimension of A; can be dynamic

  • ldB – Leading dimension of B; can be dynamic

  • ldC – Leading dimension of C; can be dynamic

  • alignA – [in] Memory alignment of A; can be 0

  • alignB – [in] Memory alignment of B; can be 0

  • alignC – [in] Memory alignment of C; can be 0

  • M_block_size – Chunk size for M-mode

Returns:

Tall and skinny recipe

get_prog#

inline shared_handle<tinytc_prog_t> tinytc::get_prog(const_tinytc_recipe_t rec)#

Get program.

Parameters:

rec – Recipe

Returns:

Program

get_binary#

inline shared_handle<tinytc_binary_t> tinytc::get_binary(const_tinytc_recipe_t rec)#

Get binary.

Parameters:

rec – Recipe

Returns:

Binary

get_recipe#

inline shared_handle<tinytc_recipe_t> tinytc::get_recipe(const_tinytc_recipe_handler_t handler)#

Get recipe.

Parameters:

handler – Recipe handler

Returns:

Recipe

set_small_gemm_batched_args#

template<typename T>
static void tinytc::set_small_gemm_batched_args(tinytc_recipe_handler_t handler, std::int64_t howmany, T alpha, mem A, mem B, T beta, mem C)#

Set kernel arguments.

Template Parameters:

T – Scalar type; must match scalar_type passed to constructor

Parameters:
  • handler – Recipe handler

  • howmany – Batch size

  • alpha\(\alpha\)

  • A – Memory object used for A-matrix

  • B – Memory object used for B-matrix

  • beta\(\beta\)

  • C – Memory object used for C-matrix

set_tall_and_skinny_args#

template<typename T>
static void tinytc::set_tall_and_skinny_args(tinytc_recipe_handler_t handler, std::int64_t M, T alpha, mem A, std::int64_t ldA, mem B, std::int64_t ldB, T beta, mem C, std::int64_t ldC)#

Set kernel arguments.

Template Parameters:

T – Scalar type; must match scalar_type passed to constructor

Parameters:
  • handler – Recipe handler

  • M – Number of rows of A and C

  • alpha\(\alpha\)

  • A – Memory object used for A-matrix

  • ldA – Leading dimension of A

  • B – Memory object used for B-matrix

  • ldB – Leading dimension of B

  • beta\(\beta\)

  • C – Memory object used for C-matrix

  • ldC – Leading dimension of C

Region#

Region Classes#

region_builder#

class region_builder#

Builder for regions.

Public Functions

inline region_builder(tinytc_region_t reg)#

ctor

Parameters:

reg – region object

inline region_builder(tinytc_region_t reg, tinytc_inst_iterator_t ip)#

ctor

Parameters:
  • reg – region object

  • ip – insertion point

inline tinytc_inst_iterator_t get_insertion_point() const#

Get insertion point.

Returns:

Iterator

inline tinytc_value_t add(unique_handle<tinytc_inst_t> &&i)#

Add instruction.

Parameters:

i – Instruction

Returns:

Value returned by instruction; may be empty

inline std::vector<tinytc_value_t> add_multivalued(unique_handle<tinytc_inst_t> &&i)#

Add instruction that returns multiple values.

Parameters:

i – Instruction

Returns:

Values returned by instruction

template<typename T, typename ...Args>
inline auto create(Args&&... args)#

Create and add instruction.

Parameters:

args – Arguments forwarded to creator

Returns:

Type is either void (T::num_returned_values==0), value (T::num_returned_values==1), or std::vector<tinytc_value_t> (T::num_returned_values>1)

inline tinytc_value_t constant_one(tinytc_type_t ty, location const &loc = {})#

Create multiplicative identity constant (“1”) for the given data type.

Parameters:
  • ty – Scalar data type

  • loc – Source code location

Returns:

Value returned by instruction

inline tinytc_value_t constant_zero(tinytc_type_t ty, location const &loc = {})#

Create additive identity constant (“0”) for the given data type.

Parameters:
  • ty – Scalar data type

  • loc – Source code location

Returns:

Value returned by instruction

template<typename F>
inline void for_loop(tinytc_value_t from, tinytc_value_t to, F &&f, tinytc_attr_t attributes = nullptr, location const &loc = {})#

Build for-loop with functor f(region_builder&, value) -> void.

The loop trip count is passed as second argument to the functor.

Template Parameters:

F – Functor type

Parameters:
  • from – Loop variable start

  • to – Loop variable bound

  • f – Functor

  • attributes – For attributes

  • loc – Source code location

template<typename F>
inline void for_loop(tinytc_value_t from, tinytc_value_t to, tinytc_value_t step, F &&f, tinytc_attr_t attributes = nullptr, location const &loc = {})#

Build for-loop with functor f(region_builder&, value) -> void.

The loop trip count is passed as second argument to the functor.

Template Parameters:

F – Functor type

Parameters:
  • from – Loop variable start

  • to – Loop variable bound

  • step – Loop variable step

  • f – Functor

  • attributes – For attributes

  • loc – Source code location

template<typename F>
inline std::vector<tinytc_value_t> for_loop(tinytc_value_t from, tinytc_value_t to, tinytc_value_t step, array_view<tinytc_value_t> initial_value_list, array_view<tinytc_type_t> return_type_list, F &&f, tinytc_attr_t attributes = nullptr, location const &loc = {})#

Build for-loop with functor f(region_builder&, array_view<tinytc_value_t>) -> void.

The loop trip count is the first value in the array_view. The following values are the loop-carried values.

Template Parameters:

F – Functor type

Parameters:
  • from – Loop variable start

  • to – Loop variable bound

  • step – Loop variable step

  • initial_value_list – Array of initial values; can be {}

  • return_type_list – Array of return types; can be {}

  • f – Functor

  • attributes – For attributes

  • loc – Source code location

template<typename F>
inline void foreach_loop(array_view<tinytc_value_t> from, array_view<tinytc_value_t> to, F &&f, location const &loc = {})#

Build foreach-loop with functor f(region_builder&, array_view<tinytc_value_t>) -> void.

Template Parameters:

F – Functor type

Parameters:
  • from – Loop variable start list

  • to – Loop variable bound list

  • f – functor

  • loc – Source code location

template<typename F>
inline void foreach_tile_loop(array_view<std::int64_t> tile_shape, array_view<tinytc_value_t> from, array_view<tinytc_value_t> to, F &&f, location const &loc = {})#

Build foreach-loop with functor f(region_builder&, array_view<tinytc_value_t>,

array_view<tinytc_value_t>) -> void.

Template Parameters:

F – Functor type

Parameters:
  • tile_shape – Tile shape

  • from – Loop variable start list

  • to – Loop variable bound list

  • f – functor (1. region builder, 2. tile offset, 3. size)

  • loc – Source code location

template<typename F>
inline void if_condition(tinytc_value_t condition, F &&then, location const &loc = {})#

Build if with functor then(region_builder&) -> void.

Note: If the if instruction returns values then we must have a “yield” instruction in both the “then” and the “else” branch. So to return values use the “ifelse” function.

Template Parameters:

F – Functor type

Parameters:
  • condition – Condition value

  • then – Then region functor

  • loc – Source code location

template<typename F, typename G>
inline std::vector<tinytc_value_t> ifelse(tinytc_value_t condition, F &&then, G &&otherwise, array_view<tinytc_type_t> return_type_list = {}, location const &loc = {})#

Build if/else with functors then(region_builder&) -> void and otherwise(region_builder&) -> void.

Template Parameters:
  • F – “if” functor type

  • G – “else” functor type

Parameters:
  • condition – If condition

  • then – “if” functor

  • otherwise – “else” functor

  • return_type_list – List of types of returned values

  • loc – Source code location

Returns:

Returned values

inline tinytc_region_t get_region()#

Get region.

Returns:

Region

Region Functions#

append#

inline void tinytc::append(tinytc_region_t reg, unique_handle<tinytc_inst_t> &&instruction)#

Append instruction to region.

Parameters:
  • reg – Region

  • instruction – instruction object

begin#

inline tinytc_inst_iterator_t tinytc::begin(tinytc_region_t reg)#

Get iterator pointing to the begin of the region.

Parameters:

reg – Region

Returns:

iterator

end#

inline tinytc_inst_iterator_t tinytc::end(tinytc_region_t reg)#

Get iterator pointing to past the end of the region.

Parameters:

reg – Region

Returns:

iterator

get_parameters#

inline std::size_t tinytc::get_parameters(tinytc_region_t reg, mutable_array_view<tinytc_value_t> params)#

Get region parameters.

May be called with empty view (vals = {}) to get the number of parameters.

Parameters:
  • reg – Region

  • params – view on buffer that stores parameters

Returns:

Minimum of view size and actual number of parameters

insert#

inline tinytc_inst_iterator_t tinytc::insert(tinytc_region_t reg, tinytc_inst_iterator_t iterator, unique_handle<tinytc_inst_t> &&instruction)#

Insert instruction into region before the iterator.

Parameters:
  • reg – Region

  • iterator – Iterator

  • instruction – instruction object

Returns:

Iterator pointing to the newly inserted instruction

next#

inline void tinytc::next(tinytc_inst_iterator_t &iterator)#

Move iterator to next instruction.

Parameters:

iterator

prev#

inline void tinytc::prev(tinytc_inst_iterator_t &iterator)#

Move iterator to previous instruction.

Parameters:

iterator