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
#pragma once
#include <ATen/core/EnableNamedTensor.h>
 
#ifdef BUILD_NAMEDTENSOR
#include <ATen/core/interned_strings.h>
#include <c10/util/ArrayRef.h>
#include <c10/util/Optional.h>
#include <ostream>
 
namespace at {
 
enum class NameType: uint8_t { BASIC, WILDCARD };
 
struct CAFFE2_API Dimname {
  static Dimname fromSymbol(Symbol name);
  static Dimname wildcard();
  static bool isValidName(const std::string& name);
 
  NameType type() const { return type_; }
  Symbol symbol() const { return name_; }
 
  bool isBasic() const { return type_ == NameType::BASIC; }
  bool isWildcard() const { return type_ == NameType::WILDCARD; }
 
  bool matches(Dimname other) const;
  optional<Dimname> unify(Dimname other) const;
 
 private:
  Dimname(Symbol name)
    : name_(name), type_(NameType::BASIC) {}
  Dimname(Symbol name, NameType type)
    : name_(name), type_(type) {}
 
  Symbol name_;
  NameType type_;
};
 
using DimnameList = c10::ArrayRef<Dimname>;
 
static Symbol kWildcard = Symbol::dimname("*");
 
CAFFE2_API std::ostream& operator<<(std::ostream& out, const Dimname& dimname);
 
inline bool operator==(const Dimname& lhs, const Dimname& rhs) {
  return lhs.symbol() == rhs.symbol();
}
 
inline bool operator!=(const Dimname& lhs, const Dimname& rhs) {
  return !(lhs == rhs);
}
 
} // namespace at
#endif