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/add op test #2947

Merged
merged 2 commits into from
Jul 19, 2017
Merged

Conversation

reyoung
Copy link
Collaborator

@reyoung reyoung commented Jul 18, 2017

Review #2945 First.

* Fc operator is a grouped operator, which combined by may internal
  operators.
* InferShape & Run a FC operator in Python.
@@ -0,0 +1,17 @@
import unittest
from op_test_util import OpTestMeta
import numpy
Copy link
Contributor

Choose a reason for hiding this comment

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

import numpy as np

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it doesn't matter.

@@ -14,6 +14,7 @@ limitations under the License. */

#include <Python.h>
#include <paddle/framework/op_registry.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

#include "paddle/framework/op_registry.h"

others same.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will give another PR fix them all.

@@ -19,7 +19,10 @@
namespace paddle {
namespace framework {

void PlainNet::CompleteAddOp() {
void PlainNet::CompleteAddOp(bool calc) {
Copy link
Member

Choose a reason for hiding this comment

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

为什么需要 calc?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

因为其实继承产生的Net,是不需要重新计算哪些输入和输出的。

@@ -41,6 +42,35 @@ class DefaultValueSetter {
T default_value_;
};

template <typename T>
class EnumInContainer {
Copy link
Member

Choose a reason for hiding this comment

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

this class is used as checker, so if EnumInContainerChecker a better name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If that names are really matter, I prefer add a sub namespace to do this.

namespace paddle {
namespace framework {
namespace attr_checkers {
}
}
}

auto b = Input("b");
if (b != framework::OperatorBase::EMPTY_VAR_NAME()) {
AddOp(framework::OpRegistry::CreateOp("rowwise_add",
{Output("before_act"), Input("b")},
Copy link
Member

@jacquesqiao jacquesqiao Jul 19, 2017

Choose a reason for hiding this comment

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

Is act a good abbreviation for activation?

@@ -0,0 +1,43 @@
import paddle.v2.framework.core as core
Copy link
Member

Choose a reason for hiding this comment

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

这个test为何不用 OpTestMeta?

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 there are many op not implemented yet.

import paddle.v2.framework.create_op_creation_methods as creation


class OpTestMeta(type):
Copy link
Member

Choose a reason for hiding this comment

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

can you explain the Principle of this meta class?

@@ -217,6 +217,10 @@ def __impl__(*args, **kwargs):
return core.Operator.create(opdesc.SerializeToString())

__impl__.__doc__ = get_docstring_from_op_proto(op_proto)
__impl__.all_input_args = [var.name for var in op_proto.inputs]
__impl__.all_output_args = [var.name for var in op_proto.outputs]
Copy link
Member

Choose a reason for hiding this comment

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

I think following is better

all_input_names
all_output_names
all_attrs_names

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is not input_name, it is input argument name of that Op function.

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 merged commit d529134 into PaddlePaddle:develop Jul 19, 2017
@reyoung
Copy link
Collaborator Author

reyoung commented Jul 19, 2017

I merge this PR first because many other PRs depends on this PR. I will add comments to OpTestMeta in another PR.

@reyoung reyoung deleted the feature/add_op_test branch July 26, 2017 06:36
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.

3 participants