Skip to content

Remove params in python perform method #511

@ricardoV94

Description

@ricardoV94

Description

params are used to write C code that is shared among different parametrizations of the same Op class, such as an Op with self.inplace = True vs False: https://pytensor.readthedocs.io/en/latest/extending/using_params.html

They are also supposed to be passed to the python perform method (for those Ops that implement it), which we forgot to do when we implemented Blockwise. This seems unnecessary, and in fact many Ops just ignore params, and use node properties directly:

def perform(self, node, inputs, out_, params):
(out,) = out_
sh = tuple([int(i) for i in inputs])
if out[0] is None or out[0].shape != sh:
out[0] = np.empty(sh, dtype=self.dtype)

I could only find 3 cases where it was being used, including:

if not params.inplace:
z = z.copy() # the original z will not be changed

The complication of the signature doesn't seem justified, for something that is clearly focused on the C backend. There is even a warning in the docs linked above:

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions