Skip to content

Tweak pm.Data to create or auto-replace by TensorConstant #5105

Closed
@michaelosthege

Description

@michaelosthege

Background

pm.Data is often used to track data in the model, making it end up in the InferenceData and so on.

Right now this always creates shared variables, but in the vast majority of applications one doesn't actually use the shared variable features.

Generally there are three (?) flavors of data variables:

  • constant (could be a TensorConstant instead)
  • shared with constant shape
  • shared with flexible shape (constant ndim)

AFAIK Aesara does not distinguish between shared variables that can, or cannot be resized.

Motivation

But the difference between TensorConstant and SharedVariable is a thing, and sometimes also costly.
For example see #3818

Potential solution

  • Additional kwargs to pm.Data through which one can constrain the flexibility (creating TensorConstant instead).
  • Automatically replacing all SharedVariables in the graph with TensorConstant before starting MCMC.

Versions and main components

  • PyMC/PyMC3 Version: main

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