2626#include < tvm/runtime/registry.h>
2727
2828#include < cstddef>
29- #include < regex>
3029#include < string>
3130#include < vector>
3231
32+ #include " ../../../runtime/regex.h"
3333#include " ../json/json_node.h"
3434#include " ../json/json_runtime.h"
3535
@@ -194,53 +194,54 @@ class DNNLJSONRuntime : public JSONRuntimeBase {
194194 if (o_scl_tr || activation[0 ] != " none" || sum_scl_tr || dst_zp_tr) return attr;
195195
196196 // Define RegExp.
197- std::regex bias_add_pat (" .*_bias.*" );
198- std::regex relu_pat (" .*_relu.*" );
199- std::regex tanh_pat (" .*_tanh.*" );
200- std::regex sigmoid_pat (" .*_sigmoid.*" );
201- std::regex clip_pat (" .*_clip.*" );
202- std::regex gelu_pat (" .*_gelu.*" );
203- std::regex swish_pat (" .*_swish.*" );
204- std::regex sum_pat (" .*_sum.*" );
205- std::regex mish_pat (" .*_mish.*" );
197+ std::string bias_add_pat (" .*_bias.*" );
198+ std::string relu_pat (" .*_relu.*" );
199+ std::string tanh_pat (" .*_tanh.*" );
200+ std::string sigmoid_pat (" .*_sigmoid.*" );
201+ std::string clip_pat (" .*_clip.*" );
202+ std::string gelu_pat (" .*_gelu.*" );
203+ std::string swish_pat (" .*_swish.*" );
204+ std::string sum_pat (" .*_sum.*" );
205+ std::string mish_pat (" .*_mish.*" );
206206
207207 // parsing of name to extract attributes
208208 auto op_name = nodes_[nid].GetOpName ();
209209
210210 // Parsing post-ops.
211211 dnnl::post_ops ops;
212- if (std ::regex_match (op_name, sum_pat)) {
212+ if (tvm::runtime ::regex_match (op_name, sum_pat)) {
213213 ops.append_sum (1 .f );
214214 }
215- if (std ::regex_match (op_name, relu_pat)) {
215+ if (tvm::runtime ::regex_match (op_name, relu_pat)) {
216216 ops.append_eltwise (1 .f , dnnl::algorithm::eltwise_relu, 0 .f , 0 .f );
217217 }
218- if (std ::regex_match (op_name, tanh_pat)) {
218+ if (tvm::runtime ::regex_match (op_name, tanh_pat)) {
219219 ops.append_eltwise (1 .f , dnnl::algorithm::eltwise_tanh, 0 .f , 0 .f );
220220 }
221- if (std ::regex_match (op_name, clip_pat)) {
221+ if (tvm::runtime ::regex_match (op_name, clip_pat)) {
222222 float a_min = GetNodeAttr<float >(nodes_[nid], " a_min" );
223223 float a_max = GetNodeAttr<float >(nodes_[nid], " a_max" );
224224 ops.append_eltwise (1 .f , dnnl::algorithm::eltwise_clip, a_min, a_max);
225225 }
226- if (std ::regex_match (op_name, sigmoid_pat)) {
226+ if (tvm::runtime ::regex_match (op_name, sigmoid_pat)) {
227227 ops.append_eltwise (1 .f , dnnl::algorithm::eltwise_logistic, 0 .f , 0 .f );
228228 }
229- if (std ::regex_match (op_name, swish_pat)) {
229+ if (tvm::runtime ::regex_match (op_name, swish_pat)) {
230230 ops.append_eltwise (1 .f , dnnl::algorithm::eltwise_swish, 1 .f , 1 .f );
231231 }
232- if (std ::regex_match (op_name, gelu_pat)) {
232+ if (tvm::runtime ::regex_match (op_name, gelu_pat)) {
233233 ops.append_eltwise (1 .f , dnnl::algorithm::eltwise_gelu_erf, 0 .f , 0 .f );
234234 }
235- if (std ::regex_match (op_name, mish_pat)) {
235+ if (tvm::runtime ::regex_match (op_name, mish_pat)) {
236236 ops.append_eltwise (1 .f , dnnl::algorithm::eltwise_mish, 1 .f , 0 .f );
237237 }
238238 if (ops.len () != 0 ) {
239239 attr.set_post_ops (ops);
240240 }
241241
242242 // Parsing bias_add.
243- *bias_tr = std::regex_match (op_name, bias_add_pat) ? GetInput (nid, 2 ) : TensorRequisite{};
243+ *bias_tr =
244+ tvm::runtime::regex_match (op_name, bias_add_pat) ? GetInput (nid, 2 ) : TensorRequisite{};
244245
245246 return attr;
246247 }
@@ -253,31 +254,31 @@ class DNNLJSONRuntime : public JSONRuntimeBase {
253254 std::set<uint32_t > io_eid_set (run_arg_eid_.begin (), run_arg_eid_.end ());
254255 tensor_registry_ = TensorRegistry (engine_, io_eid_set);
255256
256- std::regex conv_pat (" .*conv[1-3]d.*" );
257- std::regex deconv_pat (" .*deconv[1-3]d.*" );
258- std::regex conv_transpose_pat (" .*conv[1-3]d_transpose.*" );
259- std::regex dense_pat (" .*dense.*" );
260- std::regex max_pool_pat (" .*max_pool[1-3]d" );
261- std::regex avg_pool_pat (" .*avg_pool[1-3]d" );
257+ std::string conv_pat (" .*conv[1-3]d.*" );
258+ std::string deconv_pat (" .*deconv[1-3]d.*" );
259+ std::string conv_transpose_pat (" .*conv[1-3]d_transpose.*" );
260+ std::string dense_pat (" .*dense.*" );
261+ std::string max_pool_pat (" .*max_pool[1-3]d" );
262+ std::string avg_pool_pat (" .*avg_pool[1-3]d" );
262263
263264 // Build subgraph engine.
264265 for (size_t nid = 0 ; nid < nodes_.size (); ++nid) {
265266 const auto & node = nodes_[nid];
266267 if (node.GetOpType () == " kernel" ) {
267268 ICHECK_EQ (node.GetOpType (), " kernel" );
268269 auto op_name = node.GetOpName ();
269- if (std ::regex_match (op_name, deconv_pat) ||
270- std ::regex_match (op_name, conv_transpose_pat)) {
270+ if (tvm::runtime ::regex_match (op_name, deconv_pat) ||
271+ tvm::runtime ::regex_match (op_name, conv_transpose_pat)) {
271272 Deconvolution (nid);
272- } else if (std ::regex_match (op_name, conv_pat)) {
273+ } else if (tvm::runtime ::regex_match (op_name, conv_pat)) {
273274 Convolution (nid);
274- } else if (std ::regex_match (op_name, dense_pat)) {
275+ } else if (tvm::runtime ::regex_match (op_name, dense_pat)) {
275276 Dense (nid);
276277 } else if (" nn.batch_norm" == op_name) {
277278 BatchNorm (nid);
278- } else if (std ::regex_match (op_name, max_pool_pat)) {
279+ } else if (tvm::runtime ::regex_match (op_name, max_pool_pat)) {
279280 Pooling (nid, dnnl::algorithm::pooling_max);
280- } else if (std ::regex_match (op_name, avg_pool_pat)) {
281+ } else if (tvm::runtime ::regex_match (op_name, avg_pool_pat)) {
281282 Pooling (nid, dnnl::algorithm::pooling_avg);
282283 } else if (elt_name2algo.count (op_name)) {
283284 Eltwise (nid);
0 commit comments