Skip to content

Commit

Permalink
add get_library_symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
kailaix committed Oct 24, 2020
1 parent c412cfc commit 8dec3d3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/extra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ diagnose,
get_placement,
timestamp,
load_library,
sleep_for
sleep_for,
get_library_symbols

"""
xavier_init(size, dtype=Float64)
Expand Down Expand Up @@ -1008,4 +1009,17 @@ function load_library(filename::String)
error("Failed to load library: $filename. Original error message:\n$e")
end
return STORAGE[keyname]
end

"""
get_library_symbols(file::Union{String, PyObject})
Returns the symbols in the custom op library `file`.
"""
function get_library_symbols(files::Union{String, PyObject})
if isa(files, String)
files = load_library(files)
end
files = keys(files)
filter(x->islowercase(String(x)[1]) && String(x)!="tf_export" && !(occursin("fallback", String(x))) && String(x)!="deprecated_endpoints", files)
end
4 changes: 4 additions & 0 deletions test/extra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ end
time = t1_ - t0_
true
end
end

@testset "get_library_symbols" begin
@test length(get_library_symbols(ADCME.libadcme))>0
end

0 comments on commit 8dec3d3

Please sign in to comment.