pymc-devs / pymc-devs/pytensor

Document `output_types_preference` in ScalarOp

Open
#1,617 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs Op implementation
Dominant language
Python
Stars
644
Forks
208
Avg merge
2d 14h
Merged PRs (30d)
16

Description

Description

ScalarOps are parametrized by an output_types_preference that determines the output types from the input types in make_node (unless an Op overrides make_node). This is used indirectly via output_types. The design is somewhat convoluted, but meant to make it easier to define ScalarOps (and IIRC to tweak their behavior in the InplaceOptimizer).

The whole logic should be documented, in which process, we may find out it can be simplified. Also, everytime we use it we check whether the outputs from this function are valid, which is costly. Since nobody is really creating new output_types_preference we should just trust them.

https://github.com/pymc-devs/pytensor/blob/ee107cbafd7257d52d9877dbb2c9b07477680392/pytensor/scalar/basic.py#L1219-L1272

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read pytensor/scalar/basic.py around lines 1219-1272 and trace how output_types_preference is used by ScalarOp.make_node and output_types, including the override case mentioned in the issue. Document the current logic and its validation checks, and leave the behavior simplified only if the surrounding code confirms that is safe.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.