Page MenuHomePhabricator

[mlir][tosa] Add lowering for tosa.scatter to linalg
AcceptedPublic

Authored by rsuderman on Sep 7 2021, 3:30 PM.

Details

Summary

TOSA's scatter lowering is implemented by reducing accross the batch dimension.
It would be better to perform a write to the input per-input value however this
is not supported by our existing dialects. Includes a simple lit validation
test.

Diff Detail

Unit TestsFailed

TimeTest
20 msx64 windows > Clang.CodeGen/aarch64-sve-intrinsics::acle_sve_st1b.c
shell parser error on: ": 'RUN: at line 3'; c:\\ws\\w8\\llvm-project\\premerge-checks\\build\\bin\\clang.exe -cc1 -internal-isystem c:\\ws\\w8\\llvm-project\\premerge-checks\\build\\lib\\clang\\14.0.0\\include -nostdsysteminc -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - -emit-llvm C:\\ws\\w8\\llvm-project\\premerge-checks\\clang\\test\\CodeGen\\aarch64-sve-intrinsics\\acle_sve_st1b.c |& c:\\ws\\w8\\llvm-project\\premerge-checks\\build\\bin\\filecheck.exe C:\\ws\\w8\\llvm-project\\premerge-checks\\clang\\test\\CodeGen\\aarch64-sve-intrinsics\\acle_sve_st1b.c"
0 msx64 windows > Clang.CodeGen/aarch64-sve-intrinsics::acle_sve_st1h.c
shell parser error on: ": 'RUN: at line 3'; c:\\ws\\w8\\llvm-project\\premerge-checks\\build\\bin\\clang.exe -cc1 -internal-isystem c:\\ws\\w8\\llvm-project\\premerge-checks\\build\\lib\\clang\\14.0.0\\include -nostdsysteminc -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - -emit-llvm C:\\ws\\w8\\llvm-project\\premerge-checks\\clang\\test\\CodeGen\\aarch64-sve-intrinsics\\acle_sve_st1h.c |& c:\\ws\\w8\\llvm-project\\premerge-checks\\build\\bin\\filecheck.exe C:\\ws\\w8\\llvm-project\\premerge-checks\\clang\\test\\CodeGen\\aarch64-sve-intrinsics\\acle_sve_st1h.c"
0 msx64 windows > Clang.CodeGen/aarch64-sve-intrinsics::acle_sve_st1w.c
shell parser error on: ": 'RUN: at line 3'; c:\\ws\\w8\\llvm-project\\premerge-checks\\build\\bin\\clang.exe -cc1 -internal-isystem c:\\ws\\w8\\llvm-project\\premerge-checks\\build\\lib\\clang\\14.0.0\\include -nostdsysteminc -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - -emit-llvm C:\\ws\\w8\\llvm-project\\premerge-checks\\clang\\test\\CodeGen\\aarch64-sve-intrinsics\\acle_sve_st1w.c |& c:\\ws\\w8\\llvm-project\\premerge-checks\\build\\bin\\filecheck.exe C:\\ws\\w8\\llvm-project\\premerge-checks\\clang\\test\\CodeGen\\aarch64-sve-intrinsics\\acle_sve_st1w.c"
980 msx64 windows > Clang.Index::complete-macros.c
Script: -- : 'RUN: at line 28'; c:\ws\w8\llvm-project\premerge-checks\build\bin\c-index-test.exe -code-completion-at=C:\ws\w8\llvm-project\premerge-checks\clang\test\Index\complete-macros.c:7:1 C:\ws\w8\llvm-project\premerge-checks\clang\test\Index\complete-macros.c -IC:\ws\w8\llvm-project\premerge-checks\clang\test\Index | c:\ws\w8\llvm-project\premerge-checks\build\bin\filecheck.exe -check-prefix=CHECK-CC0 C:\ws\w8\llvm-project\premerge-checks\clang\test\Index\complete-macros.c

Event Timeline

rsuderman created this revision.Sep 7 2021, 3:30 PM
rsuderman requested review of this revision.Sep 7 2021, 3:31 PM
mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
2501

You should be able to compress those significantly:

using MapList = ArrayRef<ArrayRef<AffineExpr>>;
auto infer = [](MapList m) { return AffineMap::inferFromExprList(m); };
AffineExpr m, n, o, p;
bindDims(rewriter.getContext(), m, n, o, p);
SmallVector<AffineMap, 4> affineMaps = infer({m, n, o}, {m, p}, {m, p, o});
rsuderman updated this revision to Diff 371420.EditedSep 8 2021, 12:49 PM

Updated for Nicolas's comments.

rsuderman marked an inline comment as done.Sep 8 2021, 12:49 PM
nicolasvasilache accepted this revision.Sep 8 2021, 1:12 PM

Code looks good to me, I am not sure about the semantics of the op itself so someone else please cehck this.

This revision is now accepted and ready to land.Sep 8 2021, 1:12 PM