Commit 5076adf6 authored by Tom Hennigan's avatar Tom Hennigan Committed by TensorFlower Gardener
Browse files

Expose Module._flatten to allow subclasses to implement gathering.

I've made this "private" since this exposes the implementation of modules, which
in typical Python code does not represent part of the classes public API. As
such I think having the leading _ makes it clear (at least to the linter) that
you're using an "internal" method. As always this is a "sign" not a cop.

As a concrete example, I strongly encourage the following usage:

    >>> class FooModule(...):
    ...   @property
    ...   def hash_tables(self):
    ...     return tuple(self._flatten(predicate=IS_HASH_TABLE))

But in general we should discourage usage outside of modules:

    >>> m = FooModule()
    >>> hash_tables = tuple(m._flatten(predicate=IS_HASH_TABLE))  # Naughty.

c.f. tensorflow/community#56

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