Skip to content

Commit 0a0a8b4

Browse files
committed
Add convenience methods for reading/writing Metallibs.
1 parent 507e0cb commit 0a0a8b4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/compiler/library.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@ end
462462

463463
## metal library format
464464

465+
Base.parse(::Type{MetalLib}, path::AbstractString) = open(path) do io
466+
read(io, MetalLib)
467+
end
468+
465469
function Base.read(io::IO, ::Type{MetalLib})
466470
## header
467471

@@ -687,6 +691,10 @@ function Base.read(io::IO, ::Type{MetalLib})
687691
optional_args...)
688692
end
689693

694+
Base.write(path::AbstractString, lib::MetalLib) = open(path, "w") do io
695+
write(io, lib)
696+
end
697+
690698
function Base.write(io::IO, lib::MetalLib)
691699
## embedded source
692700

0 commit comments

Comments
 (0)