61 return !(*
this == rhs);
110 const std::vector<std::string> &
namespaces = {},
112 const std::vector<uint8_t> &modifiers = {},
141 #define HALIDE_DECLARE_EXTERN_TYPE(TypeType, Type) \ 143 struct halide_c_type_to_name<Type> { \ 144 static constexpr bool known_type = true; \ 145 static halide_cplusplus_type_name name() { \ 146 return {halide_cplusplus_type_name::TypeType, #Type}; \ 150 #define HALIDE_DECLARE_EXTERN_SIMPLE_TYPE(T) HALIDE_DECLARE_EXTERN_TYPE(Simple, T) 151 #define HALIDE_DECLARE_EXTERN_STRUCT_TYPE(T) HALIDE_DECLARE_EXTERN_TYPE(Struct, T) 152 #define HALIDE_DECLARE_EXTERN_CLASS_TYPE(T) HALIDE_DECLARE_EXTERN_TYPE(Class, T) 153 #define HALIDE_DECLARE_EXTERN_UNION_TYPE(T) HALIDE_DECLARE_EXTERN_TYPE(Union, T) 198 constexpr
bool is_ptr = std::is_pointer<T>::value;
199 constexpr
bool is_lvalue_reference = std::is_lvalue_reference<T>::value;
200 constexpr
bool is_rvalue_reference = std::is_rvalue_reference<T>::value;
202 using TNoRef =
typename std::remove_reference<T>::type;
203 using TNoRefNoPtr =
typename std::remove_pointer<TNoRef>::type;
204 constexpr
bool is_function_pointer = std::is_pointer<TNoRef>::value &&
205 std::is_function<TNoRefNoPtr>::value;
208 using TBase =
typename std::conditional<is_function_pointer, TNoRef, TNoRefNoPtr>::type;
209 constexpr
bool is_const = std::is_const<TBase>::value;
210 constexpr
bool is_volatile = std::is_volatile<TBase>::value;
225 using TNonCVBase =
typename std::remove_cv<TBase>::type;
227 static_assert(!(!known_type && !is_ptr),
"Unknown types must be pointers");
257 if (std::is_pointer<T>::value ||
258 std::is_lvalue_reference<T>::value ||
259 std::is_rvalue_reference<T>::value) {
293 return (
bits() + 7) / 8;
308 <<
"Halide only supports vector types with up to 65535 lanes. " <<
lanes <<
" lanes requested.";
310 <<
"Halide only supports types with up to 255 bits. " <<
bits <<
" bits requested.";
477 return type == other;
482 return type != other;
487 if (type < other.type) {
551 return UInt(1, lanes);
566 std::string
type_to_c_type(Type type,
bool include_space,
bool c_plus_plus =
true);
static const halide_type_code_t BFloat
Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ s...
Various utility functions used internally Halide.
bool operator==(const Type &other) const
Compare two types for equality.
bool operator!=(const halide_type_t &other) const
Compare two types for inequality.
A fragment of Halide syntax.
HALIDE_ALWAYS_INLINE 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.
#define HALIDE_DECLARE_EXTERN_STRUCT_TYPE(T)
static const halide_type_code_t Float
Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ s...
A type traits template to provide a halide_handle_cplusplus_type value from a C++ type...
CPPTypeType
An enum to indicate whether a C++ type is non-composite, a struct, class, or union.
uint16_t lanes
How many elements in a vector.
Bitmask flag for "const".
int bytes() const
The number of bytes required to store a single scalar value of this type.
#define internal_assert(c)
IEEE floating point numbers.
HALIDE_ALWAYS_INLINE bool can_overflow_int() const
uint8_t code
The basic type code: signed integer, unsigned integer, or floating point.
HALIDE_ALWAYS_INLINE bool is_float() const
Is this type a floating point type (float or double).
signed __INT8_TYPE__ int8_t
Type Handle(int lanes=1, const halide_handle_cplusplus_type *handle_type=nullptr)
Construct a handle type.
bool operator<(const halide_cplusplus_type_name &rhs) const
Modifier
One set of modifiers on a type.
HALIDE_ALWAYS_INLINE bool is_uint() const
Is this type an unsigned integer type?
HALIDE_ALWAYS_INLINE int lanes() const
Return the number of vector elements in this type.
Expr max() const
Return an expression which is the maximum value of this type.
std::vector< std::string > namespaces
halide_handle_cplusplus_type(const halide_cplusplus_type_name &inner_name, const std::vector< std::string > &namespaces={}, const std::vector< halide_cplusplus_type_name > &enclosing_types={}, const std::vector< uint8_t > &modifiers={}, ReferenceType reference_type=NotReference)
bool same_handle_type(const Type &other) const
Check that the type name of two handles matches.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline, and contains methods to using Halide's bounds tools to query properties of it.
HALIDE_ALWAYS_INLINE bool is_bfloat() const
Is this type a floating point type (float or double).
int(* halide_task_t)(void *user_context, int task_number, uint8_t *closure)
Define halide_do_par_for to replace the default thread pool implementation.
Type element_of() const
Produce the scalar type (that of a single element) of this vector type.
unsigned __INT8_TYPE__ uint8_t
Class that provides a type that implements half precision floating point using the bfloat16 format...
bool operator<(const Type &other) const
Compare ordering of two types so they can be used in certain containers and algorithms.
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.
HALIDE_ALWAYS_INLINE bool can_overflow() const
halide_c_type_to_name is a utility class used to provide a user-extensible way of naming Handle types...
Type narrow() const
Return Type with the same type code and number of lanes, but with at most half as many bits...
Bitmask flag for a pointer "*".
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...
static const halide_type_code_t Int
Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ s...
bool operator!=(const Type &other) const
Compare two types for inequality.
bool operator==(const halide_cplusplus_type_name &rhs) const
Type with_bits(int new_bits) const
Return Type with same type code and lanes, but new_bits for the number of bits.
HALIDE_ALWAYS_INLINE bool is_vector() const
Is this type a vector type? (lanes() != 1).
halide_cplusplus_type_name(CPPTypeType cpp_type_type, const std::string &name)
#define HALIDE_DECLARE_EXTERN_SIMPLE_TYPE(T)
HALIDE_ALWAYS_INLINE bool is_handle() const
Is this type an opaque handle type (void *)
Class that provides a type that implements half precision floating point (IEEE754 2008 binary16) in s...
static const halide_type_code_t Handle
Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ s...
uint8_t bits
The number of bits of precision of a single scalar value of this type.
A structure to represent the fully scoped name of a C++ composite type for use in generating function...
This file declares the routines used by Halide internally in its runtime.
const halide_handle_cplusplus_type * handle_type
Type to be printed when declaring handles of this type.
HALIDE_ALWAYS_INLINE int bits() const
Return the bit size of a single element of this type.
Each GPU API provides a halide_device_interface_t struct pointing to the code that manages device all...
std::vector< halide_cplusplus_type_name > enclosing_types
opaque pointer type (void *)
Type BFloat(int bits, int lanes=1)
Construct a floating-point type in the bfloat format.
static const halide_type_code_t UInt
Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ s...
unsigned __INT32_TYPE__ uint32_t
HALIDE_ALWAYS_INLINE bool is_int_or_uint() const
Is this type an integer type of any sort?
std::vector< uint8_t > cpp_type_modifiers
Qualifiers and indirections on type. 0 is innermost.
bool is_min(uint64_t) const
Check if an integer constant value is the maximum or minimum representable value for this type...
bool operator==(const halide_type_t &other) const
Compare two types for equality.
static halide_handle_cplusplus_type make()
signed __INT64_TYPE__ int64_t
static HALIDE_ALWAYS_INLINE const halide_handle_cplusplus_type * type_info()
Type Bool(int lanes=1)
Construct a boolean type.
HALIDE_ALWAYS_INLINE bool is_scalar() const
Is this type a scalar type? (lanes() == 1).
Expr min() const
Return an expression which is the minimum value of this type.
bool is_max(uint64_t) const
Check if an integer constant value is the maximum or minimum representable value for this type...
A parallel task to be passed to halide_do_parallel_tasks.
#define HALIDE_ALWAYS_INLINE
Bitmask flag for "restrict".
static halide_cplusplus_type_name name()
Bitmask flag for "volatile".
HALIDE_ALWAYS_INLINE auto is_const(A &&a) noexcept -> IsConst< decltype(pattern_arg(a))>
A runtime tag for a type in the halide type system.
halide_cplusplus_type_name inner_name
ReferenceType reference_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...
Type UInt(int bits, int lanes=1)
Constructing an unsigned integer type.
HALIDE_ALWAYS_INLINE bool is_int() const
Is this type a signed integer type?
unsigned __INT16_TYPE__ uint16_t
floating point numbers in the bfloat format
Types in the halide type system.
static constexpr bool known_type
halide_type_code_t
Types in the halide type system.
ReferenceType
References are separate because they only occur at the outermost level.
enum halide_cplusplus_type_name::CPPTypeType cpp_type_type
A set of types to represent a C++ function signature.
The raw representation of an image passed around by generated Halide code.
int(* halide_loop_task_t)(void *user_context, int min, int extent, uint8_t *closure, void *task_parent)
A task representing a serial for loop evaluated over some range.
unsigned __INT64_TYPE__ uint64_t
HALIDE_ALWAYS_INLINE halide_type_code_t code() const
Return the underlying data type of an element as an enum value.
Type type_of()
Construct the halide equivalent of a C type.
A struct representing a semaphore and a number of items that must be acquired from it...
signed __INT32_TYPE__ int32_t
Bitmask flag for a function typedef; when this is set, Pointer should also always be set...
Type Int(int bits, int lanes=1)
Constructing a signed integer type.
signed __INT16_TYPE__ int16_t
Type widen() const
Return Type with the same type code and number of lanes, but with at least twice as many bits...
bool can_represent(Type other) const
Can this type represent all values of another type?
HALIDE_ALWAYS_INLINE bool is_bool() const
Is this type boolean (represented as UInt(1))?
std::string type_to_c_type(Type type, bool include_space, bool c_plus_plus=true)
Halide type to a C++ type.
Type Float(int bits, int lanes=1)
Construct a floating-point type.
bool operator!=(const halide_cplusplus_type_name &rhs) const
An opaque struct representing a semaphore.
std::string extract_namespaces(const std::string &name, std::vector< std::string > &namespaces)
Returns base name and fills in namespaces, outermost one first in vector.
Type & operator=(const Type &that)=default
Trivial copy assignment operator.