Skip to content

Mmt4d ukernel: Condition the lowering on the existence of an architecture-specific tile function. - #16880

Closed
bjacob wants to merge 3 commits into
mainfrom
bjacob-ukernel-lowering-only-when-fast
Closed

bjacob wants to merge 3 commits into
mainfrom
bjacob-ukernel-lowering-only-when-fast

Conversation

@bjacob

@bjacob bjacob commented Mar 22, 2024 •

Copy link
Copy Markdown
Collaborator

Following the discussion in #16848, I would like to propose this instead of the approach pursued earlier in #15784, at least as an interim solution until the arguably better approaches outlined in #16848 can be implemented, not precluding getting there - see how the diff in this PR is fairly small and contained.

The approach that we had long pursued in #15784 would, if carried out today, result in losing the large compilation-time benefits of ukernels discussed in #16848. Two solutions for that have been discussed in #16848:

  1. A partial solution discussed in ukernels are also a huge compilation-time win #16848 would be to erase some static shapes to have fewer separate fallback dispatch functions to codegen.
  2. A full solution discussed in ukernels are also a huge compilation-time win #16848 would be to unconditionally lower to ukernels after we have ensured that ukernels are always as fast as codegen thanks to letting codegen generate what we don't have hand-written ukernel code for.

Neither of the above approaches is simultaneously close to being a complete solution and easy to implement in the short term. Both would incur complexity of their own. By contrast, the solution in the present PR is a well-contained +160 lines of code. I know it's not our first choice that it increases the contact surface of ukernels, but I still think it's the best trade-off for now.

@bjacob
bjacob force-pushed the bjacob-ukernel-boilerplate-table branch 2 times, most recently from 01f0b27 to 726b960 Compare March 22, 2024 14:46
@bjacob
bjacob force-pushed the bjacob-ukernel-boilerplate-table branch from 726b960 to 0589a83 Compare March 22, 2024 15:07
@bjacob
bjacob force-pushed the bjacob-ukernel-lowering-only-when-fast branch from 0d79812 to 89cb712 Compare March 22, 2024 16:20
@bjacob bjacob changed the title Only lower to a ukernel if it would be fast. ci-extra:build_test_all_macos_arm64,build_test_all_windows Mmt4d ukernel: Condition the lowering on the existence of an architecture-specific tile function. ci-extra:build_test_all_macos_arm64,build_test_all_windows Mar 22, 2024
@bjacob
bjacob changed the base branch from bjacob-ukernel-boilerplate-table to bjacob-ukernel-lowering-test March 22, 2024 16:23
@bjacob
bjacob force-pushed the bjacob-ukernel-lowering-only-when-fast branch from 89cb712 to 03a6ef2 Compare March 22, 2024 16:30
@bjacob bjacob changed the title Mmt4d ukernel: Condition the lowering on the existence of an architecture-specific tile function. ci-extra:build_test_all_macos_arm64,build_test_all_windows Mmt4d ukernel: Condition the lowering on the existence of an architecture-specific tile function. Mar 22, 2024
@bjacob bjacob added benchmarks:x86_64 Run default x86_64 benchmarks benchmarks:android-cpu Run default Android CPU benchmarks labels Mar 22, 2024
@bjacob
bjacob force-pushed the bjacob-ukernel-lowering-only-when-fast branch from 03a6ef2 to 1f2e9c0 Compare March 22, 2024 16:46
@bjacob
bjacob marked this pull request as ready for review March 22, 2024 17:04
@github-actions

Copy link
Copy Markdown

Abbreviated Benchmark Summary

@ commit 833bcfc18d390e5d3446607199d03d227b37a778 (vs. base aa72368e1c9803ea1bfc37aac984d08a4c274cb4)

Data-Tiling Comparison Table

Click to show
Name No-DT (baseline) DT-Only DT-UK
BertForMaskedLMTF(stablehlo) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[30-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 212.773 (1.0X) N/A 110.866 (1.9X)
BertLargePTBatch1(linalg) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[30-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 654.742 (1.0X) N/A 225.609 (2.9X)
BertLargeTF(stablehlo) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[30-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 715.901 (1.0X) N/A 226.605 (3.2X)
DeepLabV3_fp32(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 32.614 (1.0X) N/A 34.215 (1.0X)
DeepLabV3_fp32(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[8-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 6.893 (1.0X) N/A 9.340 (0.7X)
EfficientNetV2STF(stablehlo) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 262.106 (1.0X) N/A 246.987 (1.1X)
EfficientNetV2STF(stablehlo) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[15-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 35.157 (1.0X) N/A 37.499 (0.9X)
EfficientNet_int8(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 26.098 (1.0X) N/A 17.025 (1.5X)
EfficientNet_int8(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[8-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 5.586 (1.0X) N/A 6.139 (0.9X)
Falcon7bGptqPT(linalg) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[30-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 20415.637 (1.0X) N/A 4134.517 (4.9X)
Falcon7bInt4GptqPT(linalg) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[30-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 20407.274 (1.0X) N/A 4040.790 (5.1X)
GPT2_117M_TF_1X1XI32(stablehlo) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 69.717 (1.0X) N/A 39.165 (1.8X)
GPT2_117M_TF_1X1XI32(stablehlo) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[15-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 8.987 (1.0X) N/A 8.600 (1.0X)
GPT2_117M_TF_1X4XI32(stablehlo) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 89.451 (1.0X) N/A 40.462 (2.2X)
GPT2_117M_TF_1X4XI32(stablehlo) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[15-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 10.730 (1.0X) N/A 8.480 (1.3X)
MiniLML12H384Uncased(stablehlo) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 79.771 (1.0X) N/A 58.111 (1.4X)
MiniLML12H384Uncased(stablehlo) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[15-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 12.508 (1.0X) N/A 13.517 (0.9X)
MobileBertSquad_fp16(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 179.148 (1.0X) N/A 191.292 (0.9X)
MobileBertSquad_fp16(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[15-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 33.229 (1.0X) N/A 59.939 (0.6X)
MobileBertSquad_fp32(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 179.085 (1.0X) N/A 192.009 (0.9X)
MobileBertSquad_fp32(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[15-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 33.507 (1.0X) N/A 60.093 (0.6X)
MobileBertSquad_int8(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 481.383 (1.0X) N/A 224.527 (2.1X)
MobileBertSquad_int8(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[15-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 60.719 (1.0X) N/A 67.639 (0.9X)
MobileNetV1_fp32(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 26.759 (1.0X) N/A 19.905 (1.3X)
MobileNetV1_fp32(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[8-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 5.580 (1.0X) N/A 5.068 (1.1X)
MobileNetV2_fp32(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 11.310 (1.0X) N/A 13.891 (0.8X)
MobileNetV2_fp32(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[8-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 3.647 (1.0X) N/A 5.402 (0.7X)
MobileNetV2_int8(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 21.097 (1.0X) N/A 14.161 (1.5X)
MobileNetV2_int8(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[8-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 5.664 (1.0X) N/A 5.567 (1.0X)
MobileNetV3Small_fp32(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ c2-standard-60[cpu] 2.792 (1.0X) N/A 3.290 (0.8X)
MobileNetV3Small_fp32(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 3.012 (1.0X) N/A 3.515 (0.9X)
MobileSSD_fp32(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 34.276 (1.0X) N/A 34.689 (1.0X)
MobileSSD_fp32(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[8-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 8.329 (1.0X) N/A 10.372 (0.8X)
PersonDetect_int8(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ c2-standard-60[cpu] 0.735 (1.0X) N/A 0.674 (1.1X)
PersonDetect_int8(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 0.802 (1.0X) N/A 0.750 (1.1X)
PoseNet_fp32(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 17.695 (1.0X) N/A 22.293 (0.8X)
PoseNet_fp32(tflite) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_task(embedded_elf)[8-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 4.209 (1.0X) N/A 5.879 (0.7X)
matmul_1x256x2048_i8_i4_i32_tile_config_default(linalg) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ c2-standard-60[cpu] 0.065 (1.0X) N/A 0.065 (1.0X)
matmul_1x256x2048_i8_i8_i32_tile_config_default(linalg) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ c2-standard-60[cpu] 0.042 (1.0X) N/A 0.021 (2.0X)
matmul_256x256x2048_i8_i4_i32_tile_config_default(linalg) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ c2-standard-60[cpu] 7.412 (1.0X) N/A 7.426 (1.0X)
matmul_256x256x2048_i8_i8_i32_tile_config_default(linalg) [x86_64-cascadelake-linux_gnu-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ c2-standard-60[cpu] 6.647 (1.0X) N/A 1.979 (3.4X)
DeepLabV3_fp32(tflite) [armv8.2-a-generic-linux_android29-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ pixel-6-pro[big-cores] 55.593 (1.0X) N/A 75.825 (0.7X)
DeepLabV3_fp32(tflite) [armv8.2-a-generic-linux_android29-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,system-scheduling] with default @ pixel-6-pro[big-cores] 57.316 (1.0X) N/A 76.036 (0.8X)
DeepLabV3_fp32(tflite) [armv8.2-a-generic-linux_android29-llvm_cpu] local_task(embedded_elf)[2-thread,full-inference,system-scheduling] with default @ pixel-6-pro[big-cores] 33.592 (1.0X) N/A 45.493 (0.7X)
GPT2_117M_TF_1X1XI32(stablehlo) [armv8.2-a-generic-linux_android29-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ pixel-6-pro[big-cores] 92.786 (1.0X) N/A 21.102 (4.4X)
GPT2_117M_TF_1X1XI32(stablehlo) [armv8.2-a-generic-linux_android29-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,system-scheduling] with default @ pixel-6-pro[big-cores] 93.633 (1.0X) N/A 22.439 (4.2X)
GPT2_117M_TF_1X1XI32(stablehlo) [armv8.2-a-generic-linux_android29-llvm_cpu] local_task(embedded_elf)[2-thread,full-inference,system-scheduling] with default @ pixel-6-pro[big-cores] 51.900 (1.0X) N/A 21.943 (2.4X)
GPT2_117M_TF_1X4XI32(stablehlo) [armv8.2-a-generic-linux_android29-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ pixel-6-pro[big-cores] 141.642 (1.0X) N/A 27.364 (5.2X)
GPT2_117M_TF_1X4XI32(stablehlo) [armv8.2-a-generic-linux_android29-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,system-scheduling] with default @ pixel-6-pro[big-cores] 141.424 (1.0X) N/A 29.661 (4.8X)
GPT2_117M_TF_1X4XI32(stablehlo) [armv8.2-a-generic-linux_android29-llvm_cpu] local_task(embedded_elf)[2-thread,full-inference,system-scheduling] with default @ pixel-6-pro[big-cores] 76.765 (1.0X) N/A 26.461 (2.9X)
MobileBertSquad_fp32(tflite) [armv8.2-a-generic-linux_android29-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ pixel-6-pro[big-cores] 686.428 (1.0X) N/A 360.664 (1.9X)
MobileBertSquad_fp32(tflite) [armv8.2-a-generic-linux_android29-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,system-scheduling] with default @ pixel-6-pro[big-cores] 705.281 (1.0X) N/A 368.800 (1.9X)
MobileBertSquad_fp32(tflite) [armv8.2-a-generic-linux_android29-llvm_cpu] local_task(embedded_elf)[2-thread,full-inference,system-scheduling] with default @ pixel-6-pro[big-cores] 398.939 (1.0X) N/A 215.350 (1.9X)
MobileBertSquad_int8(tflite) [armv8.2-a-generic-linux_android29-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ pixel-6-pro[big-cores] 1064.377 (1.0X) N/A 279.398 (3.8X)
MobileBertSquad_int8(tflite) [armv8.2-a-generic-linux_android29-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,system-scheduling] with default @ pixel-6-pro[big-cores] 1065.756 (1.0X) N/A 277.731 (3.8X)
MobileBertSquad_int8(tflite) [armv8.2-a-generic-linux_android29-llvm_cpu] local_task(embedded_elf)[2-thread,full-inference,system-scheduling] with default @ pixel-6-pro[big-cores] 555.248 (1.0X) N/A 160.982 (3.4X)
Vit_int8(tflite) [armv8.2-a-generic-linux_android29-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ pixel-6-pro[big-cores] 2097.596 (1.0X) N/A 301.359 (7.0X)
Vit_int8(tflite) [armv8.2-a-generic-linux_android29-llvm_cpu] local_task(embedded_elf)[1-thread,full-inference,system-scheduling] with default @ pixel-6-pro[big-cores] 2096.216 (1.0X) N/A 302.526 (6.9X)
Vit_int8(tflite) [armv8.2-a-generic-linux_android29-llvm_cpu] local_task(embedded_elf)[2-thread,full-inference,system-scheduling] with default @ pixel-6-pro[big-cores] 1138.408 (1.0X) N/A 182.914 (6.2X)
matmul_1x256x2048_i8_i4_i32_tile_config_default(linalg) [armv8.2-a-generic-linux_android29-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ pixel-6-pro[big-cores] 0.080 (1.0X) N/A 0.016 (4.9X)
matmul_1x256x2048_i8_i8_i32_tile_config_default(linalg) [armv8.2-a-generic-linux_android29-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ pixel-6-pro[big-cores] 0.074 (1.0X) N/A 0.017 (4.4X)
matmul_256x256x2048_i8_i4_i32_tile_config_default(linalg) [armv8.2-a-generic-linux_android29-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ pixel-6-pro[big-cores] 11.968 (1.0X) N/A 1.400 (8.5X)
matmul_256x256x2048_i8_i8_i32_tile_config_default(linalg) [armv8.2-a-generic-linux_android29-llvm_cpu] local_sync(embedded_elf)[full-inference,default-flags] with default @ pixel-6-pro[big-cores] 16.537 (1.0X) N/A 1.213 (13.6X)

Regressed Latencies 🚩

Benchmark Name Average Latency (ms) Median Latency (ms) Latency Standard Deviation (ms)
DeepLabV3\_fp32(tflite) [x86\_64-cascadelake-linux\_gnu-llvm\_cpu][experimental-flags,no-dt] local\_task(embedded\_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 32.614 (vs. 31.613, 3.17%↑) 32.546 0.191

Improved Latencies 🎉

Benchmark Name Average Latency (ms) Median Latency (ms) Latency Standard Deviation (ms)
MobileNetV1\_fp32(tflite) [x86\_64-cascadelake-linux\_gnu-llvm\_cpu][experimental-flags,no-dt] local\_task(embedded\_elf)[1-thread,full-inference,default-flags] with default @ c2-standard-60[cpu] 26.759 (vs. 29.610, 9.63%↓) 26.767 0.430
MobileBertSquad\_fp32(tflite) [armv8.2-a-generic-linux\_android29-llvm\_cpu][default-flags,dt-uk] local\_task(embedded\_elf)[2-thread,full-inference,system-scheduling] with default @ pixel-6-pro[big-cores] 215.350 (vs. 238.064, 9.54%↓) 217.718 8.231
GPT2\_117M\_TF\_1X4XI32(stablehlo) [armv8.2-a-generic-linux\_android29-llvm\_cpu][default-flags,dt-uk] local\_sync(embedded\_elf)[full-inference,default-flags] with default @ pixel-6-pro[big-cores] 27.364 (vs. 29.752, 8.02%↓) 27.595 0.915

[Top 3 out of 14 results showed]

No improved or regressed compilation metrics 🏖️

For more information:

Source Workflow Run

bjacob added a commit that referenced this pull request Mar 27, 2024
This -650 lines shrink comes from introducing tables (the .inl files)
where we declare the mmt4d tile functions. From that, we can generate
not only the declarations but also the whole `select_tile_func` logic.

While this PR stands on its own, there is a subtext here that in a
subsequent PR (#16880) I'm going to argue --- against all common sense!
--- for actually exporting these tables, as an interim solution to the
problem discussed in #16848 until the better solutions outlined there
can land. Don't want this to be a distraction on this PR as the tables
are not being exported here, and they are justified by independent
reasons here.

That is entirely within the `arch/` subdir. The only other part of this
PR outside of `arch` is a renaming: `mmt4d_tile.c` only contains the
generic (fallback) tile functions, so made its name reflect that.

I tried hard to also drop the whole CMake configure-checks and
configured-headers and for `IREE_UK_BUILD...`, tried moving that back
into the C files as checks of compiler versions, but ran again into the
mystery about the CI jobs `build_test_all_windows` and
`build_test_runtime_windows` having a very different MSVC behavior there
despite being the exact same version, as noted earlier in
#16637.

@benvanik benvanik left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this is not moving in a good direction IMO as it's adding magic arch values tied to ukernel code and including mmt4d-specific tables/behavior that makes it impossible to handle out-of-tree mmt4d ukernels with differing features, mmt4d ukernels for new architectures without patching the compiler, or non-mmt4d ukernels to the same fidelity.

If we're keeping the ukernels separate from the compiler (which I still think is valuable for all the original reasons we went that way) there's alternatives we should explore here instead. Functions can have arbitrary string annotations plumbed all the way from C, for example: https://bholt.org/posts/llvm-quick-tricks.html - we could use that and query the functions from the loaded bitcode instead of compiling in the table. We can also embed the selection logic by inverting it: a tile function declares what it works with (features, etc) in a structured fashion (either via function multi-versioning attributes like cpu_specific/target, or string annotations with +/-feature,..., whatever) and we just ask the LLVM target machine info instead of needing to hardcode things. Data types can also be included if needed and matched without awareness of the particular ukernel: declaring "operands 0,1,2 have data types f16,f16,f32" and matching that against op.getDps...() for each makes it work with arbitrary functions instead of just mmt4d as done in the pattern.

In other words: if we're going to have magic strings coupling the compiler and the ukernel library across the bitcode boundary we really need to think of those as an API/ABI instead of something we can just reach around for an mmt4d-specific thing. I think we have options there that allow us to have fallbacks for arbitrary ukernels instead of just mmt4d and still allow for out-of-tree bitcode to be produced without needing to modify the compiler. We must do this for non-mmt4d ukernels so adding something mmt4d-specific has a very high bar if we don't want to have to rewrite it all again or continue to not be able to use ukernels effectively for non-mmt4d operations.

Happy to hop on a call and brainstorm some ways we can do this!

Base automatically changed from bjacob-ukernel-lowering-test to main March 27, 2024 21:08
@bjacob

bjacob commented Apr 23, 2024

Copy link
Copy Markdown
Collaborator Author

Thanks for the explanation. Closing for now, keeping around in case we end up wanting to do something like this.

@bjacob bjacob closed this Apr 23, 2024
@benvanik
benvanik deleted the bjacob-ukernel-lowering-only-when-fast branch May 9, 2024 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

benchmarks:android-cpu Run default Android CPU benchmarks benchmarks:x86_64 Run default x86_64 benchmarks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants