This is an archive of the discontinued LLVM Phabricator instance.

[mlir][tosa] : adding folder and canonicalizer for select
ClosedPublic

Authored by lipracer on Mar 11 2022, 10:09 PM.

Details

Summary

define canonicalizer and folder for tosa::select

Diff Detail

Event Timeline

lipracer created this revision.Mar 11 2022, 10:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2022, 10:09 PM
lipracer requested review of this revision.Mar 11 2022, 10:09 PM
lipracer updated this revision to Diff 414813.Mar 12 2022, 12:00 AM

update patch rebase on latest

mehdi_amini added inline comments.Mar 12 2022, 9:43 AM
mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
624

What is the issue with clang-format here? It is fairly rare that we have to disable clang-format, and in general it is always about some large struct initializers or things similar.

653

Nit: remove trivial braces, here and elsewhere.

661

Shouldn't this be part of a verifier?

lipracer marked 2 inline comments as done.Mar 12 2022, 11:52 AM
lipracer added inline comments.
mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
624

There is an indenter on line 593 on the left of difference. I don't know why. I feel the format is strange.

lipracer updated this revision to Diff 414870.Mar 12 2022, 12:04 PM
lipracer marked an inline comment as done.
lipracer marked an inline comment as done.
lipracer abandoned this revision.Mar 24 2022, 1:11 AM
lipracer reclaimed this revision.
lipracer added a reviewer: Mogball.
Mogball added inline comments.Mar 24 2022, 2:22 PM
mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
195

how about using hasCanonicalizeMethod?

204–206
jpienaar added inline comments.
mlir/test/Dialect/Tosa/canonicalize.mlir
256

smae -> same

mehdi_amini accepted this revision.Mar 24 2022, 5:30 PM

LG, after you look into @Mogball's comments

This revision is now accepted and ready to land.Mar 24 2022, 5:30 PM
lipracer updated this revision to Diff 418120.Mar 24 2022, 8:57 PM

wrap setOperands with updateRootInPlace

lipracer updated this revision to Diff 418123.Mar 24 2022, 9:01 PM
lipracer marked an inline comment as done.

fix typo

lipracer marked an inline comment as done.Mar 24 2022, 9:03 PM
lipracer updated this revision to Diff 418146.Mar 25 2022, 12:35 AM

format code style with clang-format

Thanks,Can you help me commit this? user.name: lipracer user.email: lipracer@gmail.com

This revision was automatically updated to reflect the committed changes.

Hi @lipracer, this change has caused a build error when building with clang:

/usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DMLIR_CUDA_CONVERSIONS_ENABLED=0 -DMLIR_ROCM_CONVERSIONS_ENABLED=0 -D_DEBUG -D_GNU_SOURCE -DSTDC_CONSTANT_MACROS -DSTDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/mnt/vss/_work/1/b/llvm/Release/tools/mlir/lib/Dialect/Tosa -I/mnt/vss/_work/1/llvm-project/mlir/lib/Dialect/Tosa -I/mnt/vss/_work/1/b/llvm/Release/include -I/mnt/vss/_work/1/llvm-project/llvm/include -I/mnt/vss/_work/1/llvm-project/mlir/include -I/mnt/vss/_work/1/b/llvm/Release/tools/mlir/include -fPIC -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Werror=mismatched-tags -Werror=global-constructors -O3 -DNDEBUG -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT tools/mlir/lib/Dialect/Tosa/CMakeFiles/obj.MLIRTosa.dir/IR/TosaOps.cpp.o -MF tools/mlir/lib/Dialect/Tosa/CMakeFiles/obj.MLIRTosa.dir/IR/TosaOps.cpp.o.d -o tools/mlir/lib/Dialect/Tosa/CMakeFiles/obj.MLIRTosa.dir/IR/TosaOps.cpp.o -c /mnt/vss/_work/1/llvm-project/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
/mnt/vss/_work/1/llvm-project/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp:599:26: error: extra ';' outside of a function is incompatible with C++98 [-Werror,-Wc++98-compat-extra-semi]
ReduceFolder(ReduceAllOp);

This comment was removed by lipracer.

Hi @lipracer, this change has caused a build error when building with clang:

/usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DMLIR_CUDA_CONVERSIONS_ENABLED=0 -DMLIR_ROCM_CONVERSIONS_ENABLED=0 -D_DEBUG -D_GNU_SOURCE -DSTDC_CONSTANT_MACROS -DSTDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/mnt/vss/_work/1/b/llvm/Release/tools/mlir/lib/Dialect/Tosa -I/mnt/vss/_work/1/llvm-project/mlir/lib/Dialect/Tosa -I/mnt/vss/_work/1/b/llvm/Release/include -I/mnt/vss/_work/1/llvm-project/llvm/include -I/mnt/vss/_work/1/llvm-project/mlir/include -I/mnt/vss/_work/1/b/llvm/Release/tools/mlir/include -fPIC -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Werror=mismatched-tags -Werror=global-constructors -O3 -DNDEBUG -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT tools/mlir/lib/Dialect/Tosa/CMakeFiles/obj.MLIRTosa.dir/IR/TosaOps.cpp.o -MF tools/mlir/lib/Dialect/Tosa/CMakeFiles/obj.MLIRTosa.dir/IR/TosaOps.cpp.o.d -o tools/mlir/lib/Dialect/Tosa/CMakeFiles/obj.MLIRTosa.dir/IR/TosaOps.cpp.o -c /mnt/vss/_work/1/llvm-project/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
/mnt/vss/_work/1/llvm-project/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp:599:26: error: extra ';' outside of a function is incompatible with C++98 [-Werror,-Wc++98-compat-extra-semi]
ReduceFolder(ReduceAllOp);

I have fixed https://reviews.llvm.org/D122599, Could you please review it, It's very strange why we get normal clang-format results when we change the macro definition to uppercase.

void added a subscriber: void.Mar 28 2022, 2:02 PM

This change is resulting in these warnings:

/usr/local/google/home/morbo/llvm/llvm-project/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp:599:26: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]
ReduceFolder(ReduceAllOp);
                         ^
/usr/local/google/home/morbo/llvm/llvm-project/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp:600:26: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]
ReduceFolder(ReduceAnyOp);
                         ^
/usr/local/google/home/morbo/llvm/llvm-project/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp:601:26: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]
ReduceFolder(ReduceMaxOp);
                         ^
/usr/local/google/home/morbo/llvm/llvm-project/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp:602:26: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]
ReduceFolder(ReduceMinOp);
                         ^
/usr/local/google/home/morbo/llvm/llvm-project/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp:603:27: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]
ReduceFolder(ReduceProdOp);
                          ^
/usr/local/google/home/morbo/llvm/llvm-project/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp:604:26: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]
ReduceFolder(ReduceSumOp);
                         ^
6 warnings generated.

This change is resulting in these warnings:

I think this is what was mention right above? Can you check if the follow-up revision linked above fixed it for you as well?

void added a comment.Mar 28 2022, 4:34 PM

This change is resulting in these warnings:

I think this is what was mention right above? Can you check if the follow-up revision linked above fixed it for you as well?

It looks like it did the trick. Thanks!