Skip to content

Stablehlo to linalg - #1

Closed
kuhar wants to merge 9 commits into
stablehlo-to-linalg-startfrom
stablehlo-to-linalg
Closed

kuhar wants to merge 9 commits into
stablehlo-to-linalg-startfrom
stablehlo-to-linalg

Conversation

@kuhar

@kuhar kuhar commented Mar 28, 2023

Copy link
Copy Markdown
Owner

Creating a PR to make it easy to compare

kuhar pushed a commit that referenced this pull request Sep 20, 2023
Caught by ASan:

```
370: =================================================================
370: ==3911909==ERROR: LeakSanitizer: detected memory leaks
370: 
370: Direct leak of 376 byte(s) in 1 object(s) allocated from:
370:     #0 0x6a9b022 in calloc (iree-build/tools/iree-run-mlir+0x6a9b022)
370:     #1 0x6ad5d47 in iree_allocator_system_alloc iree/runtime/src/iree/base/allocator.c:104:17
370:     #2 0x6ad5d47 in iree_allocator_system_ctl iree/runtime/src/iree/base/allocator.c:144:14
370:     iree-org#3 0x6ad56ad in iree_allocator_issue_alloc iree/runtime/src/iree/base/allocator.c:27:10
370:     iree-org#4 0x6ad56ad in iree_allocator_malloc iree/runtime/src/iree/base/allocator.c:32:10
370:     iree-org#5 0x1acf2486 in iree_vm_bytecode_module_create iree/runtime/src/iree/vm/bytecode/module.c:836:3
370:     iree-org#6 0x6afdf31 in iree_tooling_create_run_context iree/runtime/src/iree/tooling/run_module.c:107:9
370:     iree-org#7 0x6afdf31 in iree_tooling_run_module_with_data iree/runtime/src/iree/tooling/run_module.c:340:3
370:     iree-org#8 0x6ad2a24 in iree::(anonymous namespace)::CompileAndRunFile(iree_compiler_session_t*, char const*) iree/tools/iree-run-mlir-main.cc:359:3
370:     iree-org#9 0x6ad2a24 in main iree/tools/iree-run-mlir-main.cc:520:20
370:     iree-org#10 0x7fce3bc456c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
```
@kuhar kuhar closed this Sep 20, 2023
kuhar pushed a commit that referenced this pull request Sep 27, 2023
kuhar pushed a commit that referenced this pull request Nov 16, 2023
…e_thread_request_affinity` (iree-org#15499)

TSan report:

```
WARNING: ThreadSanitizer: data race (pid=45817)
  Read of size 4 at 0x0001084004e0 by thread T2:
    #0 iree_thread_request_affinity threading_darwin.c:230 (local-task_vmvx_semaphore_submission_test:arm64+0x100078f40)
    #1 iree_task_worker_main worker.c:385 (local-task_vmvx_semaphore_submission_test:arm64+0x100071594)
    #2 iree_thread_start_routine threading_darwin.c:72 (local-task_vmvx_semaphore_submission_test:arm64+0x100078e3c)

  Previous write of size 4 at 0x0001084004e0 by main thread:
    #0 iree_thread_create threading_darwin.c:140 (local-task_vmvx_semaphore_submission_test:arm64+0x100078ca4)
    #1 iree_task_worker_initialize worker.c:66 (local-task_vmvx_semaphore_submission_test:arm64+0x1000714f8)
    #2 iree_task_executor_create executor.c:161 (local-task_vmvx_semaphore_submission_test:arm64+0x10006b2b0)
```

The read of `thread->mach_port` at
https://github.com/openxla/iree/blob/ccc4c3719cea467477a783f1c9e9f1fc06b4c508/runtime/src/iree/base/internal/threading_darwin.c#L230

is not ordered relatively to the write of that variable in the parent
thread after `pthread_mach_thread_np` returns:
https://github.com/openxla/iree/blob/ccc4c3719cea467477a783f1c9e9f1fc06b4c508/runtime/src/iree/base/internal/threading_darwin.c#L140

The proposed fix is that the worker thread shouldn't need to access its
own `thread->mach_port`, it can equivalently call `mach_task_self()`.
kuhar pushed a commit that referenced this pull request Nov 6, 2024
…ree-org#18894)

Main motivation of this patch is to resolve issue where we have the same
constOp being used by multiple operations.

But with a twist where first time the constOp needs a layout is on a op
that topologically comes after other ops that use constOp. This will
generate a copy of constOp in the location right before the latter op,
which is problematic because this constOp will be used by other ops
before it.

Previously for the test added we get this error:
```
within split at contraction_layout.mlir:1 offset :24:10: note: see current operation: %9 = "arith.addf"(%8, %6) <{fastmath = #arith.fastmath<none>}> : (vector<96x64xf16>, vector<96x64xf16>) -> vector<96x64xf16>
within split at contraction_layout.mlir:1 offset :22:19: error: operand #1 does not dominate this use
    %scaled_rhs = arith.mulf %read_1, %cst_1 : vector<96x64xf16>
```

While minor, this is also problematic because this error seem to stopped
layout analysis (but not fatally) S.T it fails to vector distribute in
some cases, making it hard to debug.

Signed-off-by: Stanley Winata <[email protected]>
kuhar pushed a commit that referenced this pull request Jun 6, 2025
In fusion of consumer `tensor.collapse_shape` operations into
`scf.forall`, there is a potential dominance issue if the
`tensor.parallel_insert_slice` operation depends on both a BlockArgument
and an affine expression on the same BlockArgument (in this order). This
lead to the following error for the added test:
```
...
error: operand #1 does not dominate this use
    %2 = affine.apply #map(%arg4)
...
```

Signed-off-by: Jorn Tuyls <[email protected]>
kuhar pushed a commit that referenced this pull request Aug 6, 2025
This PR adds a pattern to swap the `collapse_shape` with the
`extract_slice` op to enable more loop fusion opportunity. Note this
pattern is adapted from the upstream[
`BubbleUpCollapseShapeThroughExtractSlice`](https://github.com/llvm/llvm-project/blob/ffb453989b0e95d85b6cfa543b65fec23b65649d/mlir/lib/Dialect/Tensor/Transforms/ReshapePatterns.cpp#L322)
by allowing some special cases we've seen through the IGEMM path.

The special case is processed under `CASE #1` session with the
corresponding tests mainly focusing on the changes. Note that some
strict conditions are added to match the special case for convolutions
which maybe not general and robust enough to add to upstream. In
addition, we break the [upstream single
pattern](https://github.com/llvm/llvm-project/blob/ffb453989b0e95d85b6cfa543b65fec23b65649d/mlir/lib/Dialect/Tensor/Transforms/ReshapePatterns.cpp#L767)
into two separate ones to be able to apply them separately in different
passes.

---------

Signed-off-by: yzhang93 <[email protected]>
kuhar added a commit that referenced this pull request Feb 21, 2026
I'm testing a new multi-model review tool, it reported some outdated
docs:

- Remove nonexistent `--iree-codegen-gpu-native-math-precision` flag
  from SDXL golden outputs guide (found by GPT-5.3)
- Fix `CMake_BUILD_TYPE` → `CMAKE_BUILD_TYPE` case typo in Emscripten
  build docs (found by GPT-5.3)
- Fix `iree-import-tf -help` → `--help` in TensorFlow guide; the tool
  uses Python argparse which requires `-h` or `--help` (found by GPT-5.3)

Findings from Gemini Flash confirmed issues #1 and iree-org#3 independently.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.

1 participant