Halide
Halide::Type Struct Reference

Types in the halide type system. More...

#include <Type.h>

Public Member Functions

int bytes () const
 The number of bytes required to store a single scalar value of this type. More...
 
 Type ()
 
 Type (halide_type_code_t code, int bits, int lanes, const halide_handle_cplusplus_type *handle_type=nullptr)
 Construct a runtime representation of a Halide type from: code: The fundamental type from an enum. More...
 
 Type (const Type &that)=default
 Trivial copy constructor. More...
 
 Type (const halide_type_t &that, const halide_handle_cplusplus_type *handle_type=nullptr)
 Type is a wrapper around halide_type_t with more methods for use inside the compiler. More...
 
 operator halide_type_t () const
 Unwrap the runtime halide_type_t for use in runtime calls, etc. More...
 
halide_type_code_t code () const
 Return the underlying data type of an element as an enum value. More...
 
int bits () const
 Return the bit size of a single element of this type. More...
 
int lanes () const
 Return the number of vector elements in this type. More...
 
Type with_code (halide_type_code_t new_code) const
 Return Type with same number of bits and lanes, but new_code for a type code. More...
 
Type with_bits (int new_bits) const
 Return Type with same type code and lanes, but new_bits for the number of bits. More...
 
Type with_lanes (int new_lanes) const
 Return Type with same type code and number of bits, but new_lanes for the number of vector lanes. More...
 
bool is_bool () const
 Is this type boolean (represented as UInt(1))? More...
 
bool is_vector () const
 Is this type a vector type? (lanes() != 1). More...
 
bool is_scalar () const
 Is this type a scalar type? (lanes() == 1). More...
 
bool is_float () const
 Is this type a floating point type (float or double). More...
 
bool is_int () const
 Is this type a signed integer type? More...
 
bool is_uint () const
 Is this type an unsigned integer type? More...
 
bool is_handle () const
 Is this type an opaque handle type (void *) More...
 
EXPORT bool same_handle_type (const Type &other) const
 Check that the type name of two handles matches. More...
 
bool operator== (const Type &other) const
 Compare two types for equality. More...
 
bool operator!= (const Type &other) const
 Compare two types for inequality. More...
 
bool operator< (const Type &other) const
 Compare ordering of two types so they can be used in certain containers and algorithms. More...
 
Type element_of () const
 Produce the scalar type (that of a single element) of this vector type. More...
 
EXPORT bool can_represent (Type other) const
 Can this type represent all values of another type? More...
 
EXPORT Expr max () const
 Return an expression which is the maximum value of this type. More...
 
EXPORT Expr min () const
 Return an expression which is the minimum value of this type. More...
 
EXPORT bool can_represent (double x) const
 Can this type represent a particular constant? More...
 
EXPORT bool can_represent (int64_t x) const
 Can this type represent a particular constant? More...
 
EXPORT bool can_represent (uint64_t x) const
 Can this type represent a particular constant? More...
 
EXPORT bool is_max (uint64_t) const
 Check if an integer constant value is the maximum or minimum representable value for this type. More...
 
EXPORT bool is_max (int64_t) const
 Check if an integer constant value is the maximum or minimum representable value for this type. More...
 
EXPORT bool is_min (uint64_t) const
 Check if an integer constant value is the maximum or minimum representable value for this type. More...
 
EXPORT bool is_min (int64_t) const
 Check if an integer constant value is the maximum or minimum representable value for this type. More...
 

Public Attributes

const halide_handle_cplusplus_typehandle_type
 Type to be printed when declaring handles of this type. More...
 

Static Public Attributes

static const halide_type_code_t Int = halide_type_int
 Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ style. More...
 
static const halide_type_code_t UInt = halide_type_uint
 Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ style. More...
 
static const halide_type_code_t Float = halide_type_float
 Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ style. More...
 
static const halide_type_code_t Handle = halide_type_handle
 Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ style. More...
 

Detailed Description

Types in the halide type system.

They can be ints, unsigned ints, or floats of various bit-widths (the 'bits' field). They can also be vectors of the same (by setting the 'lanes' field to something larger than one). Front-end code shouldn't use vector types. Instead vectorize a function.

Examples:
tutorial/lesson_14_types.cpp.

Definition at line 285 of file Type.h.

Constructor & Destructor Documentation

◆ Type() [1/4]

Halide::Type::Type ( )
inline

Definition at line 303 of file Type.h.

◆ Type() [2/4]

Halide::Type::Type ( halide_type_code_t  code,
int  bits,
int  lanes,
const halide_handle_cplusplus_type handle_type = nullptr 
)
inline

Construct a runtime representation of a Halide type from: code: The fundamental type from an enum.

bits: The bit size of one element. lanes: The number of vector elements in the type.

Definition at line 310 of file Type.h.

◆ Type() [3/4]

Halide::Type::Type ( const Type that)
default

Trivial copy constructor.

◆ Type() [4/4]

Halide::Type::Type ( const halide_type_t that,
const halide_handle_cplusplus_type handle_type = nullptr 
)
inline

Type is a wrapper around halide_type_t with more methods for use inside the compiler.

This simply constructs the wrapper around the runtime value.

Definition at line 320 of file Type.h.

Member Function Documentation

◆ bytes()

int Halide::Type::bytes ( ) const
inline

The number of bytes required to store a single scalar value of this type.

Ignores vector lanes.

Definition at line 300 of file Type.h.

Referenced by Halide::Target::natural_vector_size().

◆ operator halide_type_t()

Halide::Type::operator halide_type_t ( ) const
inline

Unwrap the runtime halide_type_t for use in runtime calls, etc.

Representation is exactly equivalent.

Definition at line 325 of file Type.h.

◆ code()

halide_type_code_t Halide::Type::code ( ) const
inline

Return the underlying data type of an element as an enum value.

Definition at line 328 of file Type.h.

Referenced by Halide::absd(), operator!=(), operator<(), and operator==().

◆ bits()

◆ lanes()

◆ with_code()

Type Halide::Type::with_code ( halide_type_code_t  new_code) const
inline

Return Type with same number of bits and lanes, but new_code for a type code.

Definition at line 337 of file Type.h.

Referenced by Halide::absd(), Halide::Internal::eliminated_bool_type(), and Halide::is_nan().

◆ with_bits()

Type Halide::Type::with_bits ( int  new_bits) const
inline

Return Type with same type code and lanes, but new_bits for the number of bits.

Examples:
tutorial/lesson_14_types.cpp.

Definition at line 343 of file Type.h.

Referenced by Halide::Internal::eliminated_bool_type(), Halide::operator &(), Halide::operator^(), and Halide::operator|().

◆ with_lanes()

Type Halide::Type::with_lanes ( int  new_lanes) const
inline

Return Type with same type code and number of bits, but new_lanes for the number of vector lanes.

Definition at line 350 of file Type.h.

◆ is_bool()

bool Halide::Type::is_bool ( ) const
inline

Is this type boolean (represented as UInt(1))?

Definition at line 358 of file Type.h.

Referenced by Halide::operator &&(), Halide::operator||(), and Halide::select().

◆ is_vector()

bool Halide::Type::is_vector ( ) const
inline

Is this type a vector type? (lanes() != 1).

TODO(abadams): Decide what to do for lanes() == 0.

Definition at line 362 of file Type.h.

Referenced by Halide::cast(), and Halide::Internal::eliminated_bool_type().

◆ is_scalar()

bool Halide::Type::is_scalar ( ) const
inline

Is this type a scalar type? (lanes() == 1).

TODO(abadams): Decide what to do for lanes() == 0.

Definition at line 366 of file Type.h.

Referenced by Halide::cast(), Halide::Internal::IntImm::make(), Halide::Internal::UIntImm::make(), and Halide::Internal::FloatImm::make().

◆ is_float()

bool Halide::Type::is_float ( ) const
inline

◆ is_int()

◆ is_uint()

bool Halide::Type::is_uint ( ) const
inline

◆ is_handle()

bool Halide::Type::is_handle ( ) const
inline

Is this type an opaque handle type (void *)

Examples:
tutorial/lesson_14_types.cpp.

Definition at line 378 of file Type.h.

References EXPORT, and Halide::Handle().

Referenced by Halide::cast().

◆ same_handle_type()

EXPORT bool Halide::Type::same_handle_type ( const Type other) const

Check that the type name of two handles matches.

◆ operator==()

bool Halide::Type::operator== ( const Type other) const
inline

Compare two types for equality.

Definition at line 384 of file Type.h.

References bits(), code(), and lanes().

◆ operator!=()

bool Halide::Type::operator!= ( const Type other) const
inline

Compare two types for inequality.

Definition at line 390 of file Type.h.

References bits(), code(), and lanes().

◆ operator<()

bool Halide::Type::operator< ( const Type other) const
inline

Compare ordering of two types so they can be used in certain containers and algorithms.

Definition at line 396 of file Type.h.

References bits(), code(), handle_type, and lanes().

◆ element_of()

Type Halide::Type::element_of ( ) const
inline

Produce the scalar type (that of a single element) of this vector type.

Definition at line 404 of file Type.h.

References EXPORT, Halide::max(), and Halide::min().

Referenced by Halide::cast(), Halide::ceil(), and Halide::is_nan().

◆ can_represent() [1/4]

EXPORT bool Halide::Type::can_represent ( Type  other) const

Can this type represent all values of another type?

◆ can_represent() [2/4]

EXPORT bool Halide::Type::can_represent ( double  x) const

Can this type represent a particular constant?

◆ can_represent() [3/4]

EXPORT bool Halide::Type::can_represent ( int64_t  x) const

Can this type represent a particular constant?

◆ can_represent() [4/4]

EXPORT bool Halide::Type::can_represent ( uint64_t  x) const

Can this type represent a particular constant?

◆ is_max() [1/2]

EXPORT bool Halide::Type::is_max ( uint64_t  ) const

Check if an integer constant value is the maximum or minimum representable value for this type.

◆ is_max() [2/2]

EXPORT bool Halide::Type::is_max ( int64_t  ) const

Check if an integer constant value is the maximum or minimum representable value for this type.

◆ is_min() [1/2]

EXPORT bool Halide::Type::is_min ( uint64_t  ) const

Check if an integer constant value is the maximum or minimum representable value for this type.

◆ is_min() [2/2]

EXPORT bool Halide::Type::is_min ( int64_t  ) const

Check if an integer constant value is the maximum or minimum representable value for this type.

◆ max()

EXPORT Expr Halide::Type::max ( ) const

Return an expression which is the maximum value of this type.

Returns infinity for types which can represent it.

◆ min()

EXPORT Expr Halide::Type::min ( ) const

Return an expression which is the minimum value of this type.

Returns -infinity for types which can represent it.

Member Data Documentation

◆ Int

const halide_type_code_t Halide::Type::Int = halide_type_int
static

Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ style.

Definition at line 293 of file Type.h.

Referenced by Halide::Internal::eliminated_bool_type().

◆ UInt

const halide_type_code_t Halide::Type::UInt = halide_type_uint
static

Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ style.

Definition at line 294 of file Type.h.

Referenced by Halide::abs(), and Halide::absd().

◆ Float

const halide_type_code_t Halide::Type::Float = halide_type_float
static

Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ style.

Definition at line 295 of file Type.h.

Referenced by Halide::ceil(), Halide::floor(), Halide::is_nan(), Halide::round(), and Halide::trunc().

◆ Handle

const halide_type_code_t Halide::Type::Handle = halide_type_handle
static

Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ style.

Definition at line 296 of file Type.h.

◆ handle_type

const halide_handle_cplusplus_type* Halide::Type::handle_type

Type to be printed when declaring handles of this type.

Definition at line 355 of file Type.h.

Referenced by operator<().


The documentation for this struct was generated from the following file: