Skip to content

Commit

Permalink
Allow for multiple provider configs, and for merging multiple configs. (
Browse files Browse the repository at this point in the history
#1003)

This is mostly to enable overlaying a second config on top of the first
through runtime options.

This now works:
```
      "session_options": {
        "provider_options": [
          {
            "cuda": {}
          },
          {
            "rocm": {}
          }
        ]
      },
```
  • Loading branch information
RyanUnderhill authored Oct 22, 2024
1 parent 8b2a1b9 commit 28f77a3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ struct ProviderOptionsObject_Element : JSON::Element {
explicit ProviderOptionsObject_Element(std::vector<Config::ProviderOptions>& v) : v_{v} {}

JSON::Element& OnObject(std::string_view name) override {
if (options_element_)
throw std::runtime_error("Each object in the provider_options array can only have one member (named value)");
for (auto& v : v_) {
if (v.name == name) {
options_element_ = std::make_unique<ProviderOptions_Element>(v);
return *options_element_;
}
}

auto& options = v_.emplace_back();
options.name = name;
options_element_ = std::make_unique<ProviderOptions_Element>(options);
Expand Down

0 comments on commit 28f77a3

Please sign in to comment.