Replace instances of `control_dependencies(None)` with `init_scope` when
initializing variables. Today, when variables are constructed (Resource and otherwise), we lift certain operations, including the VarHandleOp and initialization ops, out of all control flow contexts; the mechanism for doing so is entering the context manager returned by `control_dependencies(None)`. This change replaces various instances of this mechanism with `init_scope`, which clears control dependencies, lifts ops out of function-building graphs, and pauses the gradient tape. As a result, variables that are created inside graph functions will be automatically hoisted into an outer context. PiperOrigin-RevId: 183320576
Loading
Please sign in to comment