tinygrad renderer.llvmir
Note
You likely want the upstream tinygrad, not tinygrab. Tinygrab contains AI generated docstrings for a tinygrad snapshot. Upstream: https://tinygrad.org
- tinygrad.renderer.llvmir.cast(bb, val, input_type, output_type)[source]
Cast a value from one type to another.
- tinygrad.renderer.llvmir.bb
The basic block where the operation will be added.
- Type:
ir.BasicBlock
- tinygrad.renderer.llvmir.val
The value to cast.
- Type:
ir.Value
- tinygrad.renderer.llvmir.input_type
The current data type of the value.
- Type:
dtypes.*
- tinygrad.renderer.llvmir.output_type
The desired data type after casting.
- Type:
dtypes.*
- Returns:
The casted value with the new data type.
- Return type:
ir.Value
- Raises:
NotImplementedError – If the cast from input_type to output_type is not implemented.
- tinygrad.renderer.llvmir.const(args, dtype)[source]
Create a constant value based on the given arguments and data type.
- tinygrad.renderer.llvmir.args
The input argument to be converted into a constant. Can be of any type.
- Type:
any
- tinygrad.renderer.llvmir.dtype
The data type of the constant. Must be one of the supported dtypes.
- Type:
str
- Returns:
A constant object with the specified value and data type.
- Return type:
ir.Constant
- tinygrad.renderer.llvmir.is_bool(t: Type)[source]
Determine if the input type is a boolean.
Checks whether the given type is an instance of ir.IntType and its width is 1, which indicates that it’s a boolean type.
- Parameters:
t (ir.Type) – The input type to check.
- Returns:
True if the input type is a boolean, False otherwise.
- Return type:
bool
- tinygrad.renderer.llvmir.uops_to_llvm_ir(function_name: str, uops: List[UOp]) Tuple[str, Dict] [source]
Convert a list of uops to an LLVM IR module.
Creates an LLVM module containing the specified function, which is populated with the provided uops. The function’s arguments are determined by global buffers defined in the uops.
- Parameters:
function_name (str) – Name for the LLVM function.
uops (List[UOp]) – List of UOp objects to be converted to LLVM IR.
- Returns:
A tuple containing the generated LLVM IR module as a string, and a dictionary mapping buffer names to their data types.
- Return type:
Tuple[str, Dict]
- tinygrad.renderer.llvmir.module
LLVM module object.
- Type:
ir.Module
- tinygrad.renderer.llvmir.buf_to_dtype
Dictionary mapping global buffer names to their corresponding data types.
- Type:
Dict[str, dtype]
- tinygrad.renderer.llvmir.buf_index
Dictionary mapping global buffer names to their indices.
- Type:
Dict[str, int]
- tinygrad.renderer.llvmir.func_dtypes
List of tuples containing LLVM type objects and their corresponding data types.
- Type:
List[Tuple[ir.Type, dtype]]
- tinygrad.renderer.llvmir.func
LLVM function object.
- Type:
ir.Function