Skip to content

Commit aa285cd

Browse files
committed
Merge branch 'develop' of github.com:baidu/Paddle into feature/enhance_evaluator
2 parents 86c0495 + c9172c1 commit aa285cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+327
-284
lines changed

paddle/framework/backward.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ ParamGradInfoMap AppendBackward(
522522
new OpDescBind("fill_constant", {}, {{"Out", {fill_one_op_out}}},
523523
{{"shape", std::vector<int>{1}},
524524
{"value", static_cast<float>(1.0)},
525-
{"data_type", target.GetDataType()}}));
525+
{"dtype", target.GetDataType()}}));
526526
// infer var type of fill_one_op
527527
fill_one_op->InferVarType(root_block);
528528

paddle/framework/tensor_array.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ LoDTensor TensorArray::Stack() const {
302302

303303
const auto& first_dims = values_.front().dims();
304304
// check all the values have the same shape
305-
// TODO(superjom) check the same dtypes
305+
// TODO(superjom) check the same data_type
306306
for (size_t idx = 1; idx < size(); idx++) {
307307
const auto& value_dims = values_[idx].dims();
308308
PADDLE_ENFORCE_EQ(first_dims, value_dims);

paddle/memory/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_subdirectory(detail)
22

3-
cc_library(memory SRCS memory.cc DEPS place)
3+
cc_library(memory SRCS memory.cc DEPS place enforce)
44
cc_library(memcpy SRCS memcpy.cc)
55

66
cc_library(paddle_memory

paddle/operators/bilinear_tensor_product_op.cc

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,19 @@ class BilinearTensorProductOpMaker : public framework::OpProtoAndCheckerMaker {
7777
AddOutput("Out", "The output of bilinear_tensor_product operator.");
7878
AddComment(R"DOC(
7979
Bilinear Tensor Product operator.
80-
Given input X and Y, a 3D tensor weight, and bias. Each column of the
81-
output is computed by one slice i = 1, . . . , k of the tensor:
82-
83-
M = (X W_i) \cdot Y
84-
Out_i = \sum_i {M_i} + Bias_i
80+
Given input X and Y, a 3D tensor Weight and a Bias. Each column of the
81+
Output is computed by one slice $i = 1, . . . , k$ of the tensor:
82+
83+
$$
84+
M = (X W_i) * Y \\
85+
Out_i = \sum_j {M_j} + Bias_i
86+
$$
87+
88+
Where $W_i$ is the $i$-th slice of Input(Weight);
89+
$M_j$ is the $j$-th column of $M$;
90+
$Out_i$ is the $i$-th column of Output(Out);
91+
$Bias_i$ is a column vector, each element of it is equal to
92+
the $i$-th element of $Bias$;
8593
8694
)DOC");
8795
}

paddle/operators/cast_op.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class CastOpProtoMaker : public framework::OpProtoAndCheckerMaker {
2525
: OpProtoAndCheckerMaker(proto, op_checker) {
2626
AddInput("X", "The input tensor of cast op");
2727
AddOutput("Out", "The output tensor of cast op");
28-
AddAttr<int>("out_data_type", "output data type");
29-
AddAttr<int>("in_data_type", "input data type");
28+
AddAttr<int>("out_dtype", "output data type");
29+
AddAttr<int>("in_dtype", "input data type");
3030
AddComment(R"DOC(
3131
Cast Operator.
3232
@@ -58,8 +58,8 @@ class CastOpGradMaker : public framework::SingleGradOpDescMaker {
5858
grad->SetType("cast");
5959
grad->SetInput("X", OutputGrad("Out"));
6060
grad->SetOutput("Out", InputGrad("X"));
61-
grad->SetAttr("out_data_type", GetAttr("in_data_type"));
62-
grad->SetAttr("in_data_type", GetAttr("out_data_type"));
61+
grad->SetAttr("out_dtype", GetAttr("in_dtype"));
62+
grad->SetAttr("in_dtype", GetAttr("out_dtype"));
6363
return std::unique_ptr<framework::OpDescBind>(grad);
6464
}
6565
};

paddle/operators/cast_op.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class CastOpKernel : public framework::OpKernel<InT> {
5555
auto* in = context.Input<framework::Tensor>("X");
5656
auto* out = context.Output<framework::Tensor>("Out");
5757
framework::VisitDataType(
58-
static_cast<framework::DataType>(context.Attr<int>("out_data_type")),
58+
static_cast<framework::DataType>(context.Attr<int>("out_dtype")),
5959
CastOpFunctor<Place, InT>(in, out, context.device_context()));
6060
}
6161
};

paddle/operators/fill_constant_batch_size_like_op.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class FillConstantBatchSizeLikeOp : public framework::OperatorWithKernel {
5252
framework::OpKernelType GetKernelType(
5353
const framework::ExecutionContext &ctx) const override {
5454
return framework::OpKernelType(
55-
static_cast<framework::DataType>(ctx.Attr<int>("data_type")),
55+
static_cast<framework::DataType>(ctx.Attr<int>("dtype")),
5656
ctx.device_context());
5757
}
5858
};
@@ -63,7 +63,7 @@ class FillConstantBatchSizeLikeOpMaker
6363
FillConstantBatchSizeLikeOpMaker(framework::OpProto *proto,
6464
framework::OpAttrChecker *op_checker)
6565
: framework::OpProtoAndCheckerMaker(proto, op_checker) {
66-
AddAttr<int>("data_type",
66+
AddAttr<int>("dtype",
6767
"(int, default 5 (FP32)) "
6868
"Output data type")
6969
.SetDefault(framework::DataType::FP32);

paddle/operators/fill_constant_op.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class FillConstantOp : public framework::OperatorBase {
3434
using framework::OperatorBase::OperatorBase;
3535
void Run(const framework::Scope &scope,
3636
const platform::DeviceContext &dev_ctx) const override {
37-
auto data_type = static_cast<framework::DataType>(Attr<int>("data_type"));
37+
auto data_type = static_cast<framework::DataType>(Attr<int>("dtype"));
3838
auto value = Attr<float>("value");
3939
auto force_cpu = Attr<bool>("force_cpu");
4040
auto &out =
@@ -55,7 +55,7 @@ class FillConstantOpMaker : public framework::OpProtoAndCheckerMaker {
5555
FillConstantOpMaker(framework::OpProto *proto,
5656
framework::OpAttrChecker *op_checker)
5757
: framework::OpProtoAndCheckerMaker(proto, op_checker) {
58-
AddAttr<int>("data_type",
58+
AddAttr<int>("dtype",
5959
"(int, default 5 (FP32)) "
6060
"Output data type")
6161
.SetDefault(framework::DataType::FP32);

paddle/operators/gaussian_random_op.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class GaussianRandomOp : public framework::OperatorWithKernel {
6060
framework::OpKernelType GetKernelType(
6161
const framework::ExecutionContext& ctx) const override {
6262
return framework::OpKernelType(
63-
static_cast<framework::DataType>(ctx.Attr<int>("data_type")),
63+
static_cast<framework::DataType>(ctx.Attr<int>("dtype")),
6464
ctx.device_context());
6565
}
6666
};
@@ -88,7 +88,7 @@ class GaussianRandomOpMaker : public framework::OpProtoAndCheckerMaker {
8888
"Random seed of generator."
8989
"0 means use system wide seed.")
9090
.SetDefault(0);
91-
AddAttr<int>("data_type",
91+
AddAttr<int>("dtype",
9292
"(int, default 5(FP32)) "
9393
"Output data type.")
9494
.SetDefault(framework::DataType::FP32);

paddle/operators/huber_loss_op.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,18 @@ input value and Y as the target value. Huber loss can evaluate the fitness of
7070
X to Y. Different from MSE loss, Huber loss is more robust for outliers. The
7171
shape of X and Y are [batch_size, 1]. The equation is:
7272
73-
L_{\delta}(y, f(x)) =
73+
$$
74+
Out_{\delta}(X, Y)_i =
7475
\begin{cases}
75-
0.5 * (y - f(x))^2, \quad |y - f(x)| \leq \delta \\
76-
\delta * (|y - f(x)| - 0.5 * \delta), \quad otherwise
76+
0.5 * (Y_i - X_i)^2,
77+
\quad |Y_i - X_i| \leq \delta \\
78+
\delta * (|Y_i - X_i| - 0.5 * \delta),
79+
\quad otherwise
7780
\end{cases}
81+
$$
82+
83+
In the above equation, $Out_\delta(X, Y)_i$, $X_i$ and $Y_i$ represent the ith
84+
element of Out, X and Y.
7885
7986
)DOC");
8087
}

0 commit comments

Comments
 (0)