| 21 | using TensorRTUniquePtr = intl::TensorRTUniquePtr<T>; |
| 22 | |
| 23 | TEST(TestOprTensorRT, RuntimeBasic) { |
| 24 | REQUIRE_GPU(1); |
| 25 | intl::SimpleTensorRTNetwork net; |
| 26 | auto make_trt = [&net]() { |
| 27 | auto p = net.create_trt_network(false); |
| 28 | TensorRTUniquePtr<INetworkDefinition> trt_net{p.second, {}}; |
| 29 | TensorRTUniquePtr<IBuilder> builder{p.first, {}}; |
| 30 | builder->setMaxBatchSize(5); |
| 31 | #if NV_TENSOR_RT_VERSION >= 6001 |
| 32 | TensorRTUniquePtr<IBuilderConfig> build_config{builder->createBuilderConfig()}; |
| 33 | TensorRTUniquePtr<ICudaEngine> cuda_engine{ |
| 34 | builder->buildEngineWithConfig(*trt_net, *build_config)}; |
| 35 | #else |
| 36 | TensorRTUniquePtr<ICudaEngine> cuda_engine{builder->buildCudaEngine(*trt_net)}; |
| 37 | #endif |
| 38 | TensorRTUniquePtr<IHostMemory> mem{cuda_engine->serialize(), {}}; |
| 39 | return TensorRTRuntimeOpr::make(mem->data(), mem->size(), {net.x})[0]; |
| 40 | }; |
| 41 | auto y2 = make_trt(); |
| 42 | |
| 43 | HostTensorND host_z1; |
| 44 | HostTensorND host_z2; |
| 45 | auto func = net.graph->compile( |
| 46 | {make_callback_copy(net.y, host_z1), make_callback_copy(y2, host_z2)}); |
| 47 | func->execute(); |
| 48 | MGB_ASSERT_TENSOR_NEAR(host_z1, host_z2, 5e-4); |
| 49 | } |
| 50 | |
| 51 | TEST(TestOprTensorRT, RuntimeBasicBatched) { |
| 52 | REQUIRE_GPU(1); |
nothing calls this directly
no test coverage detected