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, &context_);
22  }
23  return true;
24  }
25 };
26 
27 } // namespace caffe2
Copyright (c) 2016-present, Facebook, Inc.