Builder C-API

Contents

Builder C-API#

Common#

Common Definitions#

TINYTC_DYNAMIC#

TINYTC_DYNAMIC INT64_MIN#

Common Structures#

tinytc_named_attr#

struct tinytc_named_attr#

Named attribute.

Public Members

tinytc_attr_t name#

Name stored as string attribute.

tinytc_attr_t attr#

Attribute.

tinytc_location#

struct tinytc_location#

Source code location.

Public Members

tinytc_position_t begin#

Starting position.

tinytc_position_t end#

End position.

tinytc_position#

struct tinytc_position#

Source code position.

Public Members

int32_t source_id#

Source file identifier; 0 is “unknown source”.

int32_t line#

Line number; counting starts at 1.

int32_t column#

Column number; counting start at 1.

Common Typedefs#

tinytc_attr_t#

typedef struct tinytc_attr *tinytc_attr_t#

attribute handle

tinytc_func_t#

typedef struct tinytc_func *tinytc_func_t#

func handle

tinytc_named_attr_t#

typedef struct tinytc_named_attr tinytc_named_attr_t#

Named attribute.

tinytc_location_t#

typedef struct tinytc_location tinytc_location_t#

Source code location.

tinytc_position_t#

typedef struct tinytc_position tinytc_position_t#

Source code position.

tinytc_inst_t#

typedef struct tinytc_inst *tinytc_inst_t#

inst handle

tinytc_inst_iterator_t#

typedef struct tinytc_inst *tinytc_inst_iterator_t#

inst iterator handle

tinytc_region_t#

typedef struct tinytc_region *tinytc_region_t#

region handle

tinytc_type_t#

typedef struct tinytc_type *tinytc_type_t#

type handle

tinytc_value_t#

typedef struct tinytc_value *tinytc_value_t#

value handle

const_tinytc_attr_t#

typedef const struct tinytc_attr *const_tinytc_attr_t#

const attribute handle

const_tinytc_func_t#

typedef const struct tinytc_func *const_tinytc_func_t#

const func handle

const_tinytc_inst_t#

typedef const struct tinytc_inst *const_tinytc_inst_t#

const inst handle

const_tinytc_region_t#

typedef const struct tinytc_region *const_tinytc_region_t#

const region handle

const_tinytc_type_t#

typedef const struct tinytc_type *const_tinytc_type_t#

const type handle

const_tinytc_value_t#

typedef const struct tinytc_value *const_tinytc_value_t#

const value handle

Attribute#

Attribute Functions#

tinytc_array_attr_get#

tinytc_status_t tinytc_array_attr_get(tinytc_attr_t *attr, tinytc_compiler_context_t ctx, size_t array_size, const tinytc_attr_t *array)#

Get array attribute.

Parameters:
  • attr – [out] pointer to the attribute object

  • ctx – [inout] compiler context

  • array_size – [in] number of elements in array, must be 0 if array == nullptr

  • array – [in][range(0, array_size)] attribute array

Returns:

tinytc_status_success on success and error otherwise

tinytc_boolean_attr_get#

tinytc_status_t tinytc_boolean_attr_get(tinytc_attr_t *attr, tinytc_compiler_context_t ctx, tinytc_bool_t value)#

Get boolean attribute.

Parameters:
  • attr – [out] pointer to the attribute object

  • ctx – [inout] compiler context

  • value – [in] value of attribute

Returns:

tinytc_status_success on success and error otherwise

tinytc_dictionary_attr_get#

tinytc_status_t tinytc_dictionary_attr_get(tinytc_attr_t *attr, tinytc_compiler_context_t ctx, size_t items_size, tinytc_named_attr_t *items)#

Get dictionary attribute.

Each name must only appear once.

Parameters:
  • attr – [out] pointer to the attribute object

  • ctx – [inout] compiler context

  • items_size – [in] number of elements in items array, must be 0 if items == nullptr

  • items – [in][range(0, items_size)] array of items

Returns:

tinytc_status_success on success and error otherwise

tinytc_dictionary_attr_get_with_sorted#

tinytc_status_t tinytc_dictionary_attr_get_with_sorted(tinytc_attr_t *attr, tinytc_compiler_context_t ctx, size_t items_size, const tinytc_named_attr_t *items)#

Get dictionary attribute with pre-sorted items.

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

Parameters:
  • attr – [out] pointer to the attribute object

  • ctx – [inout] compiler context

  • items_size – [in] number of elements in items array, must be 0 if items == nullptr

  • items – [in][range(0, items_size)] array of items

Returns:

tinytc_status_success on success and error otherwise

tinytc_dictionary_attr_sort#

tinytc_status_t tinytc_dictionary_attr_sort(size_t items_size, tinytc_named_attr_t *items)#

Sort items array by name.

Parameters:
  • items_size – [in] number of elements in items array, must be 0 if items == nullptr

  • items – [in][range(0, items_size)] array of items

Returns:

tinytc_status_success on success and error otherwise

tinytc_integer_attr_get#

tinytc_status_t tinytc_integer_attr_get(tinytc_attr_t *attr, tinytc_compiler_context_t ctx, int64_t value)#

Get integer attribute.

Parameters:
  • attr – [out] pointer to the attribute object

  • ctx – [inout] compiler context

  • value – [in] value of attribute

Returns:

tinytc_status_success on success and error otherwise

tinytc_string_attr_get#

tinytc_status_t tinytc_string_attr_get(tinytc_attr_t *attr, tinytc_compiler_context_t ctx, size_t str_length, char const *str)#

Get string attribute.

Parameters:
  • attr – [out] pointer to the attribute object

  • ctx – [inout] compiler context

  • str_length – [in] number of characters (not including a null terminator)

  • str – [in] string; not necessarily null-terminated

Returns:

tinytc_status_success on success and error otherwise

Data Type#

Data Type Functions#

tinytc_type_get_compiler_context#

tinytc_status_t tinytc_type_get_compiler_context(const_tinytc_type_t ty, tinytc_compiler_context_t *ctx)#

Get context object from type object.

The reference count of the context remains unchanged.

Parameters:
  • ty – [in] type object

  • ctx – [out] pointer to context object

Returns:

tinytc_status_success on success and error otherwise

Data Type Builder#

Data Type Builder Functions#

tinytc_boolean_type_get#

tinytc_status_t tinytc_boolean_type_get(tinytc_type_t *ty_, tinytc_compiler_context_t ctx)#

Bool type

Parameters:
  • ty_ – [out] pointer to the type object created

  • ctx – [in] compiler context

Returns:

tinytc_status_success on success and error otherwise

tinytc_i8_type_get#

tinytc_status_t tinytc_i8_type_get(tinytc_type_t *ty_, tinytc_compiler_context_t ctx)#

Signed 8 bit integer type

Parameters:
  • ty_ – [out] pointer to the type object created

  • ctx – [in] compiler context

Returns:

tinytc_status_success on success and error otherwise

tinytc_i16_type_get#

tinytc_status_t tinytc_i16_type_get(tinytc_type_t *ty_, tinytc_compiler_context_t ctx)#

Signed 16 bit integer type

Parameters:
  • ty_ – [out] pointer to the type object created

  • ctx – [in] compiler context

Returns:

tinytc_status_success on success and error otherwise

tinytc_i32_type_get#

tinytc_status_t tinytc_i32_type_get(tinytc_type_t *ty_, tinytc_compiler_context_t ctx)#

Signed 32 bit integer type

Parameters:
  • ty_ – [out] pointer to the type object created

  • ctx – [in] compiler context

Returns:

tinytc_status_success on success and error otherwise

tinytc_i64_type_get#

tinytc_status_t tinytc_i64_type_get(tinytc_type_t *ty_, tinytc_compiler_context_t ctx)#

Signed 64 bit integer type

Parameters:
  • ty_ – [out] pointer to the type object created

  • ctx – [in] compiler context

Returns:

tinytc_status_success on success and error otherwise

tinytc_index_type_get#

tinytc_status_t tinytc_index_type_get(tinytc_type_t *ty_, tinytc_compiler_context_t ctx)#

Integer type for indices

Parameters:
  • ty_ – [out] pointer to the type object created

  • ctx – [in] compiler context

Returns:

tinytc_status_success on success and error otherwise

tinytc_bf16_type_get#

tinytc_status_t tinytc_bf16_type_get(tinytc_type_t *ty_, tinytc_compiler_context_t ctx)#

Brain floating point (16 bit)

Parameters:
  • ty_ – [out] pointer to the type object created

  • ctx – [in] compiler context

Returns:

tinytc_status_success on success and error otherwise

tinytc_f16_type_get#

tinytc_status_t tinytc_f16_type_get(tinytc_type_t *ty_, tinytc_compiler_context_t ctx)#

Half precision floating point (16 bit)

Parameters:
  • ty_ – [out] pointer to the type object created

  • ctx – [in] compiler context

Returns:

tinytc_status_success on success and error otherwise

tinytc_f32_type_get#

tinytc_status_t tinytc_f32_type_get(tinytc_type_t *ty_, tinytc_compiler_context_t ctx)#

Single precision floating point (32 bit)

Parameters:
  • ty_ – [out] pointer to the type object created

  • ctx – [in] compiler context

Returns:

tinytc_status_success on success and error otherwise

tinytc_f64_type_get#

tinytc_status_t tinytc_f64_type_get(tinytc_type_t *ty_, tinytc_compiler_context_t ctx)#

Double precision floating point (64 bit)

Parameters:
  • ty_ – [out] pointer to the type object created

  • ctx – [in] compiler context

Returns:

tinytc_status_success on success and error otherwise

tinytc_c32_type_get#

tinytc_status_t tinytc_c32_type_get(tinytc_type_t *ty_, tinytc_compiler_context_t ctx)#

Single precision floating point (32 bit)

Parameters:
  • ty_ – [out] pointer to the type object created

  • ctx – [in] compiler context

Returns:

tinytc_status_success on success and error otherwise

tinytc_c64_type_get#

tinytc_status_t tinytc_c64_type_get(tinytc_type_t *ty_, tinytc_compiler_context_t ctx)#

Double precision floating point (64 bit)

Parameters:
  • ty_ – [out] pointer to the type object created

  • ctx – [in] compiler context

Returns:

tinytc_status_success on success and error otherwise

tinytc_coopmatrix_type_get#

tinytc_status_t tinytc_coopmatrix_type_get(tinytc_type_t *ty_, tinytc_type_t component_ty, int64_t rows, int64_t cols, tinytc_matrix_use_t use)#

Coopmatrix type

Parameters:
  • ty_ – [out] pointer to the type object created

  • component_ty – [in] component type

  • rows – [in] number of rows

  • cols – [in] number of columns

  • use – [in] matrix use

Returns:

tinytc_status_success on success and error otherwise

tinytc_group_type_get#

tinytc_status_t tinytc_group_type_get(tinytc_type_t *ty_, tinytc_type_t element_ty, int64_t size, int64_t offset)#

Group type

Parameters:
  • ty_ – [out] pointer to the type object created

  • element_ty – [in] element type

  • size – [in] group size

  • offset – [in] offset added on element access

Returns:

tinytc_status_success on success and error otherwise

tinytc_memref_type_get#

tinytc_status_t tinytc_memref_type_get(tinytc_type_t *ty_, tinytc_type_t element_ty, size_t shape_size, const int64_t *shape, size_t stride_size, const int64_t *stride, tinytc_address_space_t addrspace)#

Memref type

Parameters:
  • ty_ – [out] pointer to the type object created

  • element_ty – [in] element type

  • shape_size – [in] array size of shape

  • shape – [in][range(0, shape_size)] tensor shape; may be nullptr if shape_size is 0

  • stride_size – [in] array size of stride

  • stride – [in][range(0, stride_size)] tensor stride; may be nullptr if stride_size is 0

  • addrspace – [in] address space

Returns:

tinytc_status_success on success and error otherwise

tinytc_void_type_get#

tinytc_status_t tinytc_void_type_get(tinytc_type_t *ty_, tinytc_compiler_context_t ctx)#

Void type

Parameters:
  • ty_ – [out] pointer to the type object created

  • ctx – [in] compiler context

Returns:

tinytc_status_success on success and error otherwise

Function#

Function Functions#

tinytc_func_create#

tinytc_status_t tinytc_func_create(tinytc_func_t *fun, size_t name_length, char const *name, size_t num_params, const tinytc_type_t *param_type_list, tinytc_type_t ty, const tinytc_location_t *loc)#

Create function.

Function takes ownership of region.

Parameters:
  • fun – [out] pointer to the func object created

  • name_length – [in] length of function_name

  • name – [in] function name

  • num_params – [in] number of parameters

  • param_type_list – [in][range(0,num_params)] parameter data types; can be nullptr if num_params is 0

  • ty – [in] result type (must be void for host-callable function)

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_func_destroy#

void tinytc_func_destroy(tinytc_func_t fun)#

Delete function object.

Parameters:
  • fun – [inout] function object

tinytc_func_get_body#

tinytc_status_t tinytc_func_get_body(tinytc_func_t fun, tinytc_region_t *body)#

Get function body.

Parameters:
  • fun – [in] function object

  • body – [out] pointer to body region

Returns:

tinytc_status_success on success and error otherwise

tinytc_func_set_attr#

tinytc_status_t tinytc_func_set_attr(tinytc_func_t fun, tinytc_attr_t a)#

Set function attributes.

Parameters:
  • fun – [inout] function object

  • a – [in] attribute dictionary

Returns:

tinytc_status_success on success and error otherwise

tinytc_func_set_parameter_attr#

tinytc_status_t tinytc_func_set_parameter_attr(tinytc_func_t fun, size_t param_no, tinytc_attr_t a)#

Set parameter attributes.

Parameters:
  • fun – [in] function object

  • param_no – [in] paramater number (0 to num_parameters-1)

  • a – [in] attribute dictionary

Returns:

tinytc_status_success on success and error otherwise

Instruction#

Instruction Functions#

tinytc_inst_get_parent_region#

tinytc_status_t tinytc_inst_get_parent_region(tinytc_inst_t instr, tinytc_region_t *parent)#

Get parent region of instruction.

Parameters:
  • instr – [in] inst object

  • parent – [out] parent region

Returns:

tinytc_status_success on success and error otherwise

tinytc_inst_get_regions#

tinytc_status_t tinytc_inst_get_regions(tinytc_inst_t instr, size_t *result_list_size, tinytc_region_t *result_list)#

Get child regions of instruction.

Function can be called with result_list_size = 0 and result_list = nullptr in order to obtain the number of results

Parameters:
  • instr – [in] inst object

  • result_list_size – [inout] pointer to the number of results; if result_list_size is 0, then it is updated with the number of results; if result_list_size is greater than the number of results, the value is updated with the correct number of results

  • result_list – [out][range(0, result_list_size)] user-provided memory for storing result handles; at most result_list_size values are written; can be nullptr if result_list_size is 0

Returns:

tinytc_status_success on success and error otherwise

tinytc_inst_get_values#

tinytc_status_t tinytc_inst_get_values(tinytc_inst_t instr, size_t *result_list_size, tinytc_value_t *result_list)#

Get values produced by instruction.

Function can be called with result_list_size = 0 and result_list = nullptr in order to obtain the number of results

Parameters:
  • instr – [in] inst object

  • result_list_size – [inout] pointer to the number of results; if result_list_size is 0, then it is updated with the number of results; if result_list_size is greater than the number of results, the value is updated with the correct number of results

  • result_list – [out][range(0, result_list_size)] user-provided memory for storing result handles; at most result_list_size values are written; can be nullptr if result_list_size is 0

Returns:

tinytc_status_success on success and error otherwise

tinytc_inst_destroy#

void tinytc_inst_destroy(tinytc_inst_t instr)#

Delete inst object.

Parameters:
  • instr – [inout] inst object

tinytc_inst_set_attr#

tinytc_status_t tinytc_inst_set_attr(tinytc_inst_t instr, tinytc_attr_t a)#

Set instruction attributes.

Parameters:
  • instr – [inout] inst object

  • a – [in] attribute object (dictionary attribute)

Returns:

tinytc_status_success on success and error otherwise

Instruction Builder#

Instruction Builder Functions#

tinytc_abs_inst_create#

tinytc_status_t tinytc_abs_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Absolute value instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_add_inst_create#

tinytc_status_t tinytc_add_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Addition instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_alloca_inst_create#

tinytc_status_t tinytc_alloca_inst_create(tinytc_inst_t *instr, tinytc_type_t result, const tinytc_location_t *loc)#

Alloca instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • result – [in] memref type of allocated variable

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_and_inst_create#

tinytc_status_t tinytc_and_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Bitwise and instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_atomic_add_inst_create#

tinytc_status_t tinytc_atomic_add_inst_create(tinytc_inst_t *instr, tinytc_memory_scope_t scope, tinytc_memory_semantics_t semantics, tinytc_value_t val, tinytc_value_t operand, size_t index_list_size, const tinytc_value_t *index_list, tinytc_type_t result, const tinytc_location_t *loc)#

Atomic add instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • scope – [in] memory scope

  • semantics – [in] memory semantics

  • val – [in] value to store

  • operand – [in] operand

  • index_list_size – [in] array size of index_list

  • index_list – [in][range(0, index_list_size)] indices; may be nullptr if index_list_size is 0

  • result – [in] atomically updated value

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_atomic_load_inst_create#

tinytc_status_t tinytc_atomic_load_inst_create(tinytc_inst_t *instr, tinytc_memory_scope_t scope, tinytc_memory_semantics_t semantics, tinytc_value_t operand, size_t index_list_size, const tinytc_value_t *index_list, tinytc_type_t result, const tinytc_location_t *loc)#

Atomic load instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • scope – [in] memory scope

  • semantics – [in] memory semantics

  • operand – [in] tensor or group of tensors

  • index_list_size – [in] array size of index_list

  • index_list – [in][range(0, index_list_size)] indices; may be nullptr if index_list_size is 0

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_atomic_max_inst_create#

tinytc_status_t tinytc_atomic_max_inst_create(tinytc_inst_t *instr, tinytc_memory_scope_t scope, tinytc_memory_semantics_t semantics, tinytc_value_t val, tinytc_value_t operand, size_t index_list_size, const tinytc_value_t *index_list, tinytc_type_t result, const tinytc_location_t *loc)#

Atomic max instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • scope – [in] memory scope

  • semantics – [in] memory semantics

  • val – [in] value to store

  • operand – [in] operand

  • index_list_size – [in] array size of index_list

  • index_list – [in][range(0, index_list_size)] indices; may be nullptr if index_list_size is 0

  • result – [in] atomically updated value

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_atomic_min_inst_create#

tinytc_status_t tinytc_atomic_min_inst_create(tinytc_inst_t *instr, tinytc_memory_scope_t scope, tinytc_memory_semantics_t semantics, tinytc_value_t val, tinytc_value_t operand, size_t index_list_size, const tinytc_value_t *index_list, tinytc_type_t result, const tinytc_location_t *loc)#

Atomic min instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • scope – [in] memory scope

  • semantics – [in] memory semantics

  • val – [in] value to store

  • operand – [in] operand

  • index_list_size – [in] array size of index_list

  • index_list – [in][range(0, index_list_size)] indices; may be nullptr if index_list_size is 0

  • result – [in] atomically updated value

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_atomic_store_inst_create#

tinytc_status_t tinytc_atomic_store_inst_create(tinytc_inst_t *instr, tinytc_memory_scope_t scope, tinytc_memory_semantics_t semantics, tinytc_value_t val, tinytc_value_t operand, size_t index_list_size, const tinytc_value_t *index_list, const tinytc_location_t *loc)#

Atomic store instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • scope – [in] memory scope

  • semantics – [in] memory semantics

  • val – [in] value to store

  • operand – [in] operand

  • index_list_size – [in] array size of index_list

  • index_list – [in][range(0, index_list_size)] indices; may be nullptr if index_list_size is 0

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_axpby_inst_create#

tinytc_status_t tinytc_axpby_inst_create(tinytc_inst_t *instr, tinytc_bool_t atomic, tinytc_transpose_t tA, tinytc_value_t alpha, tinytc_value_t A, tinytc_value_t beta, tinytc_value_t B, const tinytc_location_t *loc)#

AXPBY instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • atomic – [in] atomic flag

  • tA – [in] transpose A

  • alpha – [in] alpha scalar

  • A – [in] A tensor

  • beta – [in] beta scalar

  • B – [in] B tensor

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_barrier_inst_create#

tinytc_status_t tinytc_barrier_inst_create(tinytc_inst_t *instr, tinytc_address_spaces_t fence_flags, const tinytc_location_t *loc)#

Barrier instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • fence_flags – [in] address space(s) of memory fence; set to 0 for no fence

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cast_inst_create#

tinytc_status_t tinytc_cast_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Cast instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] target type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_conj_inst_create#

tinytc_status_t tinytc_conj_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Complex conjugate instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_constant_inst_create_boolean#

tinytc_status_t tinytc_constant_inst_create_boolean(tinytc_inst_t *instr, tinytc_bool_t value, tinytc_type_t ty, const tinytc_location_t *loc)#

Create boolean constant instruction.

Parameters:
  • instr – [out] pointer to the inst object created

  • value – [in] constant value

  • ty – [in] type of constant

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_constant_inst_create_complex#

tinytc_status_t tinytc_constant_inst_create_complex(tinytc_inst_t *instr, double value_re, double value_im, tinytc_type_t ty, const tinytc_location_t *loc)#

Create complex constant instruction.

Parameters:
  • instr – [out] pointer to the inst object created

  • value_re – [in] constant value (real part)

  • value_im – [in] constant value (imaginary part)

  • ty – [in] type of constant

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_constant_inst_create_float#

tinytc_status_t tinytc_constant_inst_create_float(tinytc_inst_t *instr, double value, tinytc_type_t ty, const tinytc_location_t *loc)#

Create floating constant instruction.

Parameters:
  • instr – [out] pointer to the inst object created

  • value – [in] constant value

  • ty – [in] type of constant

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_constant_inst_create_int#

tinytc_status_t tinytc_constant_inst_create_int(tinytc_inst_t *instr, int64_t value, tinytc_type_t ty, const tinytc_location_t *loc)#

Create integer constant instruction.

Parameters:
  • instr – [out] pointer to the inst object created

  • value – [in] constant value

  • ty – [in] type of constant

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_constant_inst_create_one#

tinytc_status_t tinytc_constant_inst_create_one(tinytc_inst_t *instr, tinytc_type_t ty, const tinytc_location_t *loc)#

Creates the multiplicative identity constant (i.e. “1”) for the given data type.

Parameters:
  • instr – [out] pointer to the inst object created

  • ty – [in] type of constant

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_constant_inst_create_zero#

tinytc_status_t tinytc_constant_inst_create_zero(tinytc_inst_t *instr, tinytc_type_t ty, const tinytc_location_t *loc)#

Creates the additive identity constant (i.e. “0”) for the given data type.

Parameters:
  • instr – [out] pointer to the inst object created

  • ty – [in] type of constant

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_apply_inst_create#

tinytc_status_t tinytc_cooperative_matrix_apply_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Cooperative matrix apply instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] matrix

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_atomic_add_inst_create#

tinytc_status_t tinytc_cooperative_matrix_atomic_add_inst_create(tinytc_inst_t *instr, tinytc_transpose_t t, tinytc_checked_flag_t checked, tinytc_memory_scope_t scope, tinytc_memory_semantics_t semantics, tinytc_value_t val, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, tinytc_type_t result, const tinytc_location_t *loc)#

Cooperative matrix atomic add instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • t – [in] transposed store

  • checked – [in] boundary check

  • scope – [in] memory scope

  • semantics – [in] memory semantics

  • val – [in] value to store

  • operand – [in] matrix

  • pos0 – [in] row offset

  • pos1 – [in] column offset

  • result – [in] atomically updated matrix

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_atomic_load_inst_create#

tinytc_status_t tinytc_cooperative_matrix_atomic_load_inst_create(tinytc_inst_t *instr, tinytc_transpose_t t, tinytc_checked_flag_t checked, tinytc_memory_scope_t scope, tinytc_memory_semantics_t semantics, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, tinytc_type_t result, const tinytc_location_t *loc)#

Cooperative matrix atomic load instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • t – [in] transposed load

  • checked – [in] boundary check

  • scope – [in] memory scope

  • semantics – [in] memory semantics

  • operand – [in] matrix

  • pos0 – [in] row offset

  • pos1 – [in] column offset

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_atomic_max_inst_create#

tinytc_status_t tinytc_cooperative_matrix_atomic_max_inst_create(tinytc_inst_t *instr, tinytc_transpose_t t, tinytc_checked_flag_t checked, tinytc_memory_scope_t scope, tinytc_memory_semantics_t semantics, tinytc_value_t val, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, tinytc_type_t result, const tinytc_location_t *loc)#

Cooperative matrix atomic max instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • t – [in] transposed store

  • checked – [in] boundary check

  • scope – [in] memory scope

  • semantics – [in] memory semantics

  • val – [in] value to store

  • operand – [in] matrix

  • pos0 – [in] row offset

  • pos1 – [in] column offset

  • result – [in] atomically updated matrix

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_atomic_min_inst_create#

tinytc_status_t tinytc_cooperative_matrix_atomic_min_inst_create(tinytc_inst_t *instr, tinytc_transpose_t t, tinytc_checked_flag_t checked, tinytc_memory_scope_t scope, tinytc_memory_semantics_t semantics, tinytc_value_t val, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, tinytc_type_t result, const tinytc_location_t *loc)#

Cooperative matrix atomic min instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • t – [in] transposed store

  • checked – [in] boundary check

  • scope – [in] memory scope

  • semantics – [in] memory semantics

  • val – [in] value to store

  • operand – [in] matrix

  • pos0 – [in] row offset

  • pos1 – [in] column offset

  • result – [in] atomically updated matrix

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_atomic_store_inst_create#

tinytc_status_t tinytc_cooperative_matrix_atomic_store_inst_create(tinytc_inst_t *instr, tinytc_transpose_t t, tinytc_checked_flag_t checked, tinytc_memory_scope_t scope, tinytc_memory_semantics_t semantics, tinytc_value_t val, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, const tinytc_location_t *loc)#

Cooperative matrix atomic store instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • t – [in] transposed store

  • checked – [in] boundary check

  • scope – [in] memory scope

  • semantics – [in] memory semantics

  • val – [in] value to store

  • operand – [in] matrix

  • pos0 – [in] row offset

  • pos1 – [in] column offset

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_extract_inst_create#

tinytc_status_t tinytc_cooperative_matrix_extract_inst_create(tinytc_inst_t *instr, int64_t index, tinytc_value_t mat, tinytc_type_t result, const tinytc_location_t *loc)#

Cooperative matrix extract instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • index – [in] index

  • mat – [in] matrix

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_insert_inst_create#

tinytc_status_t tinytc_cooperative_matrix_insert_inst_create(tinytc_inst_t *instr, int64_t index, tinytc_value_t val, tinytc_value_t mat, tinytc_type_t result, const tinytc_location_t *loc)#

Cooperative matrix insert instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • index – [in] index

  • val – [in] value to insert

  • mat – [in] matrix

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_load_inst_create#

tinytc_status_t tinytc_cooperative_matrix_load_inst_create(tinytc_inst_t *instr, tinytc_transpose_t t, tinytc_checked_flag_t checked, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, tinytc_type_t result, const tinytc_location_t *loc)#

Cooperative matrix load instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • t – [in] transposed load

  • checked – [in] boundary check

  • operand – [in] matrix

  • pos0 – [in] row offset

  • pos1 – [in] column offset

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_mul_add_inst_create#

tinytc_status_t tinytc_cooperative_matrix_mul_add_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_value_t c, tinytc_type_t result, const tinytc_location_t *loc)#

Cooperative matrix mul add instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] a matrix

  • b – [in] b matrix

  • c – [in] c matrix

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_prefetch_inst_create#

tinytc_status_t tinytc_cooperative_matrix_prefetch_inst_create(tinytc_inst_t *instr, int32_t cache_level, int32_t rows, int32_t cols, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, const tinytc_location_t *loc)#

Cooperative matrix prefetch instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • cache_level – [in] cache level; 0 is closest to the core

  • rows – [in] number of rows

  • cols – [in] number of columns

  • operand – [in] matrix

  • pos0 – [in] row offset

  • pos1 – [in] column offset

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_reduce_add_inst_create#

tinytc_status_t tinytc_cooperative_matrix_reduce_add_inst_create(tinytc_inst_t *instr, tinytc_reduce_mode_t mode, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Cooperative matrix reduce add instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • mode – [in] reduce mode

  • a – [in] matrix

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_reduce_max_inst_create#

tinytc_status_t tinytc_cooperative_matrix_reduce_max_inst_create(tinytc_inst_t *instr, tinytc_reduce_mode_t mode, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Cooperative matrix reduce max instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • mode – [in] reduce mode

  • a – [in] matrix

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_reduce_min_inst_create#

tinytc_status_t tinytc_cooperative_matrix_reduce_min_inst_create(tinytc_inst_t *instr, tinytc_reduce_mode_t mode, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Cooperative matrix reduce min instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • mode – [in] reduce mode

  • a – [in] matrix

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_scale_inst_create#

tinytc_status_t tinytc_cooperative_matrix_scale_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Cooperative matrix scale instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] scalar

  • b – [in] matrix

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cooperative_matrix_store_inst_create#

tinytc_status_t tinytc_cooperative_matrix_store_inst_create(tinytc_inst_t *instr, tinytc_transpose_t t, tinytc_checked_flag_t checked, tinytc_value_t val, tinytc_value_t operand, tinytc_value_t pos0, tinytc_value_t pos1, const tinytc_location_t *loc)#

Cooperative matrix store instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • t – [in] transposed store

  • checked – [in] boundary check

  • val – [in] value to store

  • operand – [in] matrix

  • pos0 – [in] row offset

  • pos1 – [in] column offset

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cos_inst_create#

tinytc_status_t tinytc_cos_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Cosine instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] argument

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_cumsum_inst_create#

tinytc_status_t tinytc_cumsum_inst_create(tinytc_inst_t *instr, tinytc_bool_t atomic, int64_t mode, tinytc_value_t alpha, tinytc_value_t A, tinytc_value_t beta, tinytc_value_t B, const tinytc_location_t *loc)#

Cumsum instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • atomic – [in] atomic flag

  • mode – [in] sum mode

  • alpha – [in] alpha scalar

  • A – [in] A tensor

  • beta – [in] beta scalar

  • B – [in] B tensor

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_div_inst_create#

tinytc_status_t tinytc_div_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Division instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_equal_inst_create#

tinytc_status_t tinytc_equal_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Equal instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_exp2_inst_create#

tinytc_status_t tinytc_exp2_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Base-2 exponential instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] argument

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_exp_inst_create#

tinytc_status_t tinytc_exp_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Base-e exponential instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] argument

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_expand_inst_create#

tinytc_status_t tinytc_expand_inst_create(tinytc_inst_t *instr, int64_t expanded_mode, size_t static_expand_shape_size, const int64_t *static_expand_shape, tinytc_value_t operand, size_t expand_shape_size, const tinytc_value_t *expand_shape, tinytc_type_t result, const tinytc_location_t *loc)#

Expand instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • expanded_mode – [in] expanded mode

  • static_expand_shape_size – [in] array size of static_expand_shape

  • static_expand_shape – [in][range(0, static_expand_shape_size)] static expand shape; may be nullptr if static_expand_shape_size is 0

  • operand – [in] tensor

  • expand_shape_size – [in] array size of expand_shape

  • expand_shape – [in][range(0, expand_shape_size)] dynamic expand shape; may be nullptr if expand_shape_size is 0

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_for_inst_create#

tinytc_status_t tinytc_for_inst_create(tinytc_inst_t *instr, tinytc_value_t from, tinytc_value_t to, tinytc_value_t step, size_t iter_init_size, const tinytc_value_t *iter_init, size_t results_size, const tinytc_type_t *results, const tinytc_location_t *loc)#

Create for loop

Parameters:
  • instr – [out] pointer to the inst object created

  • from – [in] loop begin (inclusive)

  • to – [in] loop end (exclusive)

  • step – [in][optional] loop step; can be nullptr

  • iter_init_size – [in] array size of iter_init

  • iter_init – [in][range(0, iter_init_size)] array of initial values; may be nullptr if iter_init_size is 0

  • results_size – [in] array size of results

  • results – [in][range(0, results_size)] array of return types; may be nullptr if results_size is 0

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_foreach_inst_create#

tinytc_status_t tinytc_foreach_inst_create(tinytc_inst_t *instr, size_t from_size, const tinytc_value_t *from, size_t to_size, const tinytc_value_t *to, const tinytc_location_t *loc)#

Create foreach loop

Parameters:
  • instr – [out] pointer to the inst object created

  • from_size – [in] array size of from

  • from – [in][range(0, from_size)] array of loop begin (inclusive); may be nullptr if from_size is 0

  • to_size – [in] array size of to

  • to – [in][range(0, to_size)] array of loop end (exclusive); may be nullptr if to_size is 0

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_foreach_tile_inst_create#

tinytc_status_t tinytc_foreach_tile_inst_create(tinytc_inst_t *instr, size_t tile_shape_size, const int64_t *tile_shape, size_t from_size, const tinytc_value_t *from, size_t to_size, const tinytc_value_t *to, const tinytc_location_t *loc)#

Create tiled foreach loop

Parameters:
  • instr – [out] pointer to the inst object created

  • tile_shape_size – [in] array size of tile_shape

  • tile_shape – [in][range(0, tile_shape_size)] tile shape; may be nullptr if tile_shape_size is 0

  • from_size – [in] array size of from

  • from – [in][range(0, from_size)] array of loop begin (inclusive); may be nullptr if from_size is 0

  • to_size – [in] array size of to

  • to – [in][range(0, to_size)] array of loop end (exclusive); may be nullptr if to_size is 0

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_fuse_inst_create#

tinytc_status_t tinytc_fuse_inst_create(tinytc_inst_t *instr, int64_t from, int64_t to, tinytc_value_t operand, tinytc_type_t result, const tinytc_location_t *loc)#

Fuse instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • from – [in] first mode to fuse

  • to – [in] last mode to fuse

  • operand – [in] tensor

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_gemm_inst_create#

tinytc_status_t tinytc_gemm_inst_create(tinytc_inst_t *instr, tinytc_bool_t atomic, tinytc_transpose_t tA, tinytc_transpose_t tB, tinytc_value_t alpha, tinytc_value_t A, tinytc_value_t B, tinytc_value_t beta, tinytc_value_t C, const tinytc_location_t *loc)#

GEMM instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • atomic – [in] atomic flag

  • tA – [in] transpose A

  • tB – [in] transpose B

  • alpha – [in] alpha scalar

  • A – [in] A tensor

  • B – [in] B tensor

  • beta – [in] beta scalar

  • C – [in] C tensor

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_gemv_inst_create#

tinytc_status_t tinytc_gemv_inst_create(tinytc_inst_t *instr, tinytc_bool_t atomic, tinytc_transpose_t tA, tinytc_value_t alpha, tinytc_value_t A, tinytc_value_t B, tinytc_value_t beta, tinytc_value_t C, const tinytc_location_t *loc)#

GEMV instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • atomic – [in] atomic flag

  • tA – [in] transpose A

  • alpha – [in] alpha scalar

  • A – [in] A tensor

  • B – [in] B tensor

  • beta – [in] beta scalar

  • C – [in] C tensor

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_ger_inst_create#

tinytc_status_t tinytc_ger_inst_create(tinytc_inst_t *instr, tinytc_bool_t atomic, tinytc_value_t alpha, tinytc_value_t A, tinytc_value_t B, tinytc_value_t beta, tinytc_value_t C, const tinytc_location_t *loc)#

GER instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • atomic – [in] atomic flag

  • alpha – [in] alpha scalar

  • A – [in] A tensor

  • B – [in] B tensor

  • beta – [in] beta scalar

  • C – [in] C tensor

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_greater_than_equal_inst_create#

tinytc_status_t tinytc_greater_than_equal_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Greater than or equal instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_greater_than_inst_create#

tinytc_status_t tinytc_greater_than_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Greater instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_group_id_inst_create#

tinytc_status_t tinytc_group_id_inst_create(tinytc_inst_t *instr, tinytc_comp3_t mode, tinytc_type_t result, const tinytc_location_t *loc)#

Group ID instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • mode – [in] mode

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_hadamard_inst_create#

tinytc_status_t tinytc_hadamard_inst_create(tinytc_inst_t *instr, tinytc_bool_t atomic, tinytc_value_t alpha, tinytc_value_t A, tinytc_value_t B, tinytc_value_t beta, tinytc_value_t C, const tinytc_location_t *loc)#

Hadamard instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • atomic – [in] atomic flag

  • alpha – [in] alpha scalar

  • A – [in] A tensor

  • B – [in] B tensor

  • beta – [in] beta scalar

  • C – [in] C tensor

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_if_inst_create#

tinytc_status_t tinytc_if_inst_create(tinytc_inst_t *instr, tinytc_value_t condition, size_t results_size, const tinytc_type_t *results, const tinytc_location_t *loc)#

If instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • condition – [in] condition

  • results_size – [in] array size of results

  • results – [in][range(0, results_size)] return type array; may be nullptr if results_size is 0

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_im_inst_create#

tinytc_status_t tinytc_im_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Imaginary part instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_less_than_equal_inst_create#

tinytc_status_t tinytc_less_than_equal_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Less than or equal instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_less_than_inst_create#

tinytc_status_t tinytc_less_than_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Less than instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_lifetime_stop_inst_create#

tinytc_status_t tinytc_lifetime_stop_inst_create(tinytc_inst_t *instr, tinytc_value_t object, const tinytc_location_t *loc)#

Lifetime stop instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • object – [in] stack object whose lifetime ends

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_load_inst_create#

tinytc_status_t tinytc_load_inst_create(tinytc_inst_t *instr, tinytc_value_t operand, size_t index_list_size, const tinytc_value_t *index_list, tinytc_type_t result, const tinytc_location_t *loc)#

Load instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • operand – [in] tensor or group of tensors

  • index_list_size – [in] array size of index_list

  • index_list – [in][range(0, index_list_size)] indices; may be nullptr if index_list_size is 0

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_max_inst_create#

tinytc_status_t tinytc_max_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Max instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_min_inst_create#

tinytc_status_t tinytc_min_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Min instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_mul_inst_create#

tinytc_status_t tinytc_mul_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Multiplication instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_native_cos_inst_create#

tinytc_status_t tinytc_native_cos_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Cosine instruction (native)

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] argument

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_native_exp2_inst_create#

tinytc_status_t tinytc_native_exp2_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Base-2 exponential instruction (native)

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] argument

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_native_exp_inst_create#

tinytc_status_t tinytc_native_exp_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Base-e exponential instruction (native)

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] argument

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_native_sin_inst_create#

tinytc_status_t tinytc_native_sin_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Sine instruction (native)

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] argument

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_neg_inst_create#

tinytc_status_t tinytc_neg_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Negation instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_not_equal_inst_create#

tinytc_status_t tinytc_not_equal_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Not equal instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_not_inst_create#

tinytc_status_t tinytc_not_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Bitwise not instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_num_groups_inst_create#

tinytc_status_t tinytc_num_groups_inst_create(tinytc_inst_t *instr, tinytc_comp3_t mode, tinytc_type_t result, const tinytc_location_t *loc)#

Number of groups instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • mode – [in] mode

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_num_subgroups_inst_create#

tinytc_status_t tinytc_num_subgroups_inst_create(tinytc_inst_t *instr, tinytc_comp3_t mode, tinytc_type_t result, const tinytc_location_t *loc)#

Number of subgroups instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • mode – [in] mode

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_or_inst_create#

tinytc_status_t tinytc_or_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Bitwise or instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_parallel_inst_create#

tinytc_status_t tinytc_parallel_inst_create(tinytc_inst_t *instr, const tinytc_location_t *loc)#

Parallel instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_re_inst_create#

tinytc_status_t tinytc_re_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Real part instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_rem_inst_create#

tinytc_status_t tinytc_rem_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Remainder instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_shl_inst_create#

tinytc_status_t tinytc_shl_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Shift-left instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_shr_inst_create#

tinytc_status_t tinytc_shr_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Shift-right instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_sin_inst_create#

tinytc_status_t tinytc_sin_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Sine instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] argument

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_size_inst_create#

tinytc_status_t tinytc_size_inst_create(tinytc_inst_t *instr, int64_t mode, tinytc_value_t operand, tinytc_type_t result, const tinytc_location_t *loc)#

Size instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • mode – [in] mode for which size is extracted

  • operand – [in] tensor

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_store_inst_create#

tinytc_status_t tinytc_store_inst_create(tinytc_inst_t *instr, tinytc_value_t val, tinytc_value_t operand, size_t index_list_size, const tinytc_value_t *index_list, const tinytc_location_t *loc)#

Store instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • val – [in] value to store

  • operand – [in] operand

  • index_list_size – [in] array size of index_list

  • index_list – [in][range(0, index_list_size)] indices; may be nullptr if index_list_size is 0

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_sub_inst_create#

tinytc_status_t tinytc_sub_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Subtraction instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subgroup_broadcast_inst_create#

tinytc_status_t tinytc_subgroup_broadcast_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t idx, tinytc_type_t result, const tinytc_location_t *loc)#

Subgroup broadcast instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • idx – [in] subgroup local index

  • result – [in] result index

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subgroup_exclusive_scan_add_inst_create#

tinytc_status_t tinytc_subgroup_exclusive_scan_add_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Subgroup exclusive scan add

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subgroup_exclusive_scan_max_inst_create#

tinytc_status_t tinytc_subgroup_exclusive_scan_max_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Subgroup exclusive scan max

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subgroup_exclusive_scan_min_inst_create#

tinytc_status_t tinytc_subgroup_exclusive_scan_min_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Subgroup exclusive scan min

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subgroup_id_inst_create#

tinytc_status_t tinytc_subgroup_id_inst_create(tinytc_inst_t *instr, tinytc_comp3_t mode, tinytc_type_t result, const tinytc_location_t *loc)#

Subgroup id instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • mode – [in] mode

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subgroup_inclusive_scan_add_inst_create#

tinytc_status_t tinytc_subgroup_inclusive_scan_add_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Subgroup inclusive scan add

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subgroup_inclusive_scan_max_inst_create#

tinytc_status_t tinytc_subgroup_inclusive_scan_max_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Subgroup inclusive scan max

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subgroup_inclusive_scan_min_inst_create#

tinytc_status_t tinytc_subgroup_inclusive_scan_min_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Subgroup inclusive scan min

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subgroup_linear_id_inst_create#

tinytc_status_t tinytc_subgroup_linear_id_inst_create(tinytc_inst_t *instr, tinytc_type_t result, const tinytc_location_t *loc)#

Subgroup linear id instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subgroup_local_id_inst_create#

tinytc_status_t tinytc_subgroup_local_id_inst_create(tinytc_inst_t *instr, tinytc_type_t result, const tinytc_location_t *loc)#

Subgroup local id instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subgroup_reduce_add_inst_create#

tinytc_status_t tinytc_subgroup_reduce_add_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Subgroup reduce add

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subgroup_reduce_max_inst_create#

tinytc_status_t tinytc_subgroup_reduce_max_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Subgroup reduce max

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subgroup_reduce_min_inst_create#

tinytc_status_t tinytc_subgroup_reduce_min_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_type_t result, const tinytc_location_t *loc)#

Subgroup reduce min

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subgroup_size_inst_create#

tinytc_status_t tinytc_subgroup_size_inst_create(tinytc_inst_t *instr, tinytc_type_t result, const tinytc_location_t *loc)#

Subgroup size instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_subview_inst_create#

tinytc_status_t tinytc_subview_inst_create(tinytc_inst_t *instr, size_t static_offsets_size, const int64_t *static_offsets, size_t static_sizes_size, const int64_t *static_sizes, tinytc_value_t operand, size_t offsets_size, const tinytc_value_t *offsets, size_t sizes_size, const tinytc_value_t *sizes, tinytc_type_t result, const tinytc_location_t *loc)#

Subview instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • static_offsets_size – [in] array size of static_offsets

  • static_offsets – [in][range(0, static_offsets_size)] static offsets (need to add value to dynamic offsets if static_offsets[i] == TINYTC_DYNAMIC); may be nullptr if static_offsets_size is 0

  • static_sizes_size – [in] array size of static_sizes

  • static_sizes – [in][range(0, static_sizes_size)] static sizes (need to add value to dynamic sizes if static_sizes[i] == TINYTC_DYNAMIC); may be nullptr if static_sizes_size is 0

  • operand – [in] operand

  • offsets_size – [in] array size of offsets

  • offsets – [in][range(0, offsets_size)] dynamic offsets; may be nullptr if offsets_size is 0

  • sizes_size – [in] array size of sizes

  • sizes – [in][range(0, sizes_size)] dynamic sizes; may be nullptr if sizes_size is 0

  • result – [in] resulting memref type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_sum_inst_create#

tinytc_status_t tinytc_sum_inst_create(tinytc_inst_t *instr, tinytc_bool_t atomic, tinytc_transpose_t tA, tinytc_value_t alpha, tinytc_value_t A, tinytc_value_t beta, tinytc_value_t B, const tinytc_location_t *loc)#

Sum instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • atomic – [in] atomic flag

  • tA – [in] transpose A

  • alpha – [in] alpha scalar

  • A – [in] A tensor

  • beta – [in] beta scalar

  • B – [in] B tensor

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_xor_inst_create#

tinytc_status_t tinytc_xor_inst_create(tinytc_inst_t *instr, tinytc_value_t a, tinytc_value_t b, tinytc_type_t result, const tinytc_location_t *loc)#

Bitwise xor instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • a – [in] left-hand operand

  • b – [in] right-hand operand

  • result – [in] result type

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_yield_inst_create#

tinytc_status_t tinytc_yield_inst_create(tinytc_inst_t *instr, size_t yielded_vals_size, const tinytc_value_t *yielded_vals, const tinytc_location_t *loc)#

Yield instruction

Parameters:
  • instr – [out] pointer to the inst object created

  • yielded_vals_size – [in] array size of yielded_vals

  • yielded_vals – [in][range(0, yielded_vals_size)] yielded values; may be nullptr if yielded_vals_size is 0

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

Program#

Program Functions#

tinytc_prog_create#

tinytc_status_t tinytc_prog_create(tinytc_prog_t *prg, tinytc_compiler_context_t ctx, const tinytc_location_t *loc)#

Create program.

Parameters:
  • prg – [out] pointer to the prog object created

  • ctx – [in] compiler context object

  • loc – [in][optional] Source code location; can be nullptr

Returns:

tinytc_status_success on success and error otherwise

tinytc_prog_add_function#

tinytc_status_t tinytc_prog_add_function(tinytc_prog_t prg, tinytc_func_t fun)#

Append function to program.

The program takes ownership of the function. A function must not be added to multiple programs nor must the user destroy the function after adding it to the program.

Parameters:
  • prg – [inout] program object

  • fun – [in,pass_ownership] function object

Returns:

tinytc_status_success on success and error otherwise

Recipe#

Recipe Functions#

tinytc_recipe_get_binary#

tinytc_status_t tinytc_recipe_get_binary(const_tinytc_recipe_t recipe, tinytc_binary_t *bin)#

Get binary.

The reference count of the binary remains unchanged. The user must call tinytc_binary_retain if the binary shall be used after the recipe was released.

Parameters:
  • recipe – [in] recipe object

  • bin – [out] pointer to binary

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_get_prog#

tinytc_status_t tinytc_recipe_get_prog(const_tinytc_recipe_t recipe, tinytc_prog_t *prg)#

Get prog object.

The reference count of the prog remains unchanged. The user must call tinytc_prog_retain if the prog shall be used after the recipe was released.

Parameters:
  • recipe – [in] recipe object

  • prg – [out] pointer to prog object

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_handler_get_recipe#

tinytc_status_t tinytc_recipe_handler_get_recipe(const_tinytc_recipe_handler_t handler, tinytc_recipe_t *recipe)#

Get recipe object.

The reference count of the recipe remains unchanged. The user must call tinytc_recipe_retain if the recipe shall be used after the recipe handler was released.

Parameters:
  • handler – [in] recipe handler object

  • recipe – [out] pointer to recipe object

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_small_gemm_batched_create#

tinytc_status_t tinytc_recipe_small_gemm_batched_create(tinytc_recipe_t *recipe, const_tinytc_core_info_t info, tinytc_type_t number_ty, tinytc_transpose_t tA, tinytc_transpose_t tB, int64_t M, int64_t N, int64_t K, int64_t ldA, int64_t strideA, int64_t ldB, int64_t strideB, int64_t ldC, int64_t strideC)#

Returns a small batched GEMM recipe.

The program contains a kernel for \(\beta=0\) called “gemm_beta0” and a kernel for \(\beta\neq 0\) called “gemm”. All matrix shapes and strides are known at compile-time.

The signature of the generated kernels gemm and gemm_beta0 is (if A and B are not transposed)

func @{name}(%alpha: {ty.alpha},
             %A: memref<{ty.A}x{M}x{K}x?,strided<1,{ldA},{strideA}>>,
             %B: memref<{ty.B}x{K}x{N}x?,strided<1,{ldB},{strideB}>>,
             %beta: {ty.beta},
             %C: memref<{ty.C}x{M}x{N}x?,strided<1,{ldC},{strideC}>>)

meaning that its kernels need arguments in the following order:

alpha, A_ptr, howmany, B_ptr, howmany, beta, C_ptr, howmany
Parameters:
  • recipe – [out] pointer to the recipe object created

  • info – [in] core info object

  • number_ty – [in] Number types of alpha, A, B, beta, C

  • tA – [in] Transpose A

  • tB – [in] Transpose B

  • M – [in] Number of rows of A, C

  • N – [in] Number of columns of B, C

  • K – [in] Number columns of A, number of rows of B

  • ldA – [in] Leading dimension of A

  • strideA – [in] Number of elements between A-matrices

  • ldB – [in] Leading dimension of B

  • strideB – [in] Number of elements between B-matrices

  • ldC – [in] Leading dimension of C

  • strideC – [in] Number of elements between C-matrices

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_small_gemm_batched_set_args#

tinytc_status_t tinytc_recipe_small_gemm_batched_set_args(tinytc_recipe_handler_t handler, int64_t howmany, size_t alpha_size, const void *alpha_value, tinytc_mem_type_t A_type, const void *A_value, tinytc_mem_type_t B_type, const void *B_value, size_t beta_size, const void *beta_value, tinytc_mem_type_t C_type, const void *C_value)#

Set kernel arguments for small GEMM batched recipe.

Parameters:
  • handler – [inout] Recipe handler object

  • howmany – [in] Group size

  • alpha_size – [in] Size of alpha argument

  • alpha_value – [in] Pointer to data used for alpha; data is copied

  • A_type – [in] Type of memory object used for A-matrix

  • A_value – [in] Memory object used for A-matrix

  • B_type – [in] Type of memory object used for B-matrix

  • B_value – [in] Memory object used for B-matrix

  • beta_size – [in] Size of beta argument

  • beta_value – [in] Pointer to data used for beta; data is copied

  • C_type – [in] Type of memory object used for C-matrix

  • C_value – [in] Memory object used for C-matrix

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_tall_and_skinny_create#

tinytc_status_t tinytc_recipe_tall_and_skinny_create(tinytc_recipe_t *recipe, const_tinytc_core_info_t info, tinytc_type_t number_ty, int64_t N, int64_t K, int32_t M_block_size)#

Returns a tall and skinny recipe.

The program contains a kernel for beta = 0 called “gemm_beta0” and a kernel for beta != 0 called “gemm”. M (= number of rows of A, C) and strides are dynamic.

The signature of the generated kernels gemm and gemm_beta0 is

func @{name}(%alpha: {ty.alpha},
             %A: memref<{ty.A}x?x{K},strided<1,?>>,
             %B: memref<{ty.B}x{K}x{N},strided<1,?>>,
             %beta: {ty.beta},
             %C: memref<{ty.C}x?x{N},strided<1,?>>)

meaning that its kernels need arguments in the following order:

alpha, A_ptr, M, ldA, B_ptr, ldB, beta, C_ptr, M, ldC

where ldA, ldB, ldC is the size of stride[1] of A, B, C, respectively.

Parameters:
  • recipe – [out] pointer to the recipe object created

  • info – [in] core info object

  • number_ty – [in] Number type of alpha, A, B, beta, C

  • N – [in] Number of columns of B, C

  • K – [in] Number columns of A, number of rows of B

  • M_block_size – [in][optional] Size of M block that each work group gets; pass 0 to have the parameter auto-selected

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_tall_and_skinny_create_specialized#

tinytc_status_t tinytc_recipe_tall_and_skinny_create_specialized(tinytc_recipe_t *recipe, const_tinytc_core_info_t info, tinytc_type_t number_ty, int64_t M, int64_t N, int64_t K, int64_t ldA, int64_t ldB, int64_t ldC, int32_t alignA, int32_t alignB, int32_t alignC, int32_t M_block_size)#

Returns a tall and skinny recipe with additional specialization constants.

Similar to tinytc_recipe_tall_and_skinny_create but with the additional specialization constants M, ldA, ldB, and ldC. The specialization constants may be either set to a fixed value or to TINYTC_DYNAMIC. Note that if a specialization constant is set to a fixed value then the parameter with the same name in tinytc_recipe_tall_and_skinny_set_args is ignored.

Furthermore, the memory alignment may be passed with alignA, alignB, and alignC or set to 0 to use the default memory alignment (= size of scalar type).

The generated kernels have the following signature:

func @{name}(%alpha: {ty.alpha},
             %A: memref<{ty.A}x{M}x{K},strided<1,{ldA}>>,
             %B: memref<{ty.B}x{K}x{N},strided<1,{ldB}>>,
             %beta: {ty.beta},
             %C: memref<{ty.C}x{M}x{N},strided<1,{ldC}>>)
Parameters:
  • recipe – [out] pointer to the recipe object created

  • info – [in] core info object

  • number_ty – [in] Number type of alpha, A, B, beta, C

  • M – [in] Number of rows of A, C; can be TINYTC_DYNAMIC

  • N – [in] Number of columns of B, C

  • K – [in] Number columns of A, number of rows of B

  • ldA – [in] Leading dimension of A; can be TINYTC_DYNAMIC

  • ldB – [in] Leading dimension of B; can be TINYTC_DYNAMIC

  • ldC – [in] Leading dimension of C; can be TINYTC_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 – [in][optional] Size of M block that each work group gets; pass 0 to have the parameter auto-selected

Returns:

tinytc_recipe_tall_and_skinny_set_args#

tinytc_status_t tinytc_recipe_tall_and_skinny_set_args(tinytc_recipe_handler_t handler, int64_t M, size_t alpha_size, const void *alpha_value, tinytc_mem_type_t A_type, const void *A_value, int64_t ldA, tinytc_mem_type_t B_type, const void *B_value, int64_t ldB, size_t beta_size, const void *beta_value, tinytc_mem_type_t C_type, const void *C_value, int64_t ldC)#

Set kernel arguments for tall and skinny GEMM recipe.

Parameters:
  • handler – [inout] Recipe handler object

  • M – [in] Size of M-mode

  • alpha_size – [in] Size of alpha argument

  • alpha_value – [in] Pointer to data used for alpha; data is copied

  • A_type – [in] Type of memory object used for A-matrix

  • A_value – [in] Memory object used for A-matrix

  • ldA – [in] Leading dimension of A

  • B_type – [in] Type of memory object used for B-matrix

  • B_value – [in] Memory object used for B-matrix

  • ldB – [in] Leading dimension of B

  • beta_size – [in] Size of beta argument

  • beta_value – [in] Pointer to data used for beta; data is copied

  • C_type – [in] Type of memory object used for C-matrix

  • C_value – [in] Memory object used for C-matrix

  • ldC – [in] Leading dimension of C

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_tall_and_skinny_suggest_block_size#

tinytc_status_t tinytc_recipe_tall_and_skinny_suggest_block_size(const_tinytc_core_info_t info, int32_t *M_block_size)#

Suggest an M block size for tall and skinny recipe.

Parameters:
  • info – [in] core info object

  • M_block_size – [out] pointer to block size

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_release#

tinytc_status_t tinytc_recipe_release(tinytc_recipe_t obj)#

Release recipe object.

Decreases reference count by 1, free memory if reference count is 0.

Parameters:
  • obj – [inout] recipe object

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_retain#

tinytc_status_t tinytc_recipe_retain(tinytc_recipe_t obj)#

Increase reference count of recipe object by 1.

Parameters:
  • obj – [inout] recipe object

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_handler_release#

tinytc_status_t tinytc_recipe_handler_release(tinytc_recipe_handler_t obj)#

Release recipe handler object.

Decreases reference count by 1, free memory if reference count is 0.

Parameters:
  • obj – [inout] recipe handler object

Returns:

tinytc_status_success on success and error otherwise

tinytc_recipe_handler_retain#

tinytc_status_t tinytc_recipe_handler_retain(tinytc_recipe_handler_t obj)#

Increase reference count of recipe handler object by 1.

Parameters:
  • obj – [inout] recipe handler object

Returns:

tinytc_status_success on success and error otherwise

Region#

Region Functions#

tinytc_region_append#

tinytc_status_t tinytc_region_append(tinytc_region_t reg, tinytc_inst_t instr)#

Append instruction to region.

The region takes ownership of the instruction. An instruction must not be added to multiple regions.

Parameters:
  • reg – [inout] region object

  • instr – [in,pass_ownership] instruction

Returns:

tinytc_status_success on success and error otherwise

tinytc_region_begin#

tinytc_status_t tinytc_region_begin(tinytc_region_t reg, tinytc_inst_iterator_t *iterator)#

Returns iterator pointing to begin of the region.

Parameters:
  • reg – [in] region

  • iterator – [out] inst iterator

Returns:

tinytc_status_success on success and error otherwise

tinytc_region_end#

tinytc_status_t tinytc_region_end(tinytc_region_t reg, tinytc_inst_iterator_t *iterator)#

Returns iterator pointing to the end of the region.

The end iterator must not be dereferenced.

Parameters:
  • reg – [in] region]

  • iterator – [out] inst iterator

Returns:

tinytc_status_success on success and error otherwise

tinytc_region_erase#

tinytc_status_t tinytc_region_erase(tinytc_region_t reg, tinytc_inst_iterator_t *iterator)#

Erase instruction at the position of the iterator.

The iterator is updated to point to the instruction coming after the iterator or the end iterator

Parameters:
  • reg – [inout] region object

  • iterator – [inout] iterator

Returns:

tinytc_status_success on success and error otherwise

tinytc_region_insert#

tinytc_status_t tinytc_region_insert(tinytc_region_t reg, tinytc_inst_iterator_t *iterator, tinytc_inst_t instr)#

Insert instruction at the position before the iterator.

The iterator is updated to point to the instruction that was just inserted.

The region takes ownership of the instruction. An instruction must not be inserted into multiple regions.

Parameters:
  • reg – [inout] region object

  • iterator – [inout]

  • instr – [in,pass_ownership]

Returns:

tinytc_status_success on success and error otherwise

tinytc_next_inst#

tinytc_status_t tinytc_next_inst(tinytc_inst_iterator_t *iterator)#

Move iterator to the next instruction.

Parameters:
  • iterator – [inout] iterator

Returns:

tinytc_status_success on success and error otherwise

tinytc_prev_inst#

tinytc_status_t tinytc_prev_inst(tinytc_inst_iterator_t *iterator)#

Move iterator to the previous instruction.

Parameters:
  • iterator – [inout] iterator

Returns:

tinytc_status_success on success and error otherwise

tinytc_region_get_parameters#

tinytc_status_t tinytc_region_get_parameters(tinytc_region_t reg, size_t *result_list_size, tinytc_value_t *result_list)#

Get region parameters.

Function can be called with result_list_size = 0 and result_list = nullptr in order to obtain the number of results

Parameters:
  • reg – [in] region object

  • result_list_size – [inout] pointer to the number of results; if result_list_size is 0, then it is updated with the number of results; if result_list_size is greather than the number of results, the value is updated with the correct number of results

  • result_list – [out][range(0, result_list_size)] user-provided memory for storing result handles; at most result_list_size values are written; can be nullptr if result_list_size is 0

Returns:

tinytc_status_success on success and error otherwise

Value#

Value Functions#

tinytc_value_get_name#

tinytc_status_t tinytc_value_get_name(const_tinytc_value_t vl, char const **name)#

Get name of value.

The returned pointer may be invalidated if the value or any node in the abstract syntax tree referencing the value is modified.

Parameters:
  • vl – [in] value object

  • name – [out] pointer to C string

Returns:

tinytc_status_success on success and error otherwise

tinytc_value_get_type#

tinytc_status_t tinytc_value_get_type(const_tinytc_value_t vl, tinytc_type_t *ty)#

Get type of value.

Parameters:
  • vl – [in] value object

  • ty – [out] pointer to data type

Returns:

tinytc_status_success on success and error otherwise

tinytc_value_set_name#

tinytc_status_t tinytc_value_set_name(tinytc_value_t vl, char const *name)#

Set name of value.

Parameters:
  • vl – [inout] value object

  • name – [in] name; null-terminated string

Returns:

tinytc_status_success on success and error otherwise

tinytc_value_set_name_n#

tinytc_status_t tinytc_value_set_name_n(tinytc_value_t vl, size_t name_length, char const *name)#

Set name of value with explicit number of characters.

Parameters:
  • vl – [inout] value object

  • name_length – [in] number of characters

  • name – [in] name; not necessarily null-terminated

Returns:

tinytc_status_success on success and error otherwise