reid from https://github.com/michuanhaohao/reid-strong-baseline
zhangmeng
2020-01-17 f7c4a3cfd07adede3308f8d9d3d7315427d90a7c
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once
 
#include <c10/core/impl/DeviceGuardImplInterface.h>
#include <c10/macros/Macros.h>
 
namespace at {
namespace detail {
 
struct CPUGuardImpl final : public c10::impl::DeviceGuardImplInterface {
  CPUGuardImpl() {}
  DeviceType type() const override {
    return DeviceType::CPU;
  }
  Device exchangeDevice(Device) const override {
    // no-op
    return Device(DeviceType::CPU, -1);
 
  }
  Device getDevice() const override {
    return Device(DeviceType::CPU, -1);
  }
  void setDevice(Device) const override {
    // no-op
  }
  void uncheckedSetDevice(Device d) const noexcept override {
    // no-op
  }
  Stream getStream(Device d) const noexcept override {
    // no-op
    return Stream(Stream::DEFAULT, Device(DeviceType::CPU, -1));
  }
  // NB: These do NOT set the current device
  Stream exchangeStream(Stream s) const noexcept override {
    // no-op
    return Stream(Stream::DEFAULT, Device(DeviceType::CPU, -1));
  }
  DeviceIndex deviceCount() const noexcept override {
    return 1;
  }
 
  // Event-related functions
  void record(void** event,
    const Stream& stream,
    const DeviceIndex device_index,
    const EventFlag flag) const override {
    TORCH_CHECK(false, "CPU backend doesn't support events.");
  }
  void block(
    void* event,
    const Stream& stream) const override {
    TORCH_CHECK(false, "CPU backend doesn't support events.")
  }
  bool queryEvent(void* event) const override {
    TORCH_CHECK(false, "CPU backend doesn't support events.")
  }
  void destroyEvent(
    void* event,
    const DeviceIndex device_index) const noexcept override { }
};
 
}} // namespace at::detail