Skip to content
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

Merged
merged 9 commits into from
Aug 7, 2017

Conversation

reyoung
Copy link
Collaborator

@reyoung reyoung commented Aug 4, 2017

use Operator("fc", X="x", W='w1', B='b1') as operator
creation method.

Fix #3198

@reyoung reyoung requested review from jacquesqiao and QiJune August 4, 2017 07:12
@@ -1,131 +0,0 @@
import paddle.v2.framework.core as core
Copy link
Collaborator Author

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
@reyoung reyoung force-pushed the feature/change_op_creation branch from 8676643 to 89d33ff Compare August 4, 2017 07:22
return {
'method': __impl__,
'name': op_proto.type,
'all_inputs': [var.name for var in op_proto.inputs],
Copy link
Member

@jacquesqiao jacquesqiao Aug 7, 2017

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?

Copy link
Collaborator Author

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.

__impl__.all_not_temp_output_args = [
var.name for var in op_proto.outputs if not var.temporary
]
return {
Copy link
Member

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):
Copy link
Member

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

@reyoung reyoung force-pushed the feature/change_op_creation branch from effd1c7 to 9f81635 Compare August 7, 2017 06:40
Copy link
Member

@jacquesqiao jacquesqiao left a comment

Choose a reason for hiding this comment

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

LGTM!

@reyoung reyoung force-pushed the feature/change_op_creation branch from 3fc40f9 to 460326f Compare August 7, 2017 08:46
@reyoung reyoung merged commit 5a7a3c4 into PaddlePaddle:develop Aug 7, 2017
@reyoung reyoung deleted the feature/change_op_creation branch October 2, 2017 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants