Commit 969f5a06 authored by A. Unique TensorFlower's avatar A. Unique TensorFlower Committed by TensorFlower Gardener
Browse files

Refactoring and bug-fixes for _build_initializer_expr.

- Rename _build_initializer_expr to _try_guard_against_uninitialized_dependencies so as to clarify what it does.

- Avoid invoking the logic in _try_guard_against_uninitialized_dependencies for cyclic graphs. This currently results in infinite recursion which blows the stack.

- Use memoization to reduce the number of redundant operations created by _try_guard_against_uninitialized_dependencies when it encounters initial values with diamond-shaped dependencies.

- Refactoring: Remove unnecessary logic in _try_guard_against_uninitialized_dependencies for dealing with types other than Tensor or Operation. The dependency graph of a Variable's _initial_value should only ever comprise these two types.

- Refactoring: Added some filtering logic to _try_guard_against_uninitialized_dependencies to avoid initial_values with cyclic dependencies

- Refactoring: Moved the recursive traversal of initial_value`s dependencies into _safe_initial_value_from_tensor and _safe_initial_value_from_op.

- Refactoring: Made it so _find_initialized_value_for_variable will return None when it can't find the initialized_value. Currently it returns a Tensor when it finds the initialized_value and an Operation when it can't. This makes the logic in the caller a bit more consistent and explicit.

Future changes will address more of the shortcomings of _build_initializer_expr.

PiperOrigin-RevId: 180876754
parent aa84673f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment