-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Op refine for making build system more automatic #3852
Changes from 4 commits
c20a01d
3b16201
2071322
d4087ef
9d2909b
96cdb2c
8c048aa
58369d5
faa4da4
a60128a
fb49bc2
c2c5df2
0b478e9
5b93ac7
10eacac
740c8ba
d7b2058
3542027
a523bea
7c78542
77a15b6
9a3c69c
94f7562
bb0a11c
9f3bcd0
e4494bb
35bb0c0
b3463bf
843a8b1
3ab9327
020e45f
d44663f
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 |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
|
||
#define EIGEN_USE_GPU | ||
#include "paddle/framework/op_registry.h" | ||
#include "paddle/operators/add_op.h" | ||
#include "paddle/operators/add_two_op.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. Curious why rename to 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. Because 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. I see. 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.
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. I agree, then I will revert and change 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. Thanks very much! |
||
|
||
namespace ops = paddle::operators; | ||
REGISTER_OP_GPU_KERNEL(add_two, | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* 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/operators/net_op.h" | ||
#include "paddle/operators/scale_op.h" | ||
|
||
namespace paddle { | ||
namespace operators { | ||
|
||
// identity is a alias of scale op. This is also a example for creating a alias | ||
// operator. | ||
template <typename AttrType> | ||
class IdentityOpMaker : public framework::OpProtoAndCheckerMaker { | ||
public: | ||
IdentityOpMaker(framework::OpProto *proto, | ||
framework::OpAttrChecker *op_checker) | ||
: OpProtoAndCheckerMaker(proto, op_checker) { | ||
AddInput("X", "input tensor of identity op"); | ||
AddOutput("Out", "output tensor of identity op"); | ||
AddComment("identity operator. Just a alias of scale op which scale = 1.0"); | ||
} | ||
}; | ||
|
||
template <typename AttrType> | ||
class IdentityOp : public NetOp { | ||
public: | ||
IdentityOp(const std::string &type, const framework::VariableNameMap &inputs, | ||
const framework::VariableNameMap &outputs, | ||
const framework::AttributeMap &attrs) | ||
: NetOp(type, inputs, outputs, attrs) { | ||
AppendOp(framework::OpRegistry::CreateOp( | ||
"scale", {{"X", {Input("X")}}}, {{"Out", {Output("Out")}}}, | ||
{{"scale", static_cast<AttrType>(1)}})); | ||
} | ||
}; | ||
|
||
} // namespace operators | ||
} // namespace paddle | ||
|
||
namespace ops = paddle::operators; | ||
|
||
REGISTER_OP_WITHOUT_GRADIENT(identity, ops::IdentityOp<float>, | ||
ops::IdentityOpMaker<float>); |
This file was deleted.
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.
Does this make it simpler if we make
op_library
smarter, just callop_library(${src})
, then it can do the following:find if have both
.cc
and.cu
file, callcc_library
andnv_library
to add corresponding library.So we can call
op_library(${src})
for general ops andop_library(${src} DEPS xxx)
for ops have dependencies.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.
You are right, I will refine it.
Most ops have the same name for
.cc
and.cu
. But forrecurrent_op
, the${src}
is notrecurrent_op.cc
andrecurrent_op.cu
.Thus,
if ${src} is none
, cmake will auto find${src}.cc
and${src}.cu
. If user specific${src}
, cmake will use what user specify.