Skip to content

Refactor select.py to use object-oriented API #16

@frreiss

Description

@frreiss

The file graph_def_editor/select.py contains various routines for selecting subsets of a graph's nodes and/or tensors.

A few issues with the current organization of this file:

  • Adds 18 functions to the top-level gde namespace
  • Entry points are monolithic -- see, for example, select_s()
  • Return values are not in a single consistent format
  • No easy way to represent a selection expression as an object

To address the above issues and to facilitate the development of the "pattern" part of pattern-action rewrite rules, we should refactor these functions into a more object-oriented design:

  • Add a base class, Selector, for selection expressions over a graph. The base class will have methods to:
    • Get information about what types of things (tensors, nodes, or both) the expression can select
    • Retrieve the current set of selected graph objects as a Python list
    • Retrieve the current set of selected objects as a SubgraphView
  • Make the existing functions return subclasses of Selector
  • Put existing functions under a new namespace gde.select
  • Remove unnecessary subroutines from the top-level package
  • Refactor existing test cases to use the new APIs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions