-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix compiler warning & speed up compile stage. #1197
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* 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 "paddle/utils/ClassRegistrar.h" | ||
|
||
namespace paddle { | ||
class FuncConfig; | ||
class BufferArgs; | ||
|
||
/** | ||
* \brief Base class for Function. | ||
* The basic Function implementation requires override init and calc interfaces. | ||
* | ||
* The caller needs to ensure the validity of the arguments | ||
* during Function execution. | ||
* | ||
* Function inputs are readonly, Function outputs have two modes: ASSIGN_TO | ||
* and ADD_TO. | ||
* If output.getArgType() == ASSIGN_TO, this is assign mode, and the calculation | ||
* result of Function assigned to the output BufferArg. | ||
* If output.getArgType() == ADD_TO, this is add mode, and the calculation | ||
* result of Function need added to the output BufferArg. | ||
* | ||
* For example: | ||
* ASSIGN_TO: output = Function(inputs) | ||
* ADD_TO: output += Function(inputs) | ||
* If Function has more than one output, each output can have different modes. | ||
*/ | ||
class FunctionBase { | ||
public: | ||
virtual ~FunctionBase() {} | ||
|
||
virtual void init(const FuncConfig& config) { (void)(config); } | ||
|
||
virtual void calc(const BufferArgs& inputs, const BufferArgs& outputs) { | ||
(void)(inputs); | ||
(void)(outputs); | ||
} | ||
|
||
static ClassRegistrar<FunctionBase> funcRegistrar_; | ||
}; | ||
|
||
#define FUNC_NAME(typeName, deviceName) #typeName "-" #deviceName | ||
|
||
#define REGISTER_TYPED_FUNC(typeName, deviceName, className) \ | ||
static InitFunction __reg_type_##typeName##deviceName([]() { \ | ||
FunctionBase::funcRegistrar_ \ | ||
.registerClass<className<DEVICE_TYPE_##deviceName>>( \ | ||
FUNC_NAME(typeName, deviceName)); \ | ||
}) | ||
|
||
} // namespace paddle |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ limitations under the License. */ | |
#include <functional> | ||
#include <memory> | ||
#include "ModelConfig.pb.h" | ||
#include "paddle/function/Function.h" | ||
#include "paddle/function/FunctionBase.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make Layer.h depend on FunctionBase.h. It could speed up compiling time very much, and it makes us not to recompile the whole Paddle when we change something in Function library. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layer.h还是需要知道完整的BufferArgs类型的;Function的Prepare arguments阶段是将Layer的参数Argument类型,转换成Function的参数BufferArg类型,这个对于很多Layer的实现是一样的,后续会考虑在class Layer里面实现。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 好,那我先close了。。其他的fix回头顺手改一下吧 :) |
||
#include "paddle/math/CpuSparseMatrix.h" | ||
#include "paddle/parameter/Parameter.h" | ||
#include "paddle/utils/ClassRegistrar.h" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is simpler to use a 'U' or 'UL' suffix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
哦,warning来自于unsigned。