reid from https://github.com/michuanhaohao/reid-strong-baseline
zhangmeng
2020-01-10 c3765bd24fe73747688a0ec2a550f219c9acb384
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
40
41
42
43
44
#pragma once
 
#include <torch/csrc/autograd/function.h>
#include <torch/csrc/autograd/variable.h>
#include <torch/csrc/WindowsTorchApiMacro.h>
 
#include <ATen/TensorGeometry.h>
#include <ATen/core/DeprecatedTypeProperties.h>
#include <c10/util/Optional.h>
 
#include <cstdint>
#include <memory>
 
namespace torch { namespace autograd {
 
struct TORCH_API CopyBackwards : public Node {
  variable_list apply(variable_list&& grads) override;
 
  at::TensorOptions src_options;
  at::Device src_device = at::kCPU;
};
 
// Performs grad[idx] = fn(grad[idx]), but out-of-place. The slicing operation
// grad[idx] is defined by the relative sizes, strides, and offset of base and
// view.
// When an in-place operation is done on a differentiable view, the base's
// grad_fn is updated to become a `CopySlice` wrapping the backward of the
// in-place operation.
// See NOTE [ Autograd View Variables ].
struct TORCH_API CopySlices : public Node {
  CopySlices(
      const Variable& base_var,
      at::TensorGeometry view_,
      std::shared_ptr<Node> fn_);
 
  variable_list apply(variable_list&& inputs) override;
  void release_variables() override;
 
  at::TensorGeometry base;
  at::TensorGeometry view;
  std::shared_ptr<Node> fn;
};
 
}}