-
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
Feature/change op creation #3237
Feature/change op creation #3237
Conversation
Rename operator.py to op.py because it is conflict with protobuf
@@ -1,131 +0,0 @@ | |||
import paddle.v2.framework.core as core |
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.
先把network.py
删掉,直到我们完成high level api设计。
Currently use `Operator("fc", X="x", W='w1', B='b1')` as operator creation method. Fix PaddlePaddle#3198
8676643
to
89d33ff
Compare
python/paddle/v2/framework/op.py
Outdated
return { | ||
'method': __impl__, | ||
'name': op_proto.type, | ||
'all_inputs': [var.name for var in op_proto.inputs], |
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.
why need all
, can we just use inputs/outputs?
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.
Because some of outputs are temporary. The outputs()
API is confusing whether it contains temporary output or not.
python/paddle/v2/framework/op.py
Outdated
__impl__.all_not_temp_output_args = [ | ||
var.name for var in op_proto.outputs if not var.temporary | ||
] | ||
return { |
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.
maybe it's better to have a inner class
class OpWrapper {
def __init__(self, op_proto):
self.op_proto = op_proto
def inputs():
return self.op_proto.inputs
...
}
the benefit is it will have a type, and we can use
self.get_op_creation_info(type).inputs()
to get inputs instead of
self.get_op_creation_info(type)["inputs"]
this ask coder to search the code for the dict defination
if core.is_compile_gpu(): | ||
places.append(core.GPUPlace(0)) | ||
|
||
for place in places: | ||
for in_name in func.all_input_args: | ||
if hasattr(self, "inputs") and in_name in self.inputs: | ||
for in_name in Operator.get_op_input_names(self.type): |
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.
If we have a OpWrapper
class, we can use
for in_name in Operator.Info("type").inputs():
pass
and remove get_op_input_names
effd1c7
to
9f81635
Compare
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.
LGTM!
3fc40f9
to
460326f
Compare
use
Operator("fc", X="x", W='w1', B='b1')
as operatorcreation method.
Fix #3198