forked from apache/mxnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_loss.cc
39 lines (34 loc) · 1.19 KB
/
make_loss.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*!
* Copyright (c) 2015 by Contributors
* \file make_loss.cc
* \brief special layer for propagating loss
*/
#include "./make_loss-inl.h"
namespace mxnet {
namespace op {
template<>
Operator *CreateOp<cpu>(MakeLossParam param, int dtype) {
Operator *op = NULL;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new MakeLossOp<cpu, DType>(param);
});
return op;
}
Operator *MakeLossProp::CreateOperatorEx(Context ctx, std::vector<TShape> *in_shape,
std::vector<int> *in_type) const {
std::vector<TShape> out_shape, aux_shape;
std::vector<int> out_type, aux_type;
CHECK(InferType(in_type, &out_type, &aux_type));
CHECK(InferShape(in_shape, &out_shape, &aux_shape));
DO_BIND_DISPATCH(CreateOp, param_, in_type->at(0));
}
DMLC_REGISTER_PARAMETER(MakeLossParam);
MXNET_REGISTER_OP_PROPERTY(MakeLoss, MakeLossProp)
.describe("Get output from a symbol and pass 1 gradient back. "
"This is used as a terminal loss if unary and binary operator "
"are used to composite a loss with no declaration of backward "
"dependency")
.add_argument("data", "Symbol", "Input data.")
.add_arguments(MakeLossParam::__FIELDS__());
} // namespace op
} // namespace mxnet