Added case less check for enum names (#534)
authorIlya Churaev <ilyachur@gmail.com>
Mon, 25 May 2020 13:23:55 +0000 (16:23 +0300)
committerGitHub <noreply@github.com>
Mon, 25 May 2020 13:23:55 +0000 (16:23 +0300)
* Added case less check for enum names

* Added <algorithm> header

ngraph/src/ngraph/enum_names.hpp

index 805e84e..5da4e2c 100644 (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;
                 }