Page MenuHomePhabricator

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

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



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



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.

The code here hits a g++ bug ( 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

Feel free to send a patch!