Repository navigation
Added pad test, update LegalizeInputTypes to allow linalg.yield - #5305
Conversation
| if (llvm::isa<mlir::linalg::LinalgOp>(oldOp) || | ||
| llvm::isa<mlir::linalg::YieldOp>(oldOp)) { | ||
| // Currently assumes linalg ops have legal types. | ||
| // TODO: rewrite to generic and back. |
There was a problem hiding this comment.
I don't really understand the TODO here, and you're adding another case to the condition that it comments on. Can you expand on the TODO?
This now also assumes that YieldOps are already legal? What would "rewriting to generic and back" accomplish?
There was a problem hiding this comment.
I updated to check directly that we assume all linalg ops are valid (I think this is what the original code was meant to do). Tried to update the comment but the original line was a bit of a mystery to me too.
| %0 = "tosa.const"() { value = dense<1> : tensor<1x1x1xi32> } : () -> (tensor<1x1x1xi32>) | ||
| %1 = "tosa.const"() { value = dense<[[0, 1], [1, 0], [0, 0]]> : tensor<3x2xi32> } : () -> (tensor<3x2xi32>) | ||
| %result = "tosa.pad"(%0, %1) : (tensor<1x1x1xi32>, tensor<3x2xi32>) -> (tensor<2x2x1xi32>) | ||
| check.expect_eq_const(%result, dense<[[[0], [1]], [[0], [0]]]> : tensor<2x2x1xi32>) : tensor<2x2x1xi32> |
There was a problem hiding this comment.
o_O seems to match the spec, but wow the spec is confusing...
After reading through these:
https://mlir.llvm.org/docs/Dialects/TOSA/#tosapad-mlirtosapadop
https://developer.mlplatform.org/w/tosa/
and referencing this test, I'm still not sure where 2x2x1 is coming from, or why these values are expected...
Could you use values other than 0 and 1 to more clearly show what is happening?
There was a problem hiding this comment.
I added two more tests and used the internal value as 42 to be more clear. I can not change what the padding value is, so you are stuck with the 0s. Not sure we are going to get clearer with padding.
| %0 = "tosa.const"() { value = dense<42> : tensor<2xi32> } : () -> (tensor<2xi32>) | ||
| %1 = "tosa.const"() { value = dense<[[3, 2]]> : tensor<1x2xi32> } : () -> (tensor<1x2xi32>) | ||
| %result = "tosa.pad"(%0, %1) : (tensor<2xi32>, tensor<1x2xi32>) -> (tensor<7xi32>) |
There was a problem hiding this comment.
Do we test with "tosa.const"? If they are constants, I think they should/will be folded...
There was a problem hiding this comment.
Good catch. We actually don't have folders in TOSA so it technically works find but better to make input-1 unfoldable.
LegalizeInputTypes assumes no yield ops, updated so that it can handle nested linalg blocks. Simple pad test to verify.
| if (isa<linalg::LinalgDialect>(oldOp->getDialect())) { | ||
| // Currently we assume all Linalg ops only contain valid types. | ||
| // TODO: Support converting Linalg types when unsupported. | ||
| builder.clone(*oldOp, mapping); | ||
| return success(); | ||
| } |
There was a problem hiding this comment.
I personally think we should have a test for this in legalize_input_types.mlir... It looks like you are trying to allow linalg.yield, but it should only exist in Linalg bodys?
There was a problem hiding this comment.
Correct however this pass recurses into linalg bodies (probably shouldn't but it does). There are also other linalg ops that will likely appear so we should mark all of linalg as a special case until it is resolved. Test added.
* 734ec24 Add smoketest_linalg_on_tensors to LLVM and Vulkan-SPIRV targets. (#5324) * d8bcb78 Drop absl logging and flat_hash_map. (#5334) * 5c63668 [vulkan] Disable ResNet50 test failing on NVIDIA GPUs (#5332) * 55d3715 Fix vulkan_device struct manipulation issue with std::vector. (#5333) * 47d00c6 Fix benchmarking MobileNetV2 on S20 GPU in Linalg on tensor path. (#5331) * ccae793 Fix bugs in ExtractReduceWindowOpPaddingAttributes. (#5329) * 652e328 Don't inline block arguments that can be written (#5247) * 86e7d29 [CodeGen] Enable fusion with consumer elementwise ops (#5282) * 44ad774 Integrate MLIR-EmitC at iml130/mlir-emitc@3c265bf (#5326) * 0141857 Added pad test, update LegalizeInputTypes to allow linalg.yield (#5305) * 5a3653f Add mobile-bert f16 version to Mako benchmark. (#5204) * f596cdb Add a target_env_conversion test for Linalg on tensors. (#5309) * f1aa6f4 Print out the status when iree-check-module fails (#5323) * 40d7589 Check for VMLA and Vulkan components for simple_embedding_test. (#5318) COPYBARA_INTEGRATE_REVIEW=#5339 from NatashaKnk:main-to-google dea40ed PiperOrigin-RevId: 367330863
* 0132538 Merge google -> main #5404 * 53e7279 Limit fusion of linalg.generic/indexed_generic ops to avoid redundant computat.. * 516d1ac Merge branch 'main' into google-to-main * 9630450 Make PrePartitioningConversionPass not recurse into Linalg (#5358) * 29610ce Merge google -> main (#5388) * 692c586 Merge branch 'main' into google-to-main * 9b159c1 [CUDA Codegen] Add support for promotion to workgroup memory. (#5386) * 11b3bfe MaterializeCPULaunch configurations before bufferization (#5362) * ee0ddf4 Legalize ui64 to i32 in Flow type converter (#5384) * 87346a2 Handle tensor.cast bufferization in LinalgBufferizePass (#5369) * 2922e11 Removes tied transient buffer assignment propagation. (#5365) * 5b952e4 Making flow.tensor.reshape a tied-op. (#5368) * 7048463 Fixing ASAN-instrumented dylib library loading. (#5382) * 2f3ad70 Adding some basic flow.tensor.reshape folders. (#5366) * 357fa58 Switch simple_embeddding to test on DyLib + Vulkan (#5374) * cb7d144 Turn on operand fusion flag for benchmarks of Linalg on tensors (#5380) * f2d74fd Disable fusion of named ops with elementwise operations by default. (#5363) * 3fc84c3 Add support for returning Python tuples (#5347) * 8fb65cb Remove handling of shape dialect in flow->hal stream conversion. (#5360) * 68c27a0 Add logging for Android (#5232) * 56307e1 Merge pull request #5328 from google/benvanik-constant-io * d3eb8e4 Merge pull request #5357 from google/benvanik-host-visible * 4f86152 Materialize interfaces based on usage for flow.dispatch.workgroups. * f41b25d Splitting -iree-hal-materialize-interfaces into old/new paths. This will insul.. * 62a3dfd Move constant pool ops/hal.constant.subspan into streams. This dramatically re.. * 79dc138 [spirv] NFC: use upstream push constant utility functions (#5352) * 38daefb Revert "Disable running BERT on Vulkan (see Issue #5268) (#5269)" * 0995956 Revert "[vulkan] Disable ResNet50 test failing on NVIDIA GPUs (#5332)" * 0eeb3f8 Removing hack that forced all Vulkan buffers to be host-visible. After removin.. * 8abc33b Tracy fixes for GPU name allocation and allocation callstack mode. (#5356) * 55f76d3 Fix submodule check failure (#5355) * 830b547 [CodeGen] Copy constant at the proper place during bufferization (#5343) * 59ad168 Drop absl flat_hash_set and some unused includes. (#5346) * de2aabc Control TF MLIR print options via flags (#5336) * 2e2dfdd Merge google -> main (#5345) * ef9b787 Merge branch 'main' into google-to-main * 8b70733 Remove extra comma from context_wrapper.cc * 8cc6256 Fix linalg-on-tensors smoketests (#5341) * a578d6a Add TosaToStandard to cpu/gpu target pipeline from ApplyScale lowering (#5288) * 0c92b88 Add mixed static-dynamic arguments interface for flow.dispatch.tensor.{load|st.. * 9890722 Update Java Bindings To Build In Experimental (#5226) * 734ec24 Add smoketest_linalg_on_tensors to LLVM and Vulkan-SPIRV targets. (#5324) * d8bcb78 Drop absl logging and flat_hash_map. (#5334) * 5c63668 [vulkan] Disable ResNet50 test failing on NVIDIA GPUs (#5332) * 55d3715 Fix vulkan_device struct manipulation issue with std::vector. (#5333) * 47d00c6 Fix benchmarking MobileNetV2 on S20 GPU in Linalg on tensor path. (#5331) * ccae793 Fix bugs in ExtractReduceWindowOpPaddingAttributes. (#5329) * 652e328 Don't inline block arguments that can be written (#5247) * 86e7d29 [CodeGen] Enable fusion with consumer elementwise ops (#5282) * 44ad774 Integrate MLIR-EmitC at iml130/mlir-emitc@3c265bf (#5326) * 0141857 Added pad test, update LegalizeInputTypes to allow linalg.yield (#5305) * 5a3653f Add mobile-bert f16 version to Mako benchmark. (#5204) * f596cdb Add a target_env_conversion test for Linalg on tensors. (#5309) * f1aa6f4 Print out the status when iree-check-module fails (#5323) * 40d7589 Check for VMLA and Vulkan components for simple_embedding_test. (#5318) COPYBARA_INTEGRATE_REVIEW=#5407 from rsuderman:main-to-google c9c3ea7 PiperOrigin-RevId: 368121520
* 0132538 Merge google -> main #5404 * 53e7279 Limit fusion of linalg.generic/indexed_generic ops to avoid redundant computat.. * 516d1ac Merge branch 'main' into google-to-main * 9630450 Make PrePartitioningConversionPass not recurse into Linalg (#5358) * 29610ce Merge google -> main (#5388) * 692c586 Merge branch 'main' into google-to-main * 9b159c1 [CUDA Codegen] Add support for promotion to workgroup memory. (#5386) * 11b3bfe MaterializeCPULaunch configurations before bufferization (#5362) * ee0ddf4 Legalize ui64 to i32 in Flow type converter (#5384) * 87346a2 Handle tensor.cast bufferization in LinalgBufferizePass (#5369) * 2922e11 Removes tied transient buffer assignment propagation. (#5365) * 5b952e4 Making flow.tensor.reshape a tied-op. (#5368) * 7048463 Fixing ASAN-instrumented dylib library loading. (#5382) * 2f3ad70 Adding some basic flow.tensor.reshape folders. (#5366) * 357fa58 Switch simple_embeddding to test on DyLib + Vulkan (#5374) * cb7d144 Turn on operand fusion flag for benchmarks of Linalg on tensors (#5380) * f2d74fd Disable fusion of named ops with elementwise operations by default. (#5363) * 3fc84c3 Add support for returning Python tuples (#5347) * 8fb65cb Remove handling of shape dialect in flow->hal stream conversion. (#5360) * 68c27a0 Add logging for Android (#5232) * 56307e1 Merge pull request #5328 from google/benvanik-constant-io * d3eb8e4 Merge pull request #5357 from google/benvanik-host-visible * 4f86152 Materialize interfaces based on usage for flow.dispatch.workgroups. * f41b25d Splitting -iree-hal-materialize-interfaces into old/new paths. This will insul.. * 62a3dfd Move constant pool ops/hal.constant.subspan into streams. This dramatically re.. * 79dc138 [spirv] NFC: use upstream push constant utility functions (#5352) * 38daefb Revert "Disable running BERT on Vulkan (see Issue #5268) (#5269)" * 0995956 Revert "[vulkan] Disable ResNet50 test failing on NVIDIA GPUs (#5332)" * 0eeb3f8 Removing hack that forced all Vulkan buffers to be host-visible. After removin.. * 8abc33b Tracy fixes for GPU name allocation and allocation callstack mode. (#5356) * 55f76d3 Fix submodule check failure (#5355) * 830b547 [CodeGen] Copy constant at the proper place during bufferization (#5343) * 59ad168 Drop absl flat_hash_set and some unused includes. (#5346) * de2aabc Control TF MLIR print options via flags (#5336) * 2e2dfdd Merge google -> main (#5345) * ef9b787 Merge branch 'main' into google-to-main * 8b70733 Remove extra comma from context_wrapper.cc * 8cc6256 Fix linalg-on-tensors smoketests (#5341) * a578d6a Add TosaToStandard to cpu/gpu target pipeline from ApplyScale lowering (#5288) * 0c92b88 Add mixed static-dynamic arguments interface for flow.dispatch.tensor.{load|st.. * 9890722 Update Java Bindings To Build In Experimental (#5226) * 734ec24 Add smoketest_linalg_on_tensors to LLVM and Vulkan-SPIRV targets. (#5324) * d8bcb78 Drop absl logging and flat_hash_map. (#5334) * 5c63668 [vulkan] Disable ResNet50 test failing on NVIDIA GPUs (#5332) * 55d3715 Fix vulkan_device struct manipulation issue with std::vector. (#5333) * 47d00c6 Fix benchmarking MobileNetV2 on S20 GPU in Linalg on tensor path. (#5331) * ccae793 Fix bugs in ExtractReduceWindowOpPaddingAttributes. (#5329) * 652e328 Don't inline block arguments that can be written (#5247) * 86e7d29 [CodeGen] Enable fusion with consumer elementwise ops (#5282) * 44ad774 Integrate MLIR-EmitC at iml130/mlir-emitc@3c265bf (#5326) * 0141857 Added pad test, update LegalizeInputTypes to allow linalg.yield (#5305) * 5a3653f Add mobile-bert f16 version to Mako benchmark. (#5204) * f596cdb Add a target_env_conversion test for Linalg on tensors. (#5309) * f1aa6f4 Print out the status when iree-check-module fails (#5323) * 40d7589 Check for VMLA and Vulkan components for simple_embedding_test. (#5318) PiperOrigin-RevId: 368121520
LegalizeInputTypes assumes no yield ops, updated so that it can handle nested
linalg blocks.
Simple pad test to verify.