Added case less check for enum names (#534)

* Added case less check for enum names

* Added <algorithm> header
This commit is contained in:
Ilya Churaev 2020-05-25 16:23:55 +03:00 committed by GitHub
parent 74e8b54ce3
commit 04bb8ab51d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,7 @@
#pragma once
#include <algorithm>
#include <string>
#include <utility>
@ -32,9 +33,15 @@ namespace ngraph
/// Converts strings to enum values
static EnumType as_enum(const std::string& name)
{
auto to_lower = [](const std::string& s)
{
std::string rc = s;
std::transform(rc.begin(), rc.end(), rc.begin(), ::tolower);
return rc;
};
for (auto p : get().m_string_enums)
{
if (p.first == name)
if (to_lower(p.first) == to_lower(name))
{
return p.second;
}