Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
frreiss opened this issue Jan 23, 2019 · 0 comments
Open

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

frreiss opened this issue Jan 23, 2019 · 0 comments

Comments

@frreiss
Copy link
Member

frreiss commented Jan 23, 2019

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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant