tinygrad realize
Note
You likely want the upstream tinygrad, not tinygrab. Tinygrab contains AI generated docstrings for a tinygrad snapshot. Upstream: https://tinygrad.org
- class tinygrad.realize.CustomOp(fxn)[source]
Bases:
JITRunner
This class represents a custom operation that can be executed by the JITRunner.
- fxn
The function to be called when this operation is executed.
- Type:
function
- tinygrad.realize.lower_schedule_item(si: ScheduleItem) JITRunner | None [source]
Lower a schedule item to a JIT runner.
This function takes a ScheduleItem and returns an optional JITRunner. If the schedule item is empty, it returns None. If the operation is of type LoadOps.FROM, it returns BufferCopy. If the operation is of type LoadOps.CUSTOM, it returns CustomOp with argument si.ast.arg. Otherwise, it gets a runner from Device based on the output’s device.
- Parameters:
si (ScheduleItem) – The schedule item to lower.
- Returns:
Optional[JITRunner]
- tinygrad.realize.run_schedule(schedule: List[ScheduleItem], disable_logging=False)[source]
Run the schedule of operations.
This function pops the first ScheduleItem from the schedule and checks if logging is disabled. If not, it logs the schedule item. It then asserts that all inputs have been realized, raising an error otherwise. Then, it lowers the schedule item to a program (not shown), creates an output buffer if one doesn’t exist already, and deletes the output buffer’s operation and its views’ operations. Finally, it executes the program with the realized outputs and inputs, along with variable values.
- Parameters:
schedule (List[ScheduleItem]) – A list of ScheduleItems to be executed.
disable_logging (bool, optional) – Whether or not to disable logging, defaults to False