MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / TEST

Function TEST

src/tensorrt/test/tensorrt_runtime.cpp:23–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21using TensorRTUniquePtr = intl::TensorRTUniquePtr<T>;
22
23TEST(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
51TEST(TestOprTensorRT, RuntimeBasicBatched) {
52 REQUIRE_GPU(1);

Callers

nothing calls this directly

Calls 15

make_callback_copyFunction · 0.85
output_fileFunction · 0.85
to_shared_ptr_engineFunction · 0.85
castFunction · 0.85
subFunction · 0.85
create_trt_networkMethod · 0.80
renameMethod · 0.80
resizeMethod · 0.80
dist_byteMethod · 0.80
spanMethod · 0.80
makeFunction · 0.50
genFunction · 0.50

Tested by

no test coverage detected