Skip to content

Commit 495a75c

Browse files
authored
Do not pretty print debug info, making result module parseable (#983)
1 parent 93266c7 commit 495a75c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/mlir/IR/Operation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ function Base.show(io::IO, operation::Operation)
235235

236236
flags = API.mlirOpPrintingFlagsCreate()
237237

238-
API.mlirOpPrintingFlagsEnableDebugInfo(flags, get(io, :debug, false), true)
238+
API.mlirOpPrintingFlagsEnableDebugInfo(flags, get(io, :debug, false), false)
239239
API.mlirOperationPrintWithFlags(operation, flags, c_print_callback, ref)
240240
API.mlirOpPrintingFlagsDestroy(flags)
241241

test/basic.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,3 +1038,21 @@ end
10381038
x_ra = Reactant.to_rarray(ones(Int, 4))
10391039
@test @jit(fn(x_ra)) == fn(ones(Int, 4))
10401040
end
1041+
1042+
@testset "Module printing" begin
1043+
for opt in (true, false, :before_jit), debug in (true, false)
1044+
v = collect(Float32(1):Float32(64))
1045+
vr = Reactant.to_rarray(v)
1046+
mod = @code_hlo optimize = opt log.(vr)
1047+
1048+
# Store the module as a string with different debug options.
1049+
io = IOBuffer()
1050+
show(IOContext(io, :debug => debug), mod)
1051+
mod_string = String(take!(io))
1052+
1053+
# Test that we can parse back the string as an MLIR module, compile it
1054+
# and get correct results.
1055+
res = @jit(Reactant.Ops.hlo_call(mod_string, vr))[1]
1056+
@test res log.(v)
1057+
end
1058+
end

0 commit comments

Comments
 (0)