pytensor icon indicating copy to clipboard operation
pytensor copied to clipboard

Deprecate / rewrite esoteric Ops

Open ricardoV94 opened this issue 10 months ago • 1 comments

Description

Make our codebase more leightweight by removing:

  • pytensor.tensor.basic.PermuteRowElements
  • pytensor.tensor.io.LoadFromDisk

Replace by symbolic equivalent:

  • pytensor.tensor.extra_ops.Bartlett (can be implemented symbolic easily: https://github.com/numpy/numpy/blob/e7a123b2d3eca9897843791dd698c1803d9a39c2/numpy/lib/_function_base_impl.py#L3254-L3262)
  • pytensor.tensor.extra_ops.UnravelIndex (not sure how feasible)
  • pytensor.tensor.extra_ops.RavelMultiIndex (not sure how feasible)
  • Several RVs: #1221
  • Several ScalarOps need not exist: #1092
    • Also: xlogx, xlogy0, can just be switch statements?

ricardoV94 avatar Feb 14 '25 15:02 ricardoV94

Here is the code to get a list of all Ops (with some base classes in the mix):

from pytensor.graph.op import Op

def get_all_subclasses(cls):
    all_subclasses = []

    for subclass in cls.__subclasses__():
        all_subclasses.append(subclass)
        all_subclasses.extend(get_all_subclasses(subclass))

    return all_subclasses

for op in sorted(set(get_all_subclasses(Op)), key=str):
    print(op)

ricardoV94 avatar Mar 18 '25 07:03 ricardoV94