-
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
Feature/add op test #2947
Feature/add op test #2947
Conversation
* 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 |
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.
import numpy as np
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.
I think it doesn't matter.
@@ -14,6 +14,7 @@ limitations under the License. */ | |||
|
|||
#include <Python.h> | |||
#include <paddle/framework/op_registry.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.
#include "paddle/framework/op_registry.h"
others same.
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.
I will give another PR fix them all.
@@ -19,7 +19,10 @@ | |||
namespace paddle { | |||
namespace framework { | |||
|
|||
void PlainNet::CompleteAddOp() { | |||
void PlainNet::CompleteAddOp(bool calc) { |
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.
为什么需要 calc?
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.
因为其实继承产生的Net,是不需要重新计算哪些输入和输出的。
@@ -41,6 +42,35 @@ class DefaultValueSetter { | |||
T default_value_; | |||
}; | |||
|
|||
template <typename T> | |||
class EnumInContainer { |
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.
this class is used as checker, so if EnumInContainerChecker a better name?
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 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")}, |
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.
Is act
a good abbreviation for activation?
@@ -0,0 +1,43 @@ | |||
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.
这个test为何不用 OpTestMeta?
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 there are many op not implemented yet.
import paddle.v2.framework.create_op_creation_methods as creation | ||
|
||
|
||
class OpTestMeta(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.
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] |
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.
I think following is better
all_input_names
all_output_names
all_attrs_names
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 not input_name
, it is input argument name
of that Op function.
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!
I merge this PR first because many other PRs depends on this PR. I will add comments to |
Review #2945 First.