Notice: 可使用模型查看器来查看模型输入名和输出名,例如 Netron 。
-
从 BERT 下载 BERT 模型。 此处以 BERT-tiny 为例。
-
利用 export_bert.py 导出
frozen_bert.pb。 -
参考 CMake-Build 构建 Forward 库。
-DENABLE_TENSORFLOW=ON,-DBUILD_PYTHON_LIB=ON,-DPYTHON_EXECUTABLE=$(which python3)须要被声明。 -
将 Forward-Python 库拷贝到当前目录。
-
执行
test_tf_bert.py脚本。
-
安装
transformers和torch。 -
参考 CMake-Build 构建 Forward 库。
-DENABLE_TORCH=ON,-DBUILD_PYTHON_LIB=ON,-DPYTHON_EXECUTABLE=$(which python3)须要被声明。 -
将 Forward-Python 库拷贝到当前目录。
-
执行
test_torch_bert.py脚本。
-
安装
transformers,并通过transformers.onnx包转换 ONNX 模型。此处以导出 BERT 模型在bert-base-uncased检查点为例,python -m transformers.onnx --model=bert-base-uncased bert.onnx。 -
参考 CMake-Build 构建 Forward 库。
-DENABLE_ONNX=ON,-DBUILD_PYTHON_LIB=ON,-DPYTHON_EXECUTABLE=$(which python3)须要被声明。 -
将 Forward-Python 库拷贝到当前目录。
-
执行
test_onnx_bert.py脚本。