mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-19 19:00:47 +00:00
Fixing OrtEnvironment.getEnvironment() so it doesn't print a warning if the environment already exists with a non-default name. (#5973)
This commit is contained in:
parent
30c7fffbab
commit
396074d2a8
1 changed files with 18 additions and 5 deletions
|
|
@ -40,18 +40,28 @@ public class OrtEnvironment implements AutoCloseable {
|
|||
* Gets the OrtEnvironment. If there is not an environment currently created, it creates one using
|
||||
* {@link OrtEnvironment#DEFAULT_NAME} and {@link OrtLoggingLevel#ORT_LOGGING_LEVEL_WARNING}.
|
||||
*
|
||||
* @return An onnxruntime environment.
|
||||
* @return The OrtEnvironment singleton.
|
||||
*/
|
||||
public static OrtEnvironment getEnvironment() {
|
||||
return getEnvironment(OrtLoggingLevel.ORT_LOGGING_LEVEL_WARNING, DEFAULT_NAME);
|
||||
public static synchronized OrtEnvironment getEnvironment() {
|
||||
if (INSTANCE == null) {
|
||||
// If there's no instance, create one.
|
||||
return getEnvironment(OrtLoggingLevel.ORT_LOGGING_LEVEL_WARNING, DEFAULT_NAME);
|
||||
} else {
|
||||
// else return the current one.
|
||||
refCount.incrementAndGet();
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the OrtEnvironment. If there is not an environment currently created, it creates one using
|
||||
* the supplied name and {@link OrtLoggingLevel#ORT_LOGGING_LEVEL_WARNING}.
|
||||
*
|
||||
* <p>If the environment already exists then it returns the existing one and logs a warning if the
|
||||
* name or log level is different from the requested one.
|
||||
*
|
||||
* @param name The logging id of the environment.
|
||||
* @return An onnxruntime environment.
|
||||
* @return The OrtEnvironment singleton.
|
||||
*/
|
||||
public static OrtEnvironment getEnvironment(String name) {
|
||||
return getEnvironment(OrtLoggingLevel.ORT_LOGGING_LEVEL_WARNING, name);
|
||||
|
|
@ -61,8 +71,11 @@ public class OrtEnvironment implements AutoCloseable {
|
|||
* Gets the OrtEnvironment. If there is not an environment currently created, it creates one using
|
||||
* the {@link OrtEnvironment#DEFAULT_NAME} and the supplied logging level.
|
||||
*
|
||||
* <p>If the environment already exists then it returns the existing one and logs a warning if the
|
||||
* name or log level is different from the requested one.
|
||||
*
|
||||
* @param logLevel The logging level to use.
|
||||
* @return An onnxruntime environment.
|
||||
* @return The OrtEnvironment singleton.
|
||||
*/
|
||||
public static OrtEnvironment getEnvironment(OrtLoggingLevel logLevel) {
|
||||
return getEnvironment(logLevel, DEFAULT_NAME);
|
||||
|
|
|
|||
Loading…
Reference in a new issue