Skip to content

abstract value protocol / ShapeDtypeStruct distinction #18459

Open
@froystig

Description

@froystig

Several of our APIs (jax.linearize, AOT lowering, jax.make_jaxpr, ...) emphasize duck-typed arguments that correspond to abstract values/arrays. We stress in documentation that any object with shape and dtype (etc.) is acceptable. But then we annotate these APIs with the concrete jax.ShapeDtypeStruct, contradicting the docs.

One way forward may be to define a Protocol type, use it as the annotation, and continue to expose jax.ShapeDtypeStruct for convenience.

(It's a bit unclear to me what to name this protocol. ShapeDtypeStruct itself is already arguably a misnomer, since there are other optional fields there too.)

Metadata

Metadata

Assignees

Labels

cleanupCode cleanups and improvementsenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions