Page MenuHomePhabricator

[mlir][DenseElementsAttr] Add support for opaque APFloat/APInt complex values.
ClosedPublic

Authored by rriddle on May 2 2020, 2:32 PM.

Details

Summary

This revision allows for creating DenseElementsAttrs and accessing elements using std::complex<APInt>/std::complex<APFloat>. This allows for opaquely accessing and transforming complex values. This is used by the printer/parser to provide pretty printing for complex values. The form for complex values matches that of std::complex, i.e.:

// `(` element `,` element `)`
dense<(10,10)> : tensor<complex<i64>>

Depends On D79281

Diff Detail

Event Timeline

rriddle created this revision.May 2 2020, 2:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2020, 2:32 PM
Smit added a subscriber: Smit.May 4 2020, 4:17 PM

Neat!

mlir/unittests/IR/AttributeTest.cpp
30

Also, dump the values?

Smit accepted this revision.May 4 2020, 4:18 PM
This revision is now accepted and ready to land.May 4 2020, 4:18 PM
This revision was automatically updated to reflect the committed changes.
kiranchandramohan added inline comments.
mlir/lib/IR/AsmPrinter.cpp
1548–1558

The code here hits a g++ bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90538) in gcc-9.1/gcc-9.2. This seems to be fixed in 9.3. Will you accept a workaround for this?

/home/user02/open_source/llvm-project/mlir/lib/IR/AsmPrinter.cpp: In instantiation of ‘{anonymous}::ModulePrinter::printDenseIntOrFPElementsAttr(mlir::DenseIntOrFPElementsAttr, bool)::<lambda(auto:2, auto:3, llvm::raw_ostream&, auto:4&& ...)> [with auto:2 = llvm::iterator_range<mlir::DenseElementsAttr::ComplexIntElementIterator>; auto:3 = void (*)(const llvm::APInt&, llvm::raw_ostream&, bool); auto:4 = {bool}]’:
/home/user02/open_source/llvm-project/mlir/lib/IR/AsmPrinter.cpp:1565:77:   required from here
/home/user02/open_source/llvm-project/mlir/lib/IR/AsmPrinter.cpp:1557:42: error: redeclaration of ‘bool& params#0’
 1557 |         printFn(complexValue.imag(), os, params...);
      |                                          ^~~~~~
/home/user02/open_source/llvm-project/mlir/lib/IR/AsmPrinter.cpp:1555:42: note: ‘bool& params#0’ previously declared here
 1555 |         printFn(complexValue.real(), os, params...);
      |                                          ^~~~~~
mehdi_amini added inline comments.Jun 14 2020, 5:41 PM
mlir/lib/IR/AsmPrinter.cpp
1548–1558

Feel free to send a patch!