Add a new option for printing the top-k locations by "number of operations".
This is useful for debugging code size explosions: Those locations that result in a large number of operations after running a lowering are printed.
Paths
| Differential D109672
[mlir] print-op-stats: Print top-k locations AbandonedPublic Authored by springerm on Sep 12 2021, 10:41 PM.
Details
Summary Add a new option for printing the top-k locations by "number of operations". This is useful for debugging code size explosions: Those locations that result in a large number of operations after running a lowering are printed.
Diff Detail
Unit TestsFailed
Event TimelineHerald added subscribers: wenzhicui, wrengr, Chia-hungDuan and 19 others. · View Herald TranscriptSep 12 2021, 10:41 PM Comment Actions Example output: RUN: mlir-opt -allow-unregistered-dialect -print-op-stats="top-k-locs=5" %s -o=/dev/null 2>&1 [OK] mlir-opt -allow-unregistered-dialect -print-op-stats="top-k-locs=5" llvm-project/mlir/test/IR/op-stats.mlir -o=/dev/null 2>&1 Operations encountered: ----------------------- builtin.func , 1 builtin.module , 1 long_op_name , 1 std.addf , 6 std.return , 1 xla.add , 17 Top locations by number of operations: -------------------------------------- ...llvm/llvm-project/mlir/test/IR/op-stats.mlir":7:8) , 1 ...lvm/llvm-project/mlir/test/IR/op-stats.mlir":28:9) , 1 ...lvm/llvm-project/mlir/test/IR/op-stats.mlir":11:8) , 1 ...llvm/llvm-project/mlir/test/IR/op-stats.mlir":9:8) , 1 ...lvm/llvm-project/mlir/test/IR/op-stats.mlir":19:9) , 1 springerm added a child revision: D109673: [mlir] print-op-stats: Print op counts for top-k locs.Sep 12 2021, 11:15 PM Comment Actions Is there a way to potentially compose these? E.g., it feels like (and I don't necessarily have good suggestion yet) that we have print op count, print top K locations (well which we could also just have print count per location and then defer to "grep loc\( | head -N K") and the follow up count per top loc. Basically, how much do we want to make this smarter vs relying on common unix tools? (summing per location using awk I invariably need to look up awk syntax again :) so counting is useful, but we could always emit a summary and then just have a group-by-location or also-group-by-location option [and then one would just have the global op count listed too], and then defer all else to awk/sed/grep or just searching in vim).
Revision Contents
Diff 372407 mlir/include/mlir/Transforms/Passes.td
mlir/lib/Transforms/OpStats.cpp
mlir/test/CAPI/pass.c
mlir/test/IR/op-stats.mlir
mlir/test/python/pass_manager.py
|