Skip to content

Commit

Permalink
Guard for wrong values
Browse files Browse the repository at this point in the history
  • Loading branch information
kbruniec committed Apr 30, 2021
1 parent ad58305 commit c92dd30
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions inference-engine/src/gna_plugin/gna_plugin_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ static const caseless_unordered_map <std::string, std::pair<Gna2AccelerationMode
};
#endif

static const std::set<std::string> supportedTargets = {
GNAConfigParams::GNA_TARGET_2_0,
GNAConfigParams::GNA_TARGET_3_0,
""
};

void Config::UpdateFromMap(const std::map<std::string, std::string>& config) {
for (auto&& item : config) {
auto key = item.first;
Expand Down Expand Up @@ -119,10 +125,11 @@ void Config::UpdateFromMap(const std::map<std::string, std::string>& config) {
pluginGna2DeviceConsistent = procType->second.second;
#endif
}
} else if (key == GNA_CONFIG_KEY(EXEC_TARGET)) {
gnaExecTarget = value;
} else if (key == GNA_CONFIG_KEY(COMPILE_TARGET)) {
gnaCompileTarget = value;
} else if (key == GNA_CONFIG_KEY(EXEC_TARGET) || key == GNA_CONFIG_KEY(COMPILE_TARGET)) {
if (supportedTargets.count(value) == 0) {
THROW_GNA_EXCEPTION << "Unsupported GNA config value (key, value): (" << key << ", " << value << ")";
}
(key == GNA_CONFIG_KEY(EXEC_TARGET) ? gnaExecTarget : gnaCompileTarget) = value;
} else if (key == GNA_CONFIG_KEY(COMPACT_MODE)) {
if (value == PluginConfigParams::YES) {
gnaFlags.compact_mode = true;
Expand Down

0 comments on commit c92dd30

Please sign in to comment.