heterocl.util module

Utility functions for HeteroCL

class CastRemover[source]

Bases: heterocl.mutator.Mutator

mutate_BinOp(binop, node)[source]
mutate_Cast(node)[source]
mutate_ConstExpr(node)[source]
class VarName[source]

Bases: object

A counter for each type of variables.

Parameters

name_dict (dict) – A dictionary whose key is the variable type and whose value is the number of such variable.

name_dict = {'compute': 2, 'mutate': 2, 'placeholder': 7, 'ra': 9, 'scalar': 1}
get_dtype(dtype, name=None)[source]

Get the data type by default or from a value.

We first check if the data type of a variable is specified after the scheduling or the variable is used for the first time. After that, we check whether user specifies the data type or not.

Parameters
  • dtype (Type or str or None) – The specified data type.

  • name (str, optional) – The name of the variable that will be given a data type.

Returns

dtype – A data type represented in str.

Return type

str

get_index(shape, args, level)[source]
get_name(var_type, name=None)[source]

Get the name of a given type of variable.

If the name is not given, this function automatically generates a name according to the given type of variable.

Parameters
  • var_type (str) – The type of the variable in string.

  • name (str, optional) – The name specified by the user.

Returns

new_name – The name of the variable.

Return type

str

get_tvm_dtype(dtype, name=None)[source]
get_type(dtype)[source]
make_for(indices, body, level)[source]
true()[source]