Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions paddle/fluid/inference/tensorrt/test_tensorrt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ limitations under the License. */
#include <glog/logging.h>
#include <gtest/gtest.h>
#include "NvInfer.h"
#include "paddle/fluid/inference/tensorrt/helper.h"
#include "paddle/fluid/platform/dynload/tensorrt.h"

namespace dy = paddle::platform::dynload;

class Logger : public nvinfer1::ILogger {
public:
void log(nvinfer1::ILogger::Severity severity, const char* msg) override {
void log(nvinfer1::ILogger::Severity severity,
const char* msg) TRT_NOEXCEPT override {
switch (severity) {
case Severity::kINFO:
LOG(INFO) << msg;
Expand Down Expand Up @@ -74,10 +76,11 @@ nvinfer1::IHostMemory* CreateNetwork() {
Logger logger;
// Create the engine.
nvinfer1::IBuilder* builder = createInferBuilder(&logger);
auto config = builder->createBuilderConfig();
ScopedWeights weights(2.);
ScopedWeights bias(3.);

nvinfer1::INetworkDefinition* network = builder->createNetwork();
nvinfer1::INetworkDefinition* network = builder->createNetworkV2(0U);
// Add the input
auto input = network->addInput(kInputTensor, nvinfer1::DataType::kFLOAT,
nvinfer1::Dims3{1, 1, 1});
Expand All @@ -91,8 +94,8 @@ nvinfer1::IHostMemory* CreateNetwork() {
network->markOutput(*output);
// Build the engine.
builder->setMaxBatchSize(1);
builder->setMaxWorkspaceSize(1 << 10);
auto engine = builder->buildCudaEngine(*network);
config->setMaxWorkspaceSize(1 << 10);
auto engine = builder->buildEngineWithConfig(*network, *config);
EXPECT_NE(engine, nullptr);
// Serialize the engine to create a model, then close.
nvinfer1::IHostMemory* model = engine->serialize();
Expand Down