Caffe2 - C++ API
A deep learning, cross platform ML framework
stop_gradient.h
1 #ifndef CAFFE2_OPERATORS_STOP_GRADIENT_H_
2 #define CAFFE2_OPERATORS_STOP_GRADIENT_H_
3 
4 #include "caffe2/core/operator.h"
5 
6 namespace caffe2 {
7 
8 template <class Context>
9 class StopGradientOp : public Operator<Context> {
10  public:
11  USE_SIMPLE_CTOR_DTOR(StopGradientOp)
12  USE_OPERATOR_CONTEXT_FUNCTIONS;
13  bool RunOnDevice() override {
14  const auto& in = Input(0);
15  auto* out = Output(0);
16  if (out != &in) {
17  out->CopyFrom(in, true /*async*/);
18  }
19  return true;
20  }
21 };
22 
23 } // namespace caffe2
24 
25 #endif // CAFFE2_OPERATORS_STOP_GRADIENT_H_
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