This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] Add codegen rule for the push_back operator.
ClosedPublic

Authored by bixia on Sep 21 2022, 9:32 AM.

Diff Detail

Event Timeline

bixia created this revision.Sep 21 2022, 9:32 AM
Herald added a project: Restricted Project. · View Herald Transcript
bixia requested review of this revision.Sep 21 2022, 9:32 AM
Peiming added inline comments.Sep 21 2022, 10:09 AM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
636

I am sorry that I missed your previous patch (which introduces the operator).

But would it be better if we get rid of idx from the push_back operator? the memref<?xindex> size array can first be viewed into a single memref<index> to construct the push_back operator? I feel this way might be cleaner?

Other than that, the patch LGTM.

bixia added inline comments.Sep 21 2022, 1:24 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
636

Per offline discussion, we will re-evaluate this approach later as it introduces memory aliasing.

aartbik accepted this revision.Sep 21 2022, 1:37 PM
aartbik added inline comments.
mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_codegen_push_back.mlir
20

Thanks for adding a integration!

This revision is now accepted and ready to land.Sep 21 2022, 1:37 PM
This revision was landed with ongoing or failed builds.Sep 22 2022, 9:10 AM
This revision was automatically updated to reflect the committed changes.

sparse_codegen_push_back.mlir is seemingly failing in asan builds:

==62819==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000011c34 at pc 0x55fd675ed144 bp 0x7ffd7761ed30 sp 0x7ffd7761e4f8
READ of size 8 at 0x602000011c34 thread T0
    #0 0x55fd675ed143 in memcpy (/home/river/llvm-project/build/bin/mlir-cpu-runner+0x4423143) (BuildId: 3d88374a90e38509)
    #1 0x7f104d2840b3  (<unknown module>)
    #2 0x7f104d28418c  (<unknown module>)
    #3 0x55fd68c4f97b in compileAndExecute((anonymous namespace)::Options&, mlir::ModuleOp, llvm::StringRef, (anonymous namespace)::CompileAndExecuteConfig, void**) /home/river/llvm-project/mlir/lib/ExecutionEngine/JitRunner.cpp:234:3
    #4 0x55fd68c4daca in compileAndExecuteVoidFunction((anonymous namespace)::Options&, mlir::ModuleOp, llvm::StringRef, (anonymous namespace)::CompileAndExecuteConfig) /home/river/llvm-project/mlir/lib/ExecutionEngine/JitRunner.cpp:250:10
    #5 0x55fd68c47dfa in mlir::JitRunnerMain(int, char**, mlir::DialectRegistry const&, mlir::JitRunnerConfig) /home/river/llvm-project/mlir/lib/ExecutionEngine/JitRunner.cpp:383:23
    #6 0x55fd67692d31 in main /home/river/llvm-project/mlir/tools/mlir-cpu-runner/mlir-cpu-runner.cpp:33:10
    #7 0x7f104f319082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
    #8 0x55fd675d2efd in _start (/home/river/llvm-project/build/bin/mlir-cpu-runner+0x4408efd) (BuildId: 3d88374a90e38509)

0x602000011c34 is located 0 bytes to the right of 4-byte region [0x602000011c30,0x602000011c34)
allocated by thread T0 here:
    #0 0x55fd6765560e in malloc (/home/river/llvm-project/build/bin/mlir-cpu-runner+0x448b60e) (BuildId: 3d88374a90e38509)
    #1 0x7f104d28402a  (<unknown module>)
    #2 0x55fd68c4daca in compileAndExecuteVoidFunction((anonymous namespace)::Options&, mlir::ModuleOp, llvm::StringRef, (anonymous namespace)::CompileAndExecuteConfig) /home/river/llvm-project/mlir/lib/ExecutionEngine/JitRunner.cpp:250:10
    #3 0x55fd68c47dfa in mlir::JitRunnerMain(int, char**, mlir::DialectRegistry const&, mlir::JitRunnerConfig) /home/river/llvm-project/mlir/lib/ExecutionEngine/JitRunner.cpp:383:23
    #4 0x55fd67692d31 in main /home/river/llvm-project/mlir/tools/mlir-cpu-runner/mlir-cpu-runner.cpp:33:10
    #5 0x7f104f319082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)

SUMMARY: AddressSanitizer: heap-buffer-overflow (/home/river/llvm-project/build/bin/mlir-cpu-runner+0x4423143) (BuildId: 3d88374a90e38509) in memcpy