MCPcopy Create free account
hub / github.com/Tencent/TurboTransformers / main

Function main

example/cpp/bert_model_example.cpp:124–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122using namespace turbo_transformers;
123
124int 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}

Callers

nothing calls this directly

Calls 4

IsCompiledWithCUDAFunction · 0.85
SetNumThreadsFunction · 0.85
testFunction · 0.70
test_multiple_threadsFunction · 0.70

Tested by

no test coverage detected