heterocl.types

heterocl.Type([bits, fracs])

The base class for all data types

heterocl.Int([bits, fracs])

Arbitrary-bit signed integers

heterocl.UInt([bits, fracs])

Arbitrary-bit unsigned integers

heterocl.Fixed([bits, fracs])

Arbitrary-bit signed fixed points

heterocl.UFixed([bits, fracs])

Arbitrary-bit unsigned fixed points

heterocl.Float([bits, fracs])

Floating points

heterocl.dtype_to_hcl(dtype)

Convert a data type to Heterocl type.

heterocl.dtype_to_str(dtype)

Convert a data type to string format.

heterocl.get_bitwidth(dtype)

Get the bitwidth of a given data type.

heterocl.get_fractional_bitwidth(dtype)

Get the fractional bitwidth of a given data type.

class Type(bits=32, fracs=0)[source]

The base class for all data types

The default bitwidth is 32 and no fractional bit.

Parameters
  • bits (int) – Number of total bits.

  • fracs (int) – Number of fractional bits.

class Int(bits=32, fracs=0)[source]

Bases: heterocl.types.Type

Arbitrary-bit signed integers

class UInt(bits=32, fracs=0)[source]

Bases: heterocl.types.Type

Arbitrary-bit unsigned integers

class Fixed(bits=32, fracs=0)[source]

Bases: heterocl.types.Type

Arbitrary-bit signed fixed points

class UFixed(bits=32, fracs=0)[source]

Bases: heterocl.types.Type

Arbitrary-bit unsigned fixed points

class Float(bits=32, fracs=0)[source]

Bases: heterocl.types.Type

Floating points

dtype_to_hcl(dtype)[source]

Convert a data type to Heterocl type.

Parameters

dtype (Type or str) – The data type to be converted

Returns

Return type

Type

dtype_to_str(dtype)[source]

Convert a data type to string format.

This method is mainly for TVM APIs.

Parameters

dtype (Type or str) – The data type to be converted

Returns

The converted data type in string format.

Return type

str

get_bitwidth(dtype)[source]

Get the bitwidth of a given data type.

Parameters

dtype (Type or str) – The given data type

Returns

Return type

int

get_fractional_bitwidth(dtype)[source]

Get the fractional bitwidth of a given data type.

Parameters

dtype (Type or str) – The given data type

Returns

Return type

int