Skip to main content

cacheable

Function cacheable 

Source
pub fn cacheable(graph: &Graph, memory: &Memory) -> Result<(), MemoryError>
Expand description

Whether what this graph says to keep can honestly be kept. A free function for the same reason compile is one: it needs the graph and the table.

A node’s output can be kept if nothing upstream of it can change — itself included.

Freezing the node alone is not enough: what is restored from a store is a leaf, so the backward pass stops there and everything above it quietly stops training. The same rule falls out without mentioning gradients — the digest of the state is in the key, so a node that keeps changing never hits and only fills the store. Being named is checked in the same walk, since a chain with a hole in it delivers no key below.