mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
Add unit test for C# setting of session options config entry. (#5073)
Make error message slightly more user friendly.
This commit is contained in:
parent
5d60d57ce2
commit
36dc057913
2 changed files with 7 additions and 2 deletions
|
|
@ -84,6 +84,11 @@ namespace Microsoft.ML.OnnxRuntime.Tests
|
|||
|
||||
Assert.Throws<OnnxRuntimeException>(() => { opt.GraphOptimizationLevel = (GraphOptimizationLevel)10; });
|
||||
|
||||
opt.AddSessionConfigEntry("key", "value");
|
||||
|
||||
var ex = Assert.Throws<OnnxRuntimeException>(() => { opt.AddSessionConfigEntry("", "invalid key"); });
|
||||
Assert.Contains("[ErrorCode:InvalidArgument] Config key is empty", ex.Message);
|
||||
|
||||
opt.AppendExecutionProvider_CPU(1);
|
||||
#if USE_DNNL
|
||||
opt.AppendExecutionProvider_Dnnl(0);
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ const std::string SessionOptions::GetConfigOrDefault(const std::string& config_k
|
|||
Status SessionOptions::AddConfigEntry(const char* config_key, const char* config_value) noexcept {
|
||||
std::string key(config_key);
|
||||
if (key.empty() || key.length() > 128)
|
||||
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "config_key is empty or longer than maximum length 128");
|
||||
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "Config key is empty or longer than maximum length 128");
|
||||
|
||||
std::string val(config_value);
|
||||
if (val.length() > 1024)
|
||||
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "config_value is longer than maximum length 1024");
|
||||
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "Config value is longer than maximum length 1024");
|
||||
|
||||
auto iter = session_configurations.find(config_key);
|
||||
if (iter != session_configurations.cend()) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue