CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
96 lines
3.0 KiB
Python
96 lines
3.0 KiB
Python
# RUN: %PYTHON %s | FileCheck %s
|
|
|
|
import gc
|
|
from mlir.ir import *
|
|
|
|
|
|
def run(f):
|
|
print("\nTEST:", f.__name__)
|
|
f()
|
|
gc.collect()
|
|
assert Context._get_live_count() == 0
|
|
return f
|
|
|
|
|
|
# CHECK-LABEL: TEST: test_exception
|
|
@run
|
|
def test_exception():
|
|
ctx = Context()
|
|
ctx.allow_unregistered_dialects = True
|
|
try:
|
|
Operation.parse(
|
|
"""
|
|
func.func @foo() {
|
|
"test.use"(%0) : (i64) -> () loc("use")
|
|
%0 = "test.def"() : () -> i64 loc("def")
|
|
return
|
|
}
|
|
""",
|
|
context=ctx,
|
|
)
|
|
except MLIRError as e:
|
|
# CHECK: Exception: <
|
|
# CHECK: Unable to parse operation assembly:
|
|
# CHECK: error: "use": operand #0 does not dominate this use
|
|
# CHECK: note: "use": see current operation: "test.use"(%0) : (i64) -> ()
|
|
# CHECK: note: "def": operand defined here (op in the same block)
|
|
# CHECK: >
|
|
print(f"Exception: <{e}>")
|
|
|
|
# CHECK: message: Unable to parse operation assembly
|
|
print(f"message: {e.message}")
|
|
|
|
# CHECK: error_diagnostics[0]: loc("use") operand #0 does not dominate this use
|
|
# CHECK: error_diagnostics[0].notes[0]: loc("use") see current operation: "test.use"(%0) : (i64) -> ()
|
|
# CHECK: error_diagnostics[0].notes[1]: loc("def") operand defined here (op in the same block)
|
|
print(
|
|
"error_diagnostics[0]: ",
|
|
e.error_diagnostics[0].location,
|
|
e.error_diagnostics[0].message,
|
|
)
|
|
print(
|
|
"error_diagnostics[0].notes[0]: ",
|
|
e.error_diagnostics[0].notes[0].location,
|
|
e.error_diagnostics[0].notes[0].message,
|
|
)
|
|
print(
|
|
"error_diagnostics[0].notes[1]: ",
|
|
e.error_diagnostics[0].notes[1].location,
|
|
e.error_diagnostics[0].notes[1].message,
|
|
)
|
|
|
|
|
|
# CHECK-LABEL: test_emit_error_diagnostics
|
|
@run
|
|
def test_emit_error_diagnostics():
|
|
ctx = Context()
|
|
loc = Location.unknown(ctx)
|
|
handler_diags = []
|
|
|
|
def handler(d):
|
|
handler_diags.append(str(d))
|
|
return True
|
|
|
|
ctx.attach_diagnostic_handler(handler)
|
|
|
|
try:
|
|
Attribute.parse("not an attr", ctx)
|
|
except MLIRError as e:
|
|
# CHECK: emit_error_diagnostics=False:
|
|
# CHECK: e.error_diagnostics: ['expected attribute value']
|
|
# CHECK: handler_diags: []
|
|
print(f"emit_error_diagnostics=False:")
|
|
print(f"e.error_diagnostics: {[str(diag) for diag in e.error_diagnostics]}")
|
|
print(f"handler_diags: {handler_diags}")
|
|
|
|
ctx.emit_error_diagnostics = True
|
|
try:
|
|
Attribute.parse("not an attr", ctx)
|
|
except MLIRError as e:
|
|
# CHECK: emit_error_diagnostics=True:
|
|
# CHECK: e.error_diagnostics: []
|
|
# CHECK: handler_diags: ['expected attribute value']
|
|
print(f"emit_error_diagnostics=True:")
|
|
print(f"e.error_diagnostics: {[str(diag) for diag in e.error_diagnostics]}")
|
|
print(f"handler_diags: {handler_diags}")
|