hawk.diff.event.state_guard

Contents

hawk.diff.event.state_guard#

hawk.diff.event.state_guard(kernel)[source]#

A kernel committing each guard of kernel into event_g<i> as a function of the state AFTER the step, named <name>_state_guard: every value the step commits is read back from its own plane (the time plane included), so its vjp() is g_x over the extended state — what a graze test measures at a located event. A guard that also reads a value the step does not commit reads it as a plain plane.

Example:

@hawk.kernel(steps=1, time="t", time_step="dt")
def osc(dt: Param, a: Param, terminated: Terminated,
        x: Mutable[Scalar], v: Mutable[Scalar], t: Mutable[Scalar]):
    v_start = v
    v = v_start - dt * x
    x = x + dt * v_start
    t = t + dt
    terminated = x <= a * t

state_guard(osc)   # event_g0 = a*t - x... read from the planes x, t
Return type:

Any

Parameters:

kernel (Any)