瀏覽代碼

add functions

lyblsgo 2 年之前
父節點
當前提交
659e18be11
共有 2 個文件被更改,包括 10 次插入0 次删除
  1. 9 0
      funasr/runtime/onnxruntime/src/util.cpp
  2. 1 0
      funasr/runtime/onnxruntime/src/util.h

+ 9 - 0
funasr/runtime/onnxruntime/src/util.cpp

@@ -180,4 +180,13 @@ void Glu(Tensor<float> *din, Tensor<float> *dout)
     }
 }
 
+bool is_target_file(const std::string& filename, const std::string target) {
+    std::size_t pos = filename.find_last_of(".");
+    if (pos == std::string::npos) {
+        return false;
+    }
+    std::string extension = filename.substr(pos + 1);
+    return (extension == target);
+}
+
 } // namespace funasr

+ 1 - 0
funasr/runtime/onnxruntime/src/util.h

@@ -25,6 +25,7 @@ extern void FindMax(float *din, int len, float &max_val, int &max_idx);
 extern void Glu(Tensor<float> *din, Tensor<float> *dout);
 
 string PathAppend(const string &p1, const string &p2);
+bool is_target_file(const std::string& filename, const std::string target);
 
 } // namespace funasr
 #endif