This is an automated email from the ASF dual-hosted git repository. syfeng pushed a commit to branch test_all_cases_on_unity in repository https://gitbox.apache.org/repos/asf/tvm.git
commit 436d3583021c17a66f8100694fcfef27b806e0dc Author: Siyuan Feng <[email protected]> AuthorDate: Thu Dec 14 22:54:54 2023 +0800 disable regex --- src/node/script_printer.cc | 22 +++++++++++++++++++--- src/relax/ir/dataflow_matcher.cc | 8 +++++--- src/runtime/contrib/cublas/cublas_json_runtime.cc | 2 +- src/runtime/contrib/cudnn/cudnn_json_runtime.cc | 2 +- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/node/script_printer.cc b/src/node/script_printer.cc index f2d985279f..d1ad92f3d8 100644 --- a/src/node/script_printer.cc +++ b/src/node/script_printer.cc @@ -21,7 +21,7 @@ #include <tvm/node/script_printer.h> #include <tvm/runtime/registry.h> -#include <regex> +// #include <regex> namespace tvm { @@ -38,10 +38,26 @@ std::string TVMScriptPrinter::Script(const ObjectRef& node, const Optional<Print } bool IsIdentifier(const std::string& name) { - static const std::regex kValidIdentifier("^[a-zA-Z_][a-zA-Z0-9_]*$"); - return std::regex_match(name, kValidIdentifier); + if (name.empty()) { + return false; + } + if (!std::isalpha(name[0]) && name[0] != '_') { + return false; + } + for (size_t i = 1; i < name.size(); ++i) { + if (!std::isalnum(name[i]) && name[i] != '_') { + return false; + } + } + + return true; } +// bool IsIdentifier(const std::string& name) { +// static const std::regex kValidIdentifier("^[a-zA-Z_][a-zA-Z0-9_]*$"); +// return std::regex_match(name, kValidIdentifier); +// } + PrinterConfig::PrinterConfig(Map<String, ObjectRef> config_dict) { runtime::ObjectPtr<PrinterConfigNode> n = make_object<PrinterConfigNode>(); if (auto v = config_dict.Get("name")) { diff --git a/src/relax/ir/dataflow_matcher.cc b/src/relax/ir/dataflow_matcher.cc index 9524c90b57..55e68ccebf 100644 --- a/src/relax/ir/dataflow_matcher.cc +++ b/src/relax/ir/dataflow_matcher.cc @@ -36,7 +36,7 @@ #include <cstddef> #include <limits> #include <optional> -#include <regex> +// #include <regex> #include <type_traits> #include <unordered_map> #include <unordered_set> @@ -557,8 +557,10 @@ bool DFPatternMatcher::VisitDFPattern_(const DataflowVarPatternNode* op, const E bool DFPatternMatcher::VisitDFPattern_(const GlobalVarPatternNode* op, const Expr& expr) { // GlobalVarPattern is not inherited from Var, so we need to handle it separately. if (const auto* var_node = expr.as<GlobalVarNode>()) { - std::regex pat{std::string(op->name_hint())}; - return "" == op->name_hint() || std::regex_search(std::string(var_node->name_hint), pat); + // std::regex pat{std::string(op->name_hint())}; + return "" == op->name_hint() || + std::string(var_node->name_hint).find(std::string(op->name_hint())) != std::string::npos; + // return "" == op->name_hint() || std::regex_search(std::string(var_node->name_hint), pat); } return false; } diff --git a/src/runtime/contrib/cublas/cublas_json_runtime.cc b/src/runtime/contrib/cublas/cublas_json_runtime.cc index c6916d4f86..6e5628ba8f 100644 --- a/src/runtime/contrib/cublas/cublas_json_runtime.cc +++ b/src/runtime/contrib/cublas/cublas_json_runtime.cc @@ -26,7 +26,7 @@ #include <tvm/runtime/registry.h> #include <cstddef> -#include <regex> +// #include <regex> #include <string> #include <vector> diff --git a/src/runtime/contrib/cudnn/cudnn_json_runtime.cc b/src/runtime/contrib/cudnn/cudnn_json_runtime.cc index 58e4e59afc..5305bd0683 100644 --- a/src/runtime/contrib/cudnn/cudnn_json_runtime.cc +++ b/src/runtime/contrib/cudnn/cudnn_json_runtime.cc @@ -54,7 +54,7 @@ class cuDNNJSONRuntime : public JSONRuntimeBase { stream = static_cast<cudaStream_t>((*func)().operator void*()); auto attr_in_name = [](const std::string& op_name, const std::string& attr_name) { - return std::regex_search(op_name, std::regex(attr_name)); + return op_name.find(attr_name) != std::string::npos; }; auto vstr2vint = [](const JSONGraphNode& node, const std::string& attrStr) {
