Skip to content

Reconsider handlig of constants in numba backend #1759

@ricardoV94

Description

@ricardoV94

Description

In the numba backend (and all Jitted backends), we massage constants into global variables of the codegen function.

This poses has a couple of issues for the Numba backend:

  1. Functions with large arrays can't be cached
  2. The number of cached functions grows with small differences in the global arrays, but otherwise identical structure (not sure how common)
  3. Functions with more esoteric constant types can't be compiled: SparseVariables, RandomGenerator, TypedLists (see failures in Implement Sparse Ops in Numba #1676 and Run whole test suite on numba backend #811)

We could adopt the approach that the C-backend takes, which is to just use pointers to the storage list created by PyTensor function, for these constants. We only inline scalars in the C-backend codegen. This would work-around all the issues listed above.

On the downside, I'm not sure how hard it would make things for nutpie. CC @aseyboldt

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