[all-commits] [llvm/llvm-project] 71a254: [MLIR:Python] Make DenseElementsAttr.get() only re...

Peter Hawkins via All-commits all-commits at lists.llvm.org
Fri Jul 14 16:08:32 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 71a254543d44a943dfe8790abc60795b87173f0b
  Author: Peter Hawkins <phawkins at google.com>
  Date:   2023-07-14 (Fri, 14 Jul 2023)

  Changed paths:
    M mlir/lib/Bindings/Python/IRAttributes.cpp
    M mlir/test/python/ir/array_attributes.py

  Log Message:
  [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

More information about the All-commits mailing list