Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
iblislin committed Mar 4, 2019
1 parent 271fed6 commit 6d9e429
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions julia/src/runtime.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,29 @@ module MXRuntime
using ..mx

export LibFeature
export libinfo_features, isenabled
export feature_list, isenabled

# defined in include/mxnet/c_api.h
struct LibFeature
name::Ptr{Cchar}
index::UInt32
_name::Ptr{Cchar}
enabled::Bool
end

function Base.getproperty(x::LibFeature, p::Symbol)
(p == :name) && return unsafe_string(getfield(x, :_name))
getfield(x, p)
end

Base.show(io::IO, x::LibFeature) =
print(io, ifelse(x.enabled, "", ""), " ", unsafe_string(x.name))
print(io, ifelse(x.enabled, "", ""), " ", x.name)

"""
libinfo_features()
feature_list()
Check the library for compile-time features.
The list of features are maintained in libinfo.h and libinfo.cc
"""
function libinfo_features()
function feature_list()
ref = Ref{Ptr{LibFeature}}(C_NULL)
s = Ref{Csize_t}(C_NULL)
@mx.mxcall(:MXLibInfoFeatures, (Ref{Ptr{LibFeature}}, Ref{Csize_t}), ref, s)
Expand All @@ -60,11 +64,11 @@ julia> mx.isenabled(:CPU_SSE)
true
```
See also `mx.libinfo_features`.
See also `mx.feature_list()`.
"""
isenabled(x::Symbol) =
any(libinfo_features()) do i
Symbol(unsafe_string(i.name)) == x && i.enabled
any(feature_list()) do i
Symbol(i.name) == x && i.enabled
end

end # module MXRuntime
Expand Down

0 comments on commit 6d9e429

Please sign in to comment.