| 122 | using namespace turbo_transformers; |
| 123 | |
| 124 | int main(int argc, char *argv[]) { |
| 125 | if (argc != 2) { |
| 126 | std::cerr << "./bert_example npz_model_path" << std::endl; |
| 127 | return -1; |
| 128 | } |
| 129 | const std::string model_path = static_cast<std::string>(argv[1]); |
| 130 | |
| 131 | if (core::IsCompiledWithCUDA()) { |
| 132 | std::cout << "run bert on GPU, device id is 0" << std::endl; |
| 133 | test(model_path, true /*use cuda*/); |
| 134 | } |
| 135 | std::cout << "run bert on CPU, use 4 threads to do bert inference" |
| 136 | << std::endl; |
| 137 | turbo_transformers::core::SetNumThreads(4); |
| 138 | test(model_path, false /*not use cuda*/); |
| 139 | turbo_transformers::core::SetNumThreads(1); |
| 140 | if (core::IsCompiledWithCUDA()) { |
| 141 | std::cout << "10 threads do 10 independent bert inferences." << std::endl; |
| 142 | test_multiple_threads(model_path, false /*only_input*/, true /*use cuda*/, |
| 143 | 10); |
| 144 | } |
| 145 | test_multiple_threads(model_path, false /*only_input*/, |
| 146 | false /*not use cuda*/, 10); |
| 147 | return 0; |
| 148 | } |
nothing calls this directly
no test coverage detected