Caffe2 - C++ API
A deep learning, cross platform ML framework
Related Pages
Modules
Data Structures
Files
C++ API
Python API
GitHub
File List
Globals
caffe2
operators
negative_op.cc
1
#include "caffe2/operators/elementwise_op.h"
2
3
namespace
caffe2
{
4
5
struct
NegativeCPUFunctor
{
6
template
<
typename
T>
7
inline
void
8
operator()(
const
int
n,
const
T* x, T* y,
CPUContext
*
/*device_context*/
) {
9
EigenVectorMap<T>(y, n) = -ConstEigenVectorMap<T>(x, n);
10
// for (int i = 0; i < n; ++i) {
11
// y[i] = -x[i];
12
//}
13
}
14
};
15
16
REGISTER_CPU_OPERATOR(
17
Negative,
UnaryElementwiseOp
<
18
TensorTypes<float, double, int, long>
,
CPUContext
,
NegativeCPUFunctor
>);
19
20
// Input: X, output: Y
21
OPERATOR_SCHEMA(Negative)
22
.NumInputs(1)
23
.NumOutputs(1)
24
.AllowInplace({{0, 0}})
25
.IdenticalTypeAndShape()
26
.SetDoc(R
"DOC(
27
Computes the element-wise negative of the input.
28
)DOC")
29
.Input(0,
"X"
,
"1D input tensor"
)
30
.Output(0,
"Y"
,
"1D input tensor"
)
31
.InheritOnnxSchema(
"Neg"
);
32
33
class
GetNegativeGradient
:
public
GradientMakerBase
{
34
using
GradientMakerBase::GradientMakerBase;
35
vector<OperatorDef> GetGradientDefs()
override
{
36
return
SingleGradientDef(
37
"Negative"
,
""
,
38
vector<string>{GO(0)},
39
vector<string>{GI(0)});
40
}
41
};
42
REGISTER_GRADIENT(Negative,
GetNegativeGradient
);
43
}
// namespace caffe2
caffe2::GradientMakerBase
Definition:
operator_gradient.h:47
caffe2::CPUContext
The CPU Context, representing the bare minimum of what a Context class in Caffe2 should implement...
Definition:
context.h:66
caffe2::GetNegativeGradient
Definition:
negative_op.cc:33
caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition:
convert_encoded_to_raw_leveldb.cc:47
caffe2::TensorTypes
Definition:
operator.h:547
caffe2::UnaryElementwiseWithArgsOp
Definition:
elementwise_op.h:36
caffe2::NegativeCPUFunctor
Definition:
negative_op.cc:5
Generated on Thu Apr 19 2018 13:03:55 for Caffe2 - C++ API by
1.8.11