Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate llvm-project and bump dependencies. #12562

Merged
merged 13 commits into from
Mar 13, 2023
Merged

Integrate llvm-project and bump dependencies. #12562

merged 13 commits into from
Mar 13, 2023

Conversation

vmurali
Copy link
Contributor

@vmurali vmurali commented Mar 8, 2023

  • llvm-project: e510d0bda0876c4baa3a270dca39b95da7ec6d9e
  • mlir-hlo: e86610442f58b889a57bf814d75c4b50c769c2a3
  • tensorflow: 67ba341c869e30ee4a89e040cd875d12b9bc666e

Cherry-picked from LLVM:

commit 80074d5fc0ab3f165865b15f5bf55ffac0917bcd (HEAD -> integrate-3-8-2023, fork/integrate-3-8-2023)
Author: Matthias Springer <me@m-sp.org>
Date:   Fri Mar 10 11:25:15 2023 +0100

    [mlir][NFC] reifyResultShapes: Add extra error checking
    
    This change adds a new helper function `mlir::reifyResultShapes` that calls the corresponding interface method and also checks the result produced by the implementation when running in debug mode. Bugs due to incorrect interface implementations can be difficult to debug.
    
    This helper function also reduces the amount of code needed at call sites: the cast to `ReifyRankedShapedTypeOpInterface` is done in the helper function.
    
    Differential Revision: https://reviews.llvm.org/D145777

commit 32b15f601de173e9511f470f7423108d3154e582
Author: Matthias Springer <me@m-sp.org>
Date:   Fri Mar 10 11:24:43 2023 +0100

    [mlir][tensor/linalg] Fix bug in reifyResultShapes
    
    `reifyResultShapes` should return an IntegerAttr if and only if the corresponding dimension is static.
    
    Differential Revision: https://reviews.llvm.org/D145702

commit 894555cd6adf2e0faffe713373a266650b40bb4e
Author: David Green <david.green@arm.com>
Date:   Wed Mar 8 12:48:21 2023 +0000

    [AArch64] Fix load-insert-zero patterns with i8 and negative offsets.
    
    These should have been using the LDURBi instructions where the offset is
    negative, as reported from the reproducer in D144086.

Created a new commit on iree-mlir-hlo fork:

https://github.com/iree-org/iree-mhlo-fork/commit/b14e9d9b06255e4476f5698e3bfc531dec793ded

} else {
shape.push_back(b.create<arith::ConstantIndexOp>(getLoc(), dim));
shape.push_back((Value)b.create<arith::ConstantIndexOp>(getLoc(), dim));
Copy link
Contributor

Choose a reason for hiding this comment

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

This must return an OpFoldResult.

From the documentation of reifyResultShapes:

        `reifiedReturnShapes` is populated with one vector per op result. Each
        of those vectors contains an OpFoldResult for each dimension of the
        shaped type. In case a dimension in the type is static, the
        corresponding entry is an IntegerAttr. Otherwise, it is a Value. The
        given builder may be used to insert ops that compute result shapes.

In this particular case here:

        shape.push_back(b.getIndexAttr(dim));

(same for a few more places below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So

        shape.push_back((Value)b.create<arith::ConstantIndexOp>(getLoc(), dim));

should be changed to

        shape.push_back(b.getIndexAttr(dim));

?

* llvm-project: e510d0bda0876c4baa3a270dca39b95da7ec6d9e
* mlir-hlo: e86610442f58b889a57bf814d75c4b50c769c2a3
* tensorflow: 67ba341c869e30ee4a89e040cd875d12b9bc666e
@vmurali vmurali marked this pull request as ready for review March 9, 2023 19:51
@vmurali vmurali enabled auto-merge (squash) March 9, 2023 19:54
@vmurali
Copy link
Contributor Author

vmurali commented Mar 9, 2023

@hanhanW the tests fail unless I do what I had done. It was @matthias-springer's suggestion:

for every source dimension {
  if (dimension is static) {
    reifiedReturnShapes[0].push_back(builder.getIndexAttr(...));
  } else {
    (whatever getDims is doing)
  }
}

I am going to mark the comments as resolved.

@MaheshRavishankar
Copy link
Contributor

@hanhanW the tests fail unless I do what I had done. It was @matthias-springer's suggestion:

for every source dimension {
  if (dimension is static) {
    reifiedReturnShapes[0].push_back(builder.getIndexAttr(...));
  } else {
    (whatever getDims is doing)
  }
}

I am going to mark the comments as resolved.

I think you can use createDimValues https://github.com/llvm/llvm-project/blob/e1b3c5c403b89172a3346ca8d781ef5ee82c1c01/mlir/include/mlir/Dialect/Tensor/Utils/Utils.h#L31

@hanhanW
Copy link
Contributor

hanhanW commented Mar 9, 2023

@hanhanW the tests fail unless I do what I had done. It was @matthias-springer's suggestion:

for every source dimension {
  if (dimension is static) {
    reifiedReturnShapes[0].push_back(builder.getIndexAttr(...));
  } else {
    (whatever getDims is doing)
  }
}

I am going to mark the comments as resolved.

This is very surprising. Does the getMixedTile() one also fail? According to the td file, the DispatchTensorLoadOp implements OffsetSizeAndStrideOpInterface interface.

def FLOW_DispatchTensorLoadOp : FLOW_PureOp<"dispatch.tensor.load", [
  AttrSizedOperandSegments,
  OffsetSizeAndStrideOpInterface,
  DeclareOpInterfaceMethods<ReifyRankedShapedTypeOpInterface>,
  DeclareOpInterfaceMethods<Util_TiedOpInterface, [
      "getTiedResult",
      "getTiedResultOperandIndex",
      "getTiedResultOperandIndices",
  ]>,

The getMixedTile method is part of OffsetSizeAndStrideOpInterface, which returns vector of OpFoldValue...

https://github.com/llvm/llvm-project/blob/54225c457a336b1609c6d064b2b606a9238a28b9/mlir/include/mlir/Interfaces/ViewLikeInterface.td#L173-L184

IMO, the fix should not be using casting like (Value).... We should fix it in a proper way...

@vmurali
Copy link
Contributor Author

vmurali commented Mar 9, 2023

@hanhanW the tests fail unless I do what I had done. It was @matthias-springer's suggestion:

for every source dimension {
  if (dimension is static) {
    reifiedReturnShapes[0].push_back(builder.getIndexAttr(...));
  } else {
    (whatever getDims is doing)
  }
}

I am going to mark the comments as resolved.

This is very surprising. Does the getMixedTile() one also fail? According to the td file, the DispatchTensorLoadOp implements OffsetSizeAndStrideOpInterface interface.

def FLOW_DispatchTensorLoadOp : FLOW_PureOp<"dispatch.tensor.load", [
  AttrSizedOperandSegments,
  OffsetSizeAndStrideOpInterface,
  DeclareOpInterfaceMethods<ReifyRankedShapedTypeOpInterface>,
  DeclareOpInterfaceMethods<Util_TiedOpInterface, [
      "getTiedResult",
      "getTiedResultOperandIndex",
      "getTiedResultOperandIndices",
  ]>,

The getMixedTile method is part of OffsetSizeAndStrideOpInterface, which returns vector of OpFoldValue...

https://github.com/llvm/llvm-project/blob/54225c457a336b1609c6d064b2b606a9238a28b9/mlir/include/mlir/Interfaces/ViewLikeInterface.td#L173-L184

IMO, the fix should not be using casting like (Value).... We should fix it in a proper way...

No I fixed that. There's the one unresolved comment that fails if I remove the cast.

@hanhanW hanhanW dismissed their stale review March 9, 2023 23:07

looks good so far, unblocking for now

@hanhanW hanhanW disabled auto-merge March 10, 2023 05:27
@hanhanW
Copy link
Contributor

hanhanW commented Mar 10, 2023

I'm worried that the next round integrator does not know these information. Can you add the commits that are cherry-picked to the PR description?

I noticed that there are commits that are not cherry-picked from upstream, e.g., https://github.com/iree-org/iree-llvm-fork/commit/87c11e2f9c56ed302657b930dce1b8553becb8b8 and https://github.com/iree-org/iree-mhlo-fork/commit/b14e9d9b06255e4476f5698e3bfc531dec793ded

Are they sent out for review yet?

@matthias-springer
Copy link
Contributor

Upstream fix for reifyResultShapes has landed. Also an additional change with extra debug mode checks to debug issues like this more easily in the future.

@vmurali
Copy link
Contributor Author

vmurali commented Mar 10, 2023

Upstream fix for reifyResultShapes has landed. Also an additional change with extra debug mode checks to debug issues like this more easily in the future.

Should I pull these two: 0a9f6b8ca3fa9449cc0accba1bc11e98d6dbc6b6, 758329dc7cd3b0da835a4f865b89003263050080 ?

@vmurali
Copy link
Contributor Author

vmurali commented Mar 10, 2023

https://github.com/openxla/iree/actions/runs/4380626838/jobs/7668127668 -

******************** TEST 'TENSORFLOW_TESTS :: iree_tfl_tests/llvmcpu_posenet_i8.run' FAILED ********************
Script:
--
: 'RUN: at line 2';   /usr/bin/python3 -m iree_tfl_tests.posenet_i8_test --target_backend=llvmcpu --artifacts_dir=/tmp/lit/iree_tfl_tests/Output/llvmcpu_posenet_i8.run.tmp
--
Exit Code: 1

Command Output (stdout):
--
$ ":" "RUN: at line 2"
$ "/usr/bin/python3" "-m" "iree_tfl_tests.posenet_i8_test" "--target_backend=llvmcpu" "--artifacts_dir=/tmp/lit/iree_tfl_tests/Output/llvmcpu_posenet_i8.run.tmp"
# command output:
TMPDIR = /tmp/lit/iree_tfl_tests/Output/llvmcpu_posenet_i8.run.tmp/download

# command stderr:
2023-03-10 02:39:54.077060: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2023-03-10 02:39:54.077160: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Running tests under Python 3.7.5: /usr/bin/python3
2023-03-10 02:39:56.311971: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2023-03-10 02:39:56.312022: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303)
2023-03-10 02:39:56.312052: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (gh-runner-presubmit-cpu-us-central1-gw6m): /proc/driver/nvidia/version does not exist
[ RUN      ] PosenetI8Test.test_compile_tflite
I0310 02:39:56.315438 139756582582080 test_util.py:50] Saving compilation artifacts and traces to '/tmp/lit/iree_tfl_tests/Output/llvmcpu_posenet_i8.run.tmp/download'
I0310 02:39:56.388114 139756582582080 test_util.py:141] Setting up for IREE
I0310 02:39:56.389639 139756582582080 binaries.py:216] Invoke IREE Pipeline:
  /work/integrations/tensorflow/python_projects/iree_tflite/iree/tools/tflite/iree-import-tflite /tmp/lit/iree_tfl_tests/Output/llvmcpu_posenet_i8.run.tmp/download/model.mlirbc --mlir-print-debuginfo --save-temp-tfl-input=/tmp/lit/iree_tfl_tests/Output/llvmcpu_posenet_i8.run.tmp/download/tflite.mlirbc --save-temp-iree-input=/tmp/lit/iree_tfl_tests/Output/llvmcpu_posenet_i8.run.tmp/download/tosa.mlirbc
  /work/full-build-dir/compiler/bindings/python/iree/compiler/tools/../_mlir_libs/iree-compile - --iree-input-type=tosa --iree-vm-bytecode-module-output-format=flatbuffer-binary --iree-hal-target-backends=llvm-cpu -o=/tmp/lit/iree_tfl_tests/Output/llvmcpu_posenet_i8.run.tmp/download/module.vmfb --iree-llvmcpu-embedded-linker-path=/work/full-build-dir/compiler/bindings/python/iree/compiler/tools/../_mlir_libs/iree-lld --mlir-print-debuginfo --mlir-print-op-on-diagnostic=false
[  FAILED  ] PosenetI8Test.test_compile_tflite
======================================================================
ERROR: test_compile_tflite (__main__.PosenetI8Test)
PosenetI8Test.test_compile_tflite
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/work/integrations/tensorflow/test/python/iree_tfl_tests/posenet_i8_test.py", line 47, in test_compile_tflite
    self.compile_and_execute()
  File "/work/integrations/tensorflow/test/python/iree_tfl_tests/test_util.py", line 149, in compile_and_execute
    import_only=False)
  File "/work/full-build-dir/compiler/bindings/python/iree/compiler/tools/tflite.py", line 154, in compile_file
    result = invoke_pipeline([import_cl, compile_cl])
  File "/work/full-build-dir/compiler/bindings/python/iree/compiler/tools/binaries.py", line 259, in invoke_pipeline
    raise CompilerToolError(stage.completed)
iree.compiler.tools.binaries.CompilerToolError: Error invoking IREE compiler tool iree-import-tflite

Debugging this. If anyone has any insights, let me know.

@hanhanW
Copy link
Contributor

hanhanW commented Mar 10, 2023

Thanks for tracking them.

(also, could you please add the other comment instead of editing my comment?)

@vmurali
Copy link
Contributor Author

vmurali commented Mar 10, 2023

Thanks for tracking them.

(also, could you please add the other comment instead of editing my comment?)

Sorry I thought I quoted it.

TENSORFLOW_COMMIT = "eece4dba1fc65f7977085581852b0d6e6d42f04e"
TENSORFLOW_COMMIT = "67ba341c869e30ee4a89e040cd875d12b9bc666e"
Copy link
Member

Choose a reason for hiding this comment

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

(just commenting here for threading)

The change to mlir-hlo includes the stablehlo test suite (https://github.com/tensorflow/mlir-hlo/tree/master/stablehlo/stablehlo/testdata), which we might want to slice out if it increases git checkout time... this is a lot of files:
image

Copy link
Contributor

@hanhanW hanhanW left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the hard work!

As mentioned on discord, I think we can land it on Monday. It's Friday. I think we don't want to have a situation where we are dealing with breakages on Friday afternoon/weekend.

@vmurali vmurali merged commit 2eb6450 into main Mar 13, 2023
@vmurali vmurali deleted the llvm-bump-3-8-2023 branch March 13, 2023 05:12
qedawkins pushed a commit to qedawkins/iree that referenced this pull request Apr 2, 2023
* llvm-project: e510d0bda0876c4baa3a270dca39b95da7ec6d9e
* mlir-hlo: e86610442f58b889a57bf814d75c4b50c769c2a3
* tensorflow: 67ba341c869e30ee4a89e040cd875d12b9bc666e

Cherry-picked from LLVM:
```
commit 80074d5fc0ab3f165865b15f5bf55ffac0917bcd (HEAD -> integrate-3-8-2023, fork/integrate-3-8-2023)
Author: Matthias Springer <me@m-sp.org>
Date:   Fri Mar 10 11:25:15 2023 +0100

    [mlir][NFC] reifyResultShapes: Add extra error checking
    
    This change adds a new helper function `mlir::reifyResultShapes` that calls the corresponding interface method and also checks the result produced by the implementation when running in debug mode. Bugs due to incorrect interface implementations can be difficult to debug.
    
    This helper function also reduces the amount of code needed at call sites: the cast to `ReifyRankedShapedTypeOpInterface` is done in the helper function.
    
    Differential Revision: https://reviews.llvm.org/D145777

commit 32b15f601de173e9511f470f7423108d3154e582
Author: Matthias Springer <me@m-sp.org>
Date:   Fri Mar 10 11:24:43 2023 +0100

    [mlir][tensor/linalg] Fix bug in reifyResultShapes
    
    `reifyResultShapes` should return an IntegerAttr if and only if the corresponding dimension is static.
    
    Differential Revision: https://reviews.llvm.org/D145702

commit 894555cd6adf2e0faffe713373a266650b40bb4e
Author: David Green <david.green@arm.com>
Date:   Wed Mar 8 12:48:21 2023 +0000

    [AArch64] Fix load-insert-zero patterns with i8 and negative offsets.
    
    These should have been using the LDURBi instructions where the offset is
    negative, as reported from the reproducer in D144086.
```

Created a new commit on iree-mlir-hlo fork:


https://github.com/iree-org/iree-mhlo-fork/commit/b14e9d9b06255e4476f5698e3bfc531dec793ded
@jpienaar jpienaar mentioned this pull request Apr 3, 2023
jpienaar pushed a commit that referenced this pull request May 1, 2023
* llvm-project: e510d0bda0876c4baa3a270dca39b95da7ec6d9e
* mlir-hlo: e86610442f58b889a57bf814d75c4b50c769c2a3
* tensorflow: 67ba341c869e30ee4a89e040cd875d12b9bc666e

Cherry-picked from LLVM:
```
commit 80074d5fc0ab3f165865b15f5bf55ffac0917bcd (HEAD -> integrate-3-8-2023, fork/integrate-3-8-2023)
Author: Matthias Springer <me@m-sp.org>
Date:   Fri Mar 10 11:25:15 2023 +0100

    [mlir][NFC] reifyResultShapes: Add extra error checking
    
    This change adds a new helper function `mlir::reifyResultShapes` that calls the corresponding interface method and also checks the result produced by the implementation when running in debug mode. Bugs due to incorrect interface implementations can be difficult to debug.
    
    This helper function also reduces the amount of code needed at call sites: the cast to `ReifyRankedShapedTypeOpInterface` is done in the helper function.
    
    Differential Revision: https://reviews.llvm.org/D145777

commit 32b15f601de173e9511f470f7423108d3154e582
Author: Matthias Springer <me@m-sp.org>
Date:   Fri Mar 10 11:24:43 2023 +0100

    [mlir][tensor/linalg] Fix bug in reifyResultShapes
    
    `reifyResultShapes` should return an IntegerAttr if and only if the corresponding dimension is static.
    
    Differential Revision: https://reviews.llvm.org/D145702

commit 894555cd6adf2e0faffe713373a266650b40bb4e
Author: David Green <david.green@arm.com>
Date:   Wed Mar 8 12:48:21 2023 +0000

    [AArch64] Fix load-insert-zero patterns with i8 and negative offsets.
    
    These should have been using the LDURBi instructions where the offset is
    negative, as reported from the reproducer in D144086.
```

Created a new commit on iree-mlir-hlo fork:


https://github.com/iree-org/iree-mhlo-fork/commit/b14e9d9b06255e4476f5698e3bfc531dec793ded
rengolin pushed a commit to plaidml/iree that referenced this pull request May 2, 2023
* llvm-project: e510d0bda0876c4baa3a270dca39b95da7ec6d9e
* mlir-hlo: e86610442f58b889a57bf814d75c4b50c769c2a3
* tensorflow: 67ba341c869e30ee4a89e040cd875d12b9bc666e

Cherry-picked from LLVM:
```
commit 80074d5fc0ab3f165865b15f5bf55ffac0917bcd (HEAD -> integrate-3-8-2023, fork/integrate-3-8-2023)
Author: Matthias Springer <me@m-sp.org>
Date:   Fri Mar 10 11:25:15 2023 +0100

    [mlir][NFC] reifyResultShapes: Add extra error checking
    
    This change adds a new helper function `mlir::reifyResultShapes` that calls the corresponding interface method and also checks the result produced by the implementation when running in debug mode. Bugs due to incorrect interface implementations can be difficult to debug.
    
    This helper function also reduces the amount of code needed at call sites: the cast to `ReifyRankedShapedTypeOpInterface` is done in the helper function.
    
    Differential Revision: https://reviews.llvm.org/D145777

commit 32b15f601de173e9511f470f7423108d3154e582
Author: Matthias Springer <me@m-sp.org>
Date:   Fri Mar 10 11:24:43 2023 +0100

    [mlir][tensor/linalg] Fix bug in reifyResultShapes
    
    `reifyResultShapes` should return an IntegerAttr if and only if the corresponding dimension is static.
    
    Differential Revision: https://reviews.llvm.org/D145702

commit 894555cd6adf2e0faffe713373a266650b40bb4e
Author: David Green <david.green@arm.com>
Date:   Wed Mar 8 12:48:21 2023 +0000

    [AArch64] Fix load-insert-zero patterns with i8 and negative offsets.
    
    These should have been using the LDURBi instructions where the offset is
    negative, as reported from the reproducer in D144086.
```

Created a new commit on iree-mlir-hlo fork:


https://github.com/iree-org/iree-mhlo-fork/commit/b14e9d9b06255e4476f5698e3bfc531dec793ded
NatashaKnk pushed a commit to NatashaKnk/iree that referenced this pull request Jul 6, 2023
* llvm-project: e510d0bda0876c4baa3a270dca39b95da7ec6d9e
* mlir-hlo: e86610442f58b889a57bf814d75c4b50c769c2a3
* tensorflow: 67ba341c869e30ee4a89e040cd875d12b9bc666e

Cherry-picked from LLVM:
```
commit 80074d5fc0ab3f165865b15f5bf55ffac0917bcd (HEAD -> integrate-3-8-2023, fork/integrate-3-8-2023)
Author: Matthias Springer <me@m-sp.org>
Date:   Fri Mar 10 11:25:15 2023 +0100

    [mlir][NFC] reifyResultShapes: Add extra error checking
    
    This change adds a new helper function `mlir::reifyResultShapes` that calls the corresponding interface method and also checks the result produced by the implementation when running in debug mode. Bugs due to incorrect interface implementations can be difficult to debug.
    
    This helper function also reduces the amount of code needed at call sites: the cast to `ReifyRankedShapedTypeOpInterface` is done in the helper function.
    
    Differential Revision: https://reviews.llvm.org/D145777

commit 32b15f601de173e9511f470f7423108d3154e582
Author: Matthias Springer <me@m-sp.org>
Date:   Fri Mar 10 11:24:43 2023 +0100

    [mlir][tensor/linalg] Fix bug in reifyResultShapes
    
    `reifyResultShapes` should return an IntegerAttr if and only if the corresponding dimension is static.
    
    Differential Revision: https://reviews.llvm.org/D145702

commit 894555cd6adf2e0faffe713373a266650b40bb4e
Author: David Green <david.green@arm.com>
Date:   Wed Mar 8 12:48:21 2023 +0000

    [AArch64] Fix load-insert-zero patterns with i8 and negative offsets.
    
    These should have been using the LDURBi instructions where the offset is
    negative, as reported from the reproducer in D144086.
```

Created a new commit on iree-mlir-hlo fork:


https://github.com/iree-org/iree-mhlo-fork/commit/b14e9d9b06255e4476f5698e3bfc531dec793ded
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.

5 participants