Skip to content

fix dialect(::Operation) #48

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

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/IR/IR.jl
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ location(operation) = Location(API.mlirOperationGetLocation(operation))
name(operation) = String(API.mlirOperationGetName(operation))
block(operation) = Block(API.mlirOperationGetBlock(operation), false)
parent_operation(operation) = Operation(API.mlirOperationGetParentOperation(operation), false)
dialect(operation) = first(split(get_name(operation), '.')) |> Symbol
dialect(operation) = first(split(name(operation), '.')) |> Symbol

function get_first_region(op::Operation)
reg = iterate(RegionIterator(op))
Expand Down
13 changes: 13 additions & 0 deletions test/ir.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using MLIR.Dialects: arith
using MLIR.IR, LLVM

@testset "operation introspection" begin
IR.context!(IR.Context()) do
IR.get_or_load_dialect!("linalg")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this have been arith?

Copy link
Member Author

Choose a reason for hiding this comment

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

unfortunately, mlirGetDialectHandle__arith__ does not exist so I had to load transitively with linalg.

op = arith.constant(; value=true, result=MLIRType(Bool))

@test IR.name(op) == "arith.constant"
@test IR.dialect(op) === :arith
@test IR.get_attribute_by_name(op, "value") |> IR.bool_value
end
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using Test

include("examples.jl")
include("executionengine.jl")
include("ir.jl")

@testset "MlirStringRef conversion" begin
s = "mlir 😄 α γ 🍕"
Expand Down