Skip to content

Commit

Permalink
Merge pull request #39 from GunnarFarneback/logging_level
Browse files Browse the repository at this point in the history
Logging level
  • Loading branch information
GunnarFarneback committed Aug 26, 2024
2 parents 603066b + 28e5fa2 commit fa5ac58
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ONNXRunTime"
uuid = "e034b28e-924e-41b2-b98f-d2bbeb830c6a"
authors = ["Jan Weidner <jw3126@gmail.com> and contributors"]
version = "1.1.1"
version = "1.2.0"

[deps]
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ output_array = GetTensorMutableData(api, output_tensor);
* [ONNX.jl](https://github.com/FluxML/ONNX.jl)
* [ONNXNaiveNASflux.jl](https://github.com/DrChainsaw/ONNXNaiveNASflux.jl)

# Complements

* [ONNXLowLevel.jl](https://github.com/GunnarFarneback/ONNXLowLevel.jl) cannot
run inference but can be used to investigate, create, or manipulate ONNX
files.

# Breaking Changes in version 0.4.

* Support for CUDA.jl is changed from version 3 to versions 4 and 5.
Expand Down
29 changes: 28 additions & 1 deletion src/highlevel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,42 @@ function output_names(api::OrtApi, session::OrtSession, allocator::OrtAllocator)
end
end

function parse_logging_level(level::Symbol)
level == :warning && return CAPI.ORT_LOGGING_LEVEL_WARNING
level == :verbose && return CAPI.ORT_LOGGING_LEVEL_VERBOSE
level == :info && return CAPI.ORT_LOGGING_LEVEL_INFO
level == :error && return CAPI.ORT_LOGGING_LEVEL_ERROR
level == :fatal && return CAPI.ORT_LOGGING_LEVEL_FATAL
error("""
$(level) is not a valid value for logging_level. The options are :verbose, :info, :warning (default), :error, and :fatal.
""")
end

"""
$TYPEDSIGNATURES
Load an ONNX file at `path` into an inference session.
*Keyword arguments:*
* `execution_provider`: Either `:cpu` or `:cuda`. The latter requires a
CUDA capable GPU and the `CUDA` and `cuDNN` packages must first be imported.
* `envname`: Name used for logging purposes.
* `logging_level`: Level of diagnostic output. Options are `:verbose`,
`:info`, `:warning` (default), `:error`, and `:fatal`.
* `provider_options`: Named tuple with options passed to the execution
provider.
Note: Due to limitations of the C API `CreateEnv` function, `envname`
and `logging_level` can only be set once per process. Attempts to
change these are ignored.
"""
function load_inference(path::AbstractString; execution_provider::Symbol=:cpu,
envname::AbstractString="defaultenv",
logging_level::Symbol=:warning,
provider_options::NamedTuple=(;)
)::InferenceSession
api = GetApi(;execution_provider)
env = CreateEnv(api, name=envname)
env = CreateEnv(api, name=envname, logging_level=parse_logging_level(logging_level))
if execution_provider === :cpu
if !isempty(provider_options)
error("""
Expand Down

2 comments on commit fa5ac58

@GunnarFarneback
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/113845

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.2.0 -m "<description of version>" fa5ac58461cd599d67370d93d42890d4b6ca9165
git push origin v1.2.0

Please sign in to comment.