Caffe2 - C++ API
A deep learning, cross platform ML framework
negate_gradient_op.h
1 // Copyright 2004-present Facebook. All Rights Reserved.
2 
3 // File: negate_gradient_op.h
4 
5 #pragma once
6 #include "caffe2/core/context.h"
7 #include "caffe2/core/operator.h"
8 
9 namespace caffe2 {
10 
11 template <class Context>
12 class NegateGradientOp final : public Operator<Context> {
13  public:
14  USE_SIMPLE_CTOR_DTOR(NegateGradientOp)
15  USE_OPERATOR_CONTEXT_FUNCTIONS;
16 
17  bool RunOnDevice() override {
18  const auto& in = Input(0);
19  auto* out = Output(0);
20  if (out != &in) {
21  out->CopyFrom(in, /* async */ true);
22  }
23  return true;
24  }
25 };
26 
27 } // namespace caffe2
const Tensor & Input(int idx, DeviceType type=Context::GetDeviceType())
Retrieve a non-owning reference to the input at position &#39;idx&#39; for this operator. ...
Definition: operator.h:702
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13