Commit 71a25454 authored by Peter Hawkins's avatar Peter Hawkins Committed by Jacques Pienaar
Browse files

[MLIR:Python] Make DenseElementsAttr.get() only request a buffer format if no...

[MLIR:Python] Make DenseElementsAttr.get() only request a buffer format if no explicit type was provided.

Not every NumPy type (e.g., the `ml_dtypes.bfloat16` NumPy extension
type) has a type in the Python buffer protocol, so exporting such a
buffer with `PyBUF_FORMAT` may fail.

However, we don't care about the self-reported type of a buffer if the
user provides an explicit type. In the case that an explicit type is
provided, don't request the format from the buffer protocol, which
allows arrays whose element types are unknown to the buffer protocol to
be passed.

Reviewed By: jpienaar, ftynse

Differential Revision: https://reviews.llvm.org/D155209
parent c9ef33e1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment