@ -0,0 +1,28 @@ |
|||||
|
#include <fst/fst-decl.h>
|
||||
|
#include <fst/fstlib.h>
|
||||
|
|
||||
|
using namespace fst; |
||||
|
int main() { |
||||
|
// 创建一个新的 FST
|
||||
|
StdVectorFst fst; |
||||
|
|
||||
|
// 添加状态
|
||||
|
fst.AddState(); // 0
|
||||
|
fst.AddState(); // 1
|
||||
|
fst.AddState(); // 2
|
||||
|
|
||||
|
// 设置起始状态
|
||||
|
fst.SetStart(0); |
||||
|
|
||||
|
// 添加转移(弧)
|
||||
|
fst.AddArc(0, fst::StdArc(1, 1, 1.5, 1)); // 从状态0到状态1,输入符号为1,输出符号为1,权重为1.5,转移标识为1
|
||||
|
fst.AddArc(1, fst::StdArc(2, 2, 2.5, 2)); // 从状态1到状态2,输入符号为2,输出符号为2,权重为2.5,转移标识为2
|
||||
|
|
||||
|
// 设置终止状态
|
||||
|
fst.SetFinal(2, 3.5); // 设置状态2为终止状态,权重为3.5
|
||||
|
|
||||
|
// 输出 FST 的文本表示
|
||||
|
fst.Write("example.fst"); |
||||
|
|
||||
|
return 0; |
||||
|
} |
@ -1,18 +1,13 @@ |
|||||
#include <iostream>
|
#include <iostream>
|
||||
#include <onnxruntime/onnxruntime.h>
|
|
||||
#include <onnxruntime/core/session/onnxruntime_session.h>
|
|
||||
#include <onnxruntime/core/provider/cpu/cpu_provider_factory.h>
|
|
||||
|
#include "onnxruntime_cxx_api.h" // NOLINT
|
||||
|
|
||||
using namespace std; |
using namespace std; |
||||
using namespace onnxruntime; |
|
||||
|
|
||||
int main() { |
int main() { |
||||
// 初始化ONNX Runtime
|
// 初始化ONNX Runtime
|
||||
OrtSessionOptions session_options; |
|
||||
session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_ALL); |
|
||||
session_options.SetExecutionProvider_CPU(true); |
|
||||
OrtSession session(session_options); |
|
||||
|
|
||||
printf("Run ONNX Done..") |
|
||||
|
Ort::SessionOptions opt = Ort::SessionOptions(); |
||||
|
Ort::Env env = Ort::Env(ORT_LOGGING_LEVEL_WARNING, ""); |
||||
|
opt.SetIntraOpNumThreads(1); |
||||
|
printf("Run ONNX Done..%d,%f\n"); |
||||
return 0; |
return 0; |
||||
} |
} |
@ -1,11 +1,3 @@ |
|||||
FetchContent_Declare(gflags |
|
||||
SOURCE_DIR ${LIB_BASE_DIR}/gflags-src |
|
||||
) |
|
||||
|
|
||||
set(gflags_DIR ${LIB_BASE_DIR}/gflags-build) |
|
||||
|
|
||||
FetchContent_MakeAvailable(gflags) |
|
||||
|
|
||||
include_directories(${gflags_DIR}/include) |
|
||||
|
find_package(gflags REQUIRED) |
||||
|
|
||||
list(APPEND third_party_libraries gflags) |
list(APPEND third_party_libraries gflags) |
@ -1,8 +1,2 @@ |
|||||
FetchContent_Declare(glog |
|
||||
SOURCE_DIR ${LIB_BASE_DIR}/glog-src |
|
||||
) |
|
||||
set(gflags_DIR ${LIB_BASE_DIR}/gflags-build) |
|
||||
|
|
||||
FetchContent_MakeAvailable(glog) |
|
||||
|
|
||||
list(APPEND third_party_libraries glog) |
|
||||
|
find_package(glog REQUIRED) |
||||
|
list(APPEND third_party_libraries glog::glog) |
@ -0,0 +1,52 @@ |
|||||
|
# We can't build glog with gflags, unless gflags is pre-installed. |
||||
|
# If build glog with pre-installed gflags, there will be conflict. |
||||
|
#message(STATUS "${BoldGreen}glog: ${glog_SOURCE_DIR}${ColourReset}") |
||||
|
|
||||
|
set(openfst_BUILD "${LIB_BASE_DIR}/openfst-build") |
||||
|
if(NOT EXISTS ${openfst_BUILD}) |
||||
|
# install openfst |
||||
|
#./configure --prefix=${openfst_SOURCE_DIR}/build --enable-static --disable-shared --with-pic |
||||
|
execute_process( |
||||
|
COMMAND ./configure --prefix=${openfst_BUILD} |
||||
|
WORKING_DIRECTORY ${LIB_BASE_DIR}/openfst-src) |
||||
|
execute_process( |
||||
|
COMMAND cmake --build . --target install |
||||
|
WORKING_DIRECTORY ${openfst_BUILD}) |
||||
|
execute_process( |
||||
|
COMMAND cmake --install . |
||||
|
WORKING_DIRECTORY ${openfst_BUILD}) |
||||
|
endif() |
||||
|
# We can't build glog with gflags, unless gflags is pre-installed. |
||||
|
# If build glog with pre-installed gflags, there will be conflict. |
||||
|
find_package(gflags) |
||||
|
set(WITH_GFLAGS OFF CACHE BOOL "whether build glog with gflags" FORCE) |
||||
|
find_package(glog) |
||||
|
|
||||
|
if(NOT GRAPH_TOOLS) |
||||
|
set(HAVE_BIN OFF CACHE BOOL "Build the fst binaries" FORCE) |
||||
|
set(HAVE_SCRIPT OFF CACHE BOOL "Build the fstscript" FORCE) |
||||
|
endif() |
||||
|
set(HAVE_COMPACT OFF CACHE BOOL "Build compact" FORCE) |
||||
|
set(HAVE_CONST OFF CACHE BOOL "Build const" FORCE) |
||||
|
set(HAVE_GRM OFF CACHE BOOL "Build grm" FORCE) |
||||
|
set(HAVE_FAR OFF CACHE BOOL "Build far" FORCE) |
||||
|
set(HAVE_PDT OFF CACHE BOOL "Build pdt" FORCE) |
||||
|
set(HAVE_MPDT OFF CACHE BOOL "Build mpdt" FORCE) |
||||
|
set(HAVE_LINEAR OFF CACHE BOOL "Build linear" FORCE) |
||||
|
set(HAVE_LOOKAHEAD OFF CACHE BOOL "Build lookahead" FORCE) |
||||
|
set(HAVE_NGRAM OFF CACHE BOOL "Build ngram" FORCE) |
||||
|
set(HAVE_SPECIAL OFF CACHE BOOL "Build special" FORCE) |
||||
|
|
||||
|
FetchContent_Declare(openfst |
||||
|
SOURCE_DIR ${LIB_BASE_DIR}/openfst-src) |
||||
|
# |
||||
|
FetchContent_MakeAvailable(openfst) |
||||
|
include_directories(${openfst_SOURCE_DIR}/src/include) |
||||
|
set(openfst_BINARY_DIR "${grpc_build_dir}/src/lib") |
||||
|
add_dependencies(fst glog::glog gflags) |
||||
|
|
||||
|
list(APPEND third_party_libraries fst glog::glog gflags) |
||||
|
|
||||
|
#list(APPEND third_party_libraries ) |
||||
|
|
||||
|
# |