mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-16 21:00:14 +00:00
* working on re-organizing js code for ortweb * remove dup files * move folder * fix common references * fix common es5 * add webpack to common * split interfact/impl * use cjs for node * add npmignore for common * update sourcemap config for common * update node * adjust folder/path in CI and build * update folder * nit: readme * add bundle for dev * correct nodejs paths * enable ORT_API_MANUAL_INIT * set name for umd library * correct name for commonjs export * add priority into registerBackend() * fix npm ci pwd * update eslintrc * revise code * revert package-lock lockfileVersion 2->1 * update prebuild * resolve comments * update document * revise eslint config * update eslint for typescript rules * revert changes by mistake in backend.ts * add env * resolve comments
33 lines
1.3 KiB
C++
33 lines
1.3 KiB
C++
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#include "onnxruntime_cxx_api.h"
|
|
#include <napi.h>
|
|
|
|
#include <cmath>
|
|
|
|
#include "common.h"
|
|
#include "run_options_helper.h"
|
|
|
|
void ParseRunOptions(const Napi::Object options, Ort::RunOptions &runOptions) {
|
|
// Log severity level
|
|
if (options.Has("logSeverityLevel")) {
|
|
auto logLevelValue = options.Get("logSeverityLevel");
|
|
ORT_NAPI_THROW_TYPEERROR_IF(!logLevelValue.IsNumber(), options.Env(),
|
|
"Invalid argument: runOptions.logSeverityLevel must be a number.");
|
|
double logLevelNumber = logLevelValue.As<Napi::Number>().DoubleValue();
|
|
ORT_NAPI_THROW_RANGEERROR_IF(
|
|
std::floor(logLevelNumber) != logLevelNumber || logLevelNumber < 0 || logLevelNumber > 4, options.Env(),
|
|
"Invalid argument: runOptions.logSeverityLevel must be one of the following: 0, 1, 2, 3, 4.");
|
|
|
|
runOptions.SetRunLogSeverityLevel(static_cast<int>(logLevelNumber));
|
|
}
|
|
|
|
// Tag
|
|
if (options.Has("tag")) {
|
|
auto tagValue = options.Get("tag");
|
|
ORT_NAPI_THROW_TYPEERROR_IF(!tagValue.IsString(), options.Env(),
|
|
"Invalid argument: runOptions.tag must be a string.");
|
|
runOptions.SetRunTag(tagValue.As<Napi::String>().Utf8Value().c_str());
|
|
}
|
|
}
|