Skip to content
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a3140d3
add tensorrt
Superjomn Apr 13, 2018
a60189f
set tensorrt on as default
Superjomn Apr 13, 2018
b95d819
add cudnn dependency
Superjomn Apr 13, 2018
87fc090
Merge branch 'develop' of github.com:PaddlePaddle/Paddle into fea/add…
Superjomn Apr 13, 2018
8dda580
nvtest
Superjomn Apr 13, 2018
92480b5
add tensorrt dynamic loader
Superjomn Apr 13, 2018
5891896
add tensorrt as dyload
Superjomn Apr 13, 2018
1b475b3
Merge branch 'develop' of github.com:PaddlePaddle/Paddle into fea/add…
Superjomn Apr 15, 2018
9d617b8
finish test
Superjomn Apr 15, 2018
0e8e85f
remove tensorrt.cmake
Superjomn Apr 15, 2018
63b6a74
fix pip upgrade pip error
Superjomn Apr 15, 2018
d492547
add flag definition for tensorrt_dir
Superjomn Apr 16, 2018
4f0a2ab
code clean
Superjomn Apr 16, 2018
e220226
add default so search path
Superjomn Apr 16, 2018
5132a2b
update
Superjomn Apr 16, 2018
dc23dc5
Merge branch 'fea/add_tensorrt' into fea/tensorrt_engine
Superjomn Apr 16, 2018
1fe9f63
change cmake config
Superjomn Apr 16, 2018
cf4f092
Merge branch 'fea/add_tensorrt' into fea/tensorrt_engine
Superjomn Apr 16, 2018
f1b5040
init
Superjomn Apr 17, 2018
9699574
init
Superjomn Apr 17, 2018
aa7ab53
update
Superjomn Apr 17, 2018
1d13858
finish coding
Superjomn Apr 18, 2018
4da8cbd
Merge branch 'develop' of github.com:PaddlePaddle/Paddle into fea/ten…
Superjomn Apr 18, 2018
5463325
fix conflict on Dockerfile
Superjomn Apr 18, 2018
74ea1f6
add new get output apis
Superjomn Apr 18, 2018
610f290
format code
Superjomn Apr 18, 2018
f273eef
Update networks.py
Superjomn Apr 18, 2018
57c0ddb
add inference namespace
Superjomn Apr 19, 2018
25397ca
Merge branch 'fea/tensorrt_engine' of github.com:Superjomn/Paddle int…
Superjomn Apr 19, 2018
6d89b54
fix copyright
Superjomn Apr 19, 2018
97a34ac
engine add namespace
Superjomn Apr 19, 2018
5b8de3b
change according to review
Superjomn Apr 24, 2018
bbf19cb
wrap test
Superjomn Apr 24, 2018
4c0ce9d
add helper
Superjomn Apr 25, 2018
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
52 changes: 52 additions & 0 deletions paddle/fluid/inference/engine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright的格式调整一下吧。另外新加入的文件copyright里面的年份应该是2018年。


#pragma once

#include "paddle/fluid/framework/framework.pb.h"

namespace paddle {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照Paddle对于命名空间的使用规则,这里应该还有一层namespace inference
另外,有个问题确认一下,TensorRT实现相关的所有代码,包括tensorrt_op,都放置在inference目录下吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可能会有下面的目录

  • inference/engine.h, engine 宏观接口
  • inference/tensorrt 装tensorrt 相关的内容
    • engine_op[.h/.cc], 包含 TensorrtEngineOp
    • convert[.h/.cc] 帮convert fluid op -> tensorrt layer
  • inference/alajin 装 alajin的
    类似 tensorrt的

/*
* EngineBase is the base class of all inference engines. An inference engine
* takes a paddle program as input, and output the result in paddle Tensor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. output->outputs
  2. paddle Tensor format->fluid tensor format

* format. It can be used to optimize performance of computation subgraphs, for
* example, break down the original model into subgraphs and execute each
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用block概念是不是更为统一,下同

  1. original model:original block?
  2. subgraphs->sub-block?

* subgraph in different engines.
*
* For example:
* When inference, the resnet50 model can put most of the model into subgraph
* and run it on a TensorRT engine.
*
* There are several engines such as TensorRT and other internal frameworks, so
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other internal frameworks,可以去掉internal

* an EngineBase is put forward to give an unified interface for all the
* different engine implemention.
*/
class EngineBase {
public:
// TODO fix it latter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请问39行是要fix什么呢?能否写的详细一点
PbType是指什么?

Copy link
Contributor Author

@Superjomn Superjomn Apr 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里 PbType 表示 desc 的格式,会换一个明确的名字

using PbType = int; // proto::BlockDesc;

// Build the model and do some preparation, for example, in TensorRT, run
// createInferBuilder, buildCudaEngine.
virtual void Build(const PbType& paddle_model) = 0;

// Execute the engine, that will run the inference network.
virtual void Execute(int batch_size) = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Execute函数是不是最好以Paddle的LoDTensor类型作为参数?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 engine 只是个工具类,会由 TensorrtEngineOp 调用。

我的理解, TensorrtEngineOp 应该会把 engine 封装成 fluid op

engine 的 input 和 output 以及个数都不固定,有 DeclInputDeclOutput 两个分别来创建 tensorrt 的 Input 和 output 节点。

这个类会暴露出比较多的小接口,这些接口会帮助构建 tensorrt 的network 以及 runtime engine, 中间小接口基本是不可少的。 最重要的用处是在 TensorrtEngineOp 里,额外的会在各种 UT 里使用, 比如 fluid_op 与convert后的 tensorrt layer 之间做无diff, 用这个类可以帮助跑 tensorrt layer和取结果。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeclInput 和 DeclOutput 两个分别来创建 tensorrt 的 Input 和 output 节点

这两个和Convert类里的ConvertInput和ConvertOutput里,除了转的那步,功能很类似。有更好的设计办法么?

Decl这四个字母含义不够清晰,能否就叫Add呢?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

会改成 DeclareInput,表示在 TensorRT network中添加 data 节点


virtual ~EngineBase() {}

}; // class EngineBase

} // namespace paddle
1 change: 1 addition & 0 deletions paddle/fluid/inference/tensorrt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
nv_test(test_tensorrt SRCS test_tensorrt.cc DEPS dynload_cuda device_context dynamic_loader)
nv_test(test_tensorrt_engine SRCS test_engine.cc engine.cc DEPS dynload_cuda)
189 changes: 189 additions & 0 deletions paddle/fluid/inference/tensorrt/engine.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */

#include "paddle/fluid/inference/tensorrt/engine.h"

#include <NvInfer.h>
#include <cuda.h>
#include <glog/logging.h>
#include "paddle/fluid/platform/dynload/tensorrt.h"
#include "paddle/fluid/platform/enforce.h"

namespace dy = paddle::platform::dynload;

namespace paddle {

size_t AccumDims(nvinfer1::Dims dims) {
size_t num = dims.nbDims == 0 ? 0 : 1;
for (int i = 0; i < dims.nbDims; i++) {
PADDLE_ENFORCE_GT(dims.d[i], 0);
LOG(INFO) << "dim.d: " << i << " " << dims.d[i];
num *= dims.d[i];
}
return num;
}

const int kDataTypeSize[] = {
4, // kFLOAT
2, // kHALF
1, // kINT8
4 // kINT32
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AccumDims和kDataTypeSize可以放在xxx_helper.cc里么?因为convert类实现的时候可能也会用到。

kDataTypeSize这样写,不太好使用。能做成enum类型么?


void TensorrtEngine::Build(const PbType& paddle_model) {
PADDLE_ENFORCE(false, "not implemented");
}

void TensorrtEngine::Execute(int batch_size) {
infer_context_->enqueue(batch_size, buffers_.data(), *stream_, nullptr);
cudaStreamSynchronize(*stream_);
}

TensorrtEngine::~TensorrtEngine() {
// clean buffer
for (auto& buffer : buffers_) {
if (buffer != nullptr) {
PADDLE_ENFORCE_EQ(0, cudaFree(buffer));
buffer = nullptr;
}
}
}

namespace {

class Logger : public nvinfer1::ILogger {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个logger放在engine.cc里面合适么?可以放在xxx_helper.cc里么?

public:
void log(nvinfer1::ILogger::Severity severity, const char* msg) override {
switch (severity) {
case Severity::kINFO:
LOG(INFO) << msg;
break;
case Severity::kWARNING:
LOG(WARNING) << msg;
break;
case Severity::kINTERNAL_ERROR:
case Severity::kERROR:
LOG(ERROR) << msg;
break;
default:
break;
}
}
};

// The following two API are implemented in TensorRT's header file, cannot load
// from the dynamic library. So create our own implementation and directly
// trigger the method from the dynamic library.
nvinfer1::IBuilder* createInferBuilder(nvinfer1::ILogger& logger) {
return static_cast<nvinfer1::IBuilder*>(
dy::createInferBuilder_INTERNAL(&logger, NV_TENSORRT_VERSION));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createInferBuilder这个函数只在InitNetwork函数里用了,这里可以不做封装,直接用么?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add tensorrt_helper.cc

}
nvinfer1::IRuntime* createInferRuntime(nvinfer1::ILogger& logger) {
return static_cast<nvinfer1::IRuntime*>(
dy::createInferRuntime_INTERNAL(&logger, NV_TENSORRT_VERSION));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createInferRuntime这个函数在其他地方没有见到,可以先删去?

}
} // namespace

void TensorrtEngine::InitNetwork() {
Logger logger;
infer_builder_.reset(createInferBuilder(logger));
infer_network_.reset(infer_builder_->createNetwork());
}

void TensorrtEngine::FreezeNetwork() {
PADDLE_ENFORCE(infer_builder_ != nullptr,
"Call InitNetwork first to initialize network.");
PADDLE_ENFORCE(infer_network_ != nullptr,
"Call InitNetwork first to initialize network.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

108行和110行的enforce内容一样?
PADDLE_ENFORCE(infer_builder_ != nullptr)-》 PADDLE_ENFORCE(infer_builder)是一样的。下同

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InitNetwork()

// build engine.
infer_builder_->setMaxBatchSize(max_batch_);
infer_builder_->setMaxWorkspaceSize(max_workspace_);

infer_engine_.reset(infer_builder_->buildCudaEngine(*infer_network_));
PADDLE_ENFORCE(infer_engine_ != nullptr, "build cuda engine failed!");

infer_context_.reset(infer_engine_->createExecutionContext());

// allocate GPU buffers.
buffers_.resize(buffer_sizes_.size(), nullptr);
for (auto& item : buffer_sizes_) {
if (item.second == 0) {
auto slot_offset = infer_engine_->getBindingIndex(item.first.c_str());
item.second = kDataTypeSize[static_cast<int>(
infer_engine_->getBindingDataType(slot_offset))] *
AccumDims(infer_engine_->getBindingDimensions(slot_offset));
}
PADDLE_ENFORCE_EQ(0, cudaMalloc(&buffer(item.first), item.second));
}
}

nvinfer1::ITensor* TensorrtEngine::DeclInput(const std::string& name,
data_type dtype,
const dim_type& dim) {
PADDLE_ENFORCE_EQ(0, buffer_sizes_.count(name), "duplicate input name %s",
name);

PADDLE_ENFORCE(infer_network_ != nullptr, "should initnetwork first");
auto* input = infer_network_->addInput(name.c_str(), dtype, dim);
PADDLE_ENFORCE(input, "infer network add input %s failed", name);

buffer_sizes_[name] = kDataTypeSize[static_cast<int>(dtype)] * AccumDims(dim);
return input;
}

void TensorrtEngine::DeclOutput(nvinfer1::ILayer* layer, int offset,
const std::string& name) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

前两个参数也是const类型

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const layer

PADDLE_ENFORCE_EQ(0, buffer_sizes_.count(name), "duplicate output name %s",
name);

auto* output = layer->getOutput(offset);
PADDLE_ENFORCE(output != nullptr);
output->setName(name.c_str());
infer_network_->markOutput(*output);
buffer_sizes_[name] = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么156行设成0?

Copy link
Contributor Author

@Superjomn Superjomn Apr 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ comment

// * data_size;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

157行删掉

}

void* TensorrtEngine::GetOutputInGPU(const std::string& name) {
return buffer(name);
}

void TensorrtEngine::GetOutputInCPU(const std::string& name, void* dst,
size_t max_size) {
// determine data size
auto it = buffer_sizes_.find(name);
PADDLE_ENFORCE(it != buffer_sizes_.end());
PADDLE_ENFORCE_GT(it->second, 0);
PADDLE_ENFORCE_GE(max_size, it->second);

PADDLE_ENFORCE_EQ(0, cudaMemcpyAsync(dst, buffer(name), it->second,
cudaMemcpyDeviceToHost, *stream_));
}

void*& TensorrtEngine::buffer(const std::string& name) {
PADDLE_ENFORCE(infer_engine_ != nullptr, "call freezenetwork first.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

freeze network 中间加空格

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FreeNetwork

auto it = buffer_sizes_.find(name);
PADDLE_ENFORCE(it != buffer_sizes_.end());
auto slot_offset = infer_engine_->getBindingIndex(name.c_str());
return buffers_[slot_offset];
}

void TensorrtEngine::SetInputFromCPU(const std::string& name, void* data,
size_t size) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size_t size也是const类型

void* buf = buffer(name);
PADDLE_ENFORCE_EQ(
0, cudaMemcpyAsync(buf, data, size, cudaMemcpyHostToDevice, *stream_));
}

} // namespace paddle
129 changes: 129 additions & 0 deletions paddle/fluid/inference/tensorrt/engine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */

#pragma once

#include <NvInfer.h>
#include <memory>
#include <unordered_map>
#include "paddle/fluid/inference/engine.h"

namespace paddle {

/*
* TensorRT Engine.
*
* There are two alternative ways to use it, one is to build from a paddle
* protobuf model, another way is to manully construct the network.
*/
class TensorrtEngine : public EngineBase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TensorrtEngine->TensorRTEngine,rt大写,和TensorRT一致。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

public:
using data_type = nvinfer1::DataType;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为nvinfer1::DataType也不是很长,使用原来的声明,参数类型会更加清晰。
同dim_type 。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

using dim_type = nvinfer1::Dims;

// Weight is model parameter.
class Weight {
public:
Weight(data_type dtype, void* value, int num_elem) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dtype和num_elem都应该是const类型

w_.type = dtype;
w_.values = value;
w_.count = num_elem;
}
const nvinfer1::Weights& get() { return w_; }

private:
nvinfer1::Weights w_;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weight class放在TensorrtEngine class里合适么?这个class也能被convert class调用。


TensorrtEngine(int max_batch, int max_workspace, cudaStream_t* stream)
: max_batch_(max_batch), max_workspace_(max_workspace), stream_(stream) {}

virtual ~TensorrtEngine();

// TODO(Superjomn) implement it latter when graph segmentation is supported.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latter-》later

virtual void Build(const PbType& paddle_model) override;

virtual void Execute(int batch_size) override;

// Initialize the infer network, so that layers can add to this network.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. infer->inference
  2. layers->ops

void InitNetwork();
// Finished adding layers, freeze this network and creates the executation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After finish adding ops

// environment.
void FreezeNetwork();

// Add an input and set its namd, data type and dimention.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namd->name

nvinfer1::ITensor* DeclInput(const std::string& name, data_type dtype,
const dim_type& dim);
// Set the offset-th output from a layer as the network's output, and set its
// name.
void DeclOutput(nvinfer1::ILayer* layer, int offset, const std::string& name);

// GPU memory address for a tensor with specific name. One can operate on
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的Tensor是fluid tensor还是tensorrt tensor,请说明一下。

// these memory directly for acceleration, for example, output the converted
// data directly to the buffer to save data copy overhead.
// NOTE this should be used after calling `FreezeNetwork`.
void*& buffer(const std::string& name);

// Fill an input from CPU memory with name and size.
void SetInputFromCPU(const std::string& name, void* data, size_t size);
// TODO(Superjomn) is this method necessary given that buffer(xxx) can be
// accessed directly. Fill an input from GPU memory with name and size.
void SetInputFromGPU(const std::string& name, void* data, size_t size);
// Get an output called name, the output of tensorrt is in GPU, so this method
// will just return the output's GPU memory address.
void* GetOutputInGPU(const std::string& name);
// LOW EFFICENCY! Get output to CPU, this will trigger a memory copy from GPU
// to CPU.
void GetOutputInCPU(const std::string& name, void* dst, size_t max_size);

nvinfer1::ICudaEngine* engine() { return infer_engine_.get(); }
nvinfer1::INetworkDefinition* network() { return infer_network_.get(); }

private:
int max_batch_;
int max_workspace_;
cudaStream_t* stream_;

std::vector<void*> buffers_;
// max data size for the buffers.
std::unordered_map<std::string /*name*/, size_t /*max size*/> buffer_sizes_;

template <typename T>
struct Destroyer {
void operator()(T* x) { x->destroy(); }
};

template <typename T>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

111-114行变量请加注释

using infer_ptr = std::unique_ptr<T, Destroyer<T>>;
infer_ptr<nvinfer1::IBuilder> infer_builder_;
infer_ptr<nvinfer1::INetworkDefinition> infer_network_;
infer_ptr<nvinfer1::ICudaEngine> infer_engine_;
infer_ptr<nvinfer1::IExecutionContext> infer_context_;
}; // class TensorrtEngine

// Add an layer__ into engine__ with args ARGS.
// For example:
// TRT_ENGINE_ADD_LAYER(xxx, FullyConnected, input, dim, weights, bias)
//
// Reference
// https://docs.nvidia.com/deeplearning/sdk/tensorrt-developer-guide/index.html#charRNN_define_network
//
// will add a fully connected layer into the engine.
// TensorRT has too many layers, so that is not wise to add member functions for
// them, and an macro like this is more extensible when underlying TensorRT
// library add new layer supports.
#define TRT_ENGINE_ADD_LAYER(engine__, layer__, ARGS...) \
engine__->network()->add##layer__(ARGS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请问这个宏定义可以去掉么?

  • 直接用原来的函数也很清晰;
  • 因为convert类里面也需要add不同的layer,那么convert类需要包含engine类的头文件,是不是不太合理?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个宏会

  • 提供统一add layer 的接口,而不需要为每种layer增加一个函数,比如 addFullyConnected


} // namespace paddle
Loading