Created
November 24, 2017 18:20
-
-
Save ryanrhymes/c31dc124814a7549df3abdad904272bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* find the root inputs of [x] *) | |
let find_roots x = | |
let s = Owl_utils.Stack.make () in | |
let rec _find x = | |
Array.iter (fun n -> | |
if n.op = Noop then Owl_utils.Stack.push s n | |
else _find n | |
) x.prev | |
in | |
_find x; | |
Owl_utils.Stack.to_array s | |
(* update [x]'s dependency graph by invalidating stale nodes *) | |
let update_graph x = | |
let rec _update x = | |
let valid = ref (is_valid x) in | |
Array.iter (fun n -> | |
valid := !valid || _update n | |
) x.prev; | |
if !valid = false then invalidate x; | |
!valid | |
in | |
_update x |> ignore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment