Skip to content

Commit b9c963e

Browse files
committed
Remove unused rewrites and functionality
1 parent 40ccab1 commit b9c963e

File tree

7 files changed

+16
-450
lines changed

7 files changed

+16
-450
lines changed

pytensor/graph/features.py

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -827,71 +827,6 @@ def validate(self, fgraph):
827827
raise InconsistencyError("Trying to reintroduce a removed node")
828828

829829

830-
class NodeFinder(Bookkeeper):
831-
def __init__(self):
832-
self.fgraph = None
833-
self.d = {}
834-
835-
def on_attach(self, fgraph):
836-
if hasattr(fgraph, "get_nodes"):
837-
raise AlreadyThere("NodeFinder is already present")
838-
839-
if self.fgraph is not None and self.fgraph != fgraph:
840-
raise Exception("A NodeFinder instance can only serve one FunctionGraph.")
841-
842-
self.fgraph = fgraph
843-
fgraph.get_nodes = partial(self.query, fgraph)
844-
Bookkeeper.on_attach(self, fgraph)
845-
846-
def clone(self):
847-
return type(self)()
848-
849-
def on_detach(self, fgraph):
850-
"""
851-
Should remove any dynamically added functionality
852-
that it installed into the function_graph
853-
"""
854-
if self.fgraph is not fgraph:
855-
raise Exception(
856-
"This NodeFinder instance was not attached to the provided fgraph."
857-
)
858-
self.fgraph = None
859-
del fgraph.get_nodes
860-
Bookkeeper.on_detach(self, fgraph)
861-
862-
def on_import(self, fgraph, node, reason):
863-
try:
864-
self.d.setdefault(node.op, []).append(node)
865-
except TypeError: # node.op is unhashable
866-
return
867-
except Exception as e:
868-
print("OFFENDING node", type(node), type(node.op), file=sys.stderr) # noqa: T201
869-
try:
870-
print("OFFENDING node hash", hash(node.op), file=sys.stderr) # noqa: T201
871-
except Exception:
872-
print("OFFENDING node not hashable", file=sys.stderr) # noqa: T201
873-
raise e
874-
875-
def on_prune(self, fgraph, node, reason):
876-
try:
877-
nodes = self.d[node.op]
878-
except TypeError: # node.op is unhashable
879-
return
880-
nodes.remove(node)
881-
if not nodes:
882-
del self.d[node.op]
883-
884-
def query(self, fgraph, op):
885-
try:
886-
all = self.d.get(op, [])
887-
except TypeError:
888-
raise TypeError(
889-
f"{op} in unhashable and cannot be queried by the optimizer"
890-
)
891-
all = list(all)
892-
return all
893-
894-
895830
class PrintListener(Feature):
896831
def __init__(self, active=True):
897832
self.active = active

0 commit comments

Comments
 (0)