Skip to content

Enable detensorize by default - #10127

Merged
rsuderman merged 1 commit into
iree-org:mainfrom
rsuderman:EnableDetensor
Aug 18, 2022
Merged

rsuderman merged 1 commit into
iree-org:mainfrom
rsuderman:EnableDetensor

Conversation

@rsuderman

Copy link
Copy Markdown
Collaborator

Wrote a simple cpu test that involves multiple iterations across
low compute workloads. Verified that we saw a 10% improvement in
performance due to detensoring the work. Validating on performance
benchmarks now.

Wrote a simple cpu test that involves multiple iterations across
low compute workloads. Verified that we saw a 10% improvement in
performance due to detensoring the work. Validating on performance
benchmarks now.
@iree-github-actions-bot

Copy link
Copy Markdown
Contributor

Abbreviated Linux Benchmark Summary

@ commit 4b83191875be18ed56253f626354c72aa8c48e14 (vs. base 91ffe357df456c3c72f98e93b6250811cb03b941)

No improved or regressed benchmarks 🏖️

Regressed Compilation Times 🚩

Benchmark Name Compilation Time (ms)
MiniLML12H384Uncased [int32] (TF) CPU-x86\_64-CascadeLake 8-thread,full-inference,default-flags 9029 (vs. 7344, 22.94%↑)
MiniLML12H384Uncased [int32] (TF) CPU-x86\_64-CascadeLake full-inference,default-flags 9029 (vs. 7344, 22.94%↑)
MiniLML12H384Uncased [int32] (TF) CPU-x86\_64-CascadeLake 4-thread,full-inference,default-flags 9029 (vs. 7344, 22.94%↑)

[Top 3 out of 11 results showed]

For more information:

@iree-github-actions-bot

iree-github-actions-bot commented Aug 18, 2022 •

Copy link
Copy Markdown
Contributor

Abbreviated Benchmark Summary

@ commit 4b83191875be18ed56253f626354c72aa8c48e14 (vs. base 91ffe357df456c3c72f98e93b6250811cb03b941)

Regressed Latencies 🚩

Benchmark Name Average Latency (ms) Median Latency (ms) Latency Standard Deviation (ms)
MobileNetV3Small [fp32,imagenet] (TFLite) big-core,full-inference,experimental-flags with IREE-LLVM-CPU-Sync @ Pixel-4 (CPU-ARMv8.2-A) 13.806 (vs. 12.432, 11.06%↑) 13.808 0.062
PoseNet [fp32] (TFLite) 4-thread,big-core,full-inference,default-flags with IREE-LLVM-CPU @ Pixel-4 (CPU-ARMv8.2-A) 80.572 (vs. 74.577, 8.04%↑) 80.289 1.764
MobileNetV2 [fp32,imagenet] (TFLite) big-core,full-inference,experimental-flags with IREE-LLVM-CPU-Sync @ Pixel-6-Pro (CPU-ARMv8.2-A) 23.398 (vs. 22.184, 5.47%↑) 23.541 0.240

[Top 3 out of 4 results showed]

Improved Latencies 🎉

Benchmark Name Average Latency (ms) Median Latency (ms) Latency Standard Deviation (ms)
MobileBertSquad [int8] (TFLite) 4-thread,big-core,full-inference,experimental-flags with IREE-LLVM-CPU @ Pixel-4 (CPU-ARMv8.2-A) 198.361 (vs. 229.356, 13.51%↓) 197.007 4.449
MobileBertSquad [fp32] (TFLite) 4-thread,big-core,full-inference,experimental-flags with IREE-LLVM-CPU @ Pixel-6-Pro (CPU-ARMv8.2-A) 322.030 (vs. 371.595, 13.34%↓) 303.019 53.983
MobileNetV3Small [fp32,imagenet] (TFLite) 4-thread,big-core,full-inference,experimental-flags with IREE-LLVM-CPU @ Pixel-4 (CPU-ARMv8.2-A) 10.016 (vs. 11.250, 10.97%↓) 10.025 0.051

[Top 3 out of 4 results showed]

No improved or regressed compilation metrics 🏖️

For more information:

@GMNGeoffrey

Copy link
Copy Markdown
Member

Seems like benchmark results are pretty mixed?

@MaheshRavishankar

Copy link
Copy Markdown
Collaborator

Unfortunately, these all seem like noise. (Its hard to decouple noise from actual regression in our suite... not complaining, just stating as fact, and is a hard thing to do in general).
I'd say there is nothing obvious here that should be a cause for concern. Its a good feature to have, so ship it! If there are any issues, fix forward.

@antiagainst

Copy link
Copy Markdown
Member

Yeah. We really need to look into the mobile CPU nosiness and see how to curb that down. Maybe at least increase the noisy control threshold for them..

@rsuderman

Copy link
Copy Markdown
Collaborator Author

It is worth noting that I was able to make a contrived example that demonstrates a monstrous performance improvement.

@rsuderman rsuderman linked an issue Aug 18, 2022 that may be closed by this pull request
@rsuderman

Copy link
Copy Markdown
Collaborator Author
Benchmark                               Time             CPU   Iterations
-------------------------------------------------------------------------
BM_main/process_time/real_time      0.605 ms        0.605 ms          910

vs

Benchmark                               Time             CPU   Iterations
-------------------------------------------------------------------------
BM_main/process_time/real_time      0.013 ms        0.013 ms        52913

@rsuderman

Copy link
Copy Markdown
Collaborator Author
module @conways {
  func.func @main(%arg0: tensor<128x128xi32>, %arg1: tensor<i32>) {
    call @jit__conway.81$main(%arg0, %arg1) : (tensor<128x128xi32>, tensor<i32>) -> ()
    return
  }
  func.func private @jit__conway.81$main(%arg0: tensor<128x128xi32>, %arg1: tensor<i32>) {
    %0 = mhlo.constant dense<0> : tensor<i32>
    %1:3 = mhlo.while(%iterArg = %0, %iterArg_0 = %arg1, %iterArg_1 = %arg0) : tensor<i32>, tensor<i32>, tensor<128x128xi32>
     cond {
      %2 = mhlo.compare  LT, %iterArg, %iterArg_0,  SIGNED : (tensor<i32>, tensor<i32>) -> tensor<i1>
      "mhlo.return"(%2) : (tensor<i1>) -> ()
    } do {
      %2 = mhlo.constant dense<1> : tensor<i32>
      %3 = mhlo.add %iterArg, %2 : tensor<i32>
      %4 = mhlo.constant dense<0> : tensor<i32>
      %5 = "mhlo.broadcast"(%4) {broadcast_sizes = dense<> : tensor<0xi64>} : (tensor<i32>) -> tensor<i32>
      %6 = "mhlo.reduce_window"(%iterArg_1, %5) ({
      ^bb0(%arg2: tensor<i32>, %arg3: tensor<i32>):
        %19 = mhlo.add %arg2, %arg3 : tensor<i32>
        "mhlo.return"(%19) : (tensor<i32>) -> ()
      }) {base_dilations = dense<1> : tensor<2xi64>, padding = dense<1> : tensor<2x2xi64>, window_dilations = dense<1> : tensor<2xi64>, window_dimensions = dense<3> : tensor<2xi64>, window_strides = dense<1> : tensor<2xi64>} : (tensor<128x128xi32>, tensor<i32>) -> tensor<128x128xi32>
      %7 = mhlo.constant dense<4> : tensor<i32>
      %8 = "mhlo.broadcast_in_dim"(%7) {broadcast_dimensions = dense<> : tensor<0xi64>} : (tensor<i32>) -> tensor<128x128xi32>
      %9 = mhlo.compare  EQ, %6, %8,  SIGNED : (tensor<128x128xi32>, tensor<128x128xi32>) -> tensor<128x128xi1>
      %10 = mhlo.constant dense<0> : tensor<i32>
      %11 = "mhlo.broadcast_in_dim"(%10) {broadcast_dimensions = dense<> : tensor<0xi64>} : (tensor<i32>) -> tensor<128x128xi32>
      %12 = mhlo.compare  NE, %6, %11,  SIGNED : (tensor<128x128xi32>, tensor<128x128xi32>) -> tensor<128x128xi1>
      %13 = mhlo.and %12, %9 : tensor<128x128xi1>
      %14 = mhlo.constant dense<3> : tensor<i32>
      %15 = "mhlo.broadcast_in_dim"(%14) {broadcast_dimensions = dense<> : tensor<0xi64>} : (tensor<i32>) -> tensor<128x128xi32>
      %16 = mhlo.compare  EQ, %6, %15,  SIGNED : (tensor<128x128xi32>, tensor<128x128xi32>) -> tensor<128x128xi1>
      %17 = mhlo.or %13, %16 : tensor<128x128xi1>
      %18 = mhlo.convert(%17) : (tensor<128x128xi1>) -> tensor<128x128xi32>
      "mhlo.return"(%3, %iterArg_0, %18) : (tensor<i32>, tensor<i32>, tensor<128x128xi32>) -> ()
    }
    return
  }
}

@rsuderman
rsuderman merged commit e33dc1e into iree-org:main Aug 18, 2022
@rsuderman
rsuderman deleted the EnableDetensor branch April 30, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tensor-to-primitive/detensoring HLO conversion

6 participants