[PATCH] D78093: [mlir] [EDSC] Add interface for yield-for loops.

Pierre Oechsel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 03:41:07 PDT 2020


poechsel created this revision.
Herald added subscribers: llvm-commits, frgossen, grosul1, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a reviewer: nicolasvasilache.
Herald added a project: LLVM.
poechsel retitled this revision from "[mlir] [EDSC] Add interface for  yield-for loops." to "[mlir] [EDSC] Add interface for yield-for loops.".
poechsel edited the summary of this revision.
poechsel updated this revision to Diff 257266.
poechsel added a comment.
poechsel edited the summary of this revision.

Renames 'arguments' to 'iter_args_init_values' and 'argument_handles' to 'iter_args_handles'.
Swapped position of the arguments 'arguments' and 'argument_handles' to mimic the position in mlir.


ModelBuilder was missing an api to easily generate yield-for-loops. 
This diffs implements an interface allowing to write:

  %2:2 = loop.for %i = %start to %end step %step iter_args(%arg0 = %init0, %arg1 = %init1) -> (f32, f32) {
    %sum = addf %arg0, %arg1 : f32
    loop.yield %arg1, %sum : f32, f32
  }
  %3 = addf %2#0, %2#1 : f32

as

  auto results =
      LoopNestBuilder(&i, start, end, step, {&arg0, &arg1},  {init0, init1})([&] {
        auto sum = arg0 + arg1;
        loop_yield(ArrayRef<ValueHandle>{arg1, sum});
      });
  
  // Add the two values accumulated by the yield-for-loop:
  ValueHandle(results[0]) + ValueHandle(results[1]);


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78093

Files:
  mlir/include/mlir/Dialect/LoopOps/EDSC/Builders.h
  mlir/include/mlir/Dialect/LoopOps/EDSC/Intrinsics.h
  mlir/include/mlir/EDSC/Builders.h
  mlir/lib/Dialect/LoopOps/EDSC/Builders.cpp
  mlir/test/EDSC/builder-api-test.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78093.257266.patch
Type: text/x-patch
Size: 8802 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200414/ab07ef8f/attachment.bin>


More information about the llvm-commits mailing list