-
Notifications
You must be signed in to change notification settings - Fork 23
/
dtype.h
56 lines (42 loc) · 1.06 KB
/
dtype.h
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
#pragma once
#include <iosfwd>
#include <chainerx/dtype.h>
#include <compiler/onnx.h>
namespace chainer_compiler {
class Dtype {
public:
// These values must be synchronized with ChainerX's.
enum DataType {
kUnknown = 0,
kBool = 1,
kInt8,
kInt16,
kInt32,
kInt64,
kUInt8,
kFloat16,
kFloat32,
kFloat64,
kString,
};
Dtype() = default;
// Accepts `TensorProto::DataType` type.
explicit Dtype(int xtype);
// Note this is an implicit constructor.
Dtype(DataType type);
explicit Dtype(chainerx::Dtype type);
operator DataType() const {
return type_;
}
chainerx::Dtype chx() const;
onnx::TensorProto::DataType ToONNX() const;
std::string ToString() const;
int SizeOf() const;
bool IsFloat() const {
return type_ == kFloat16 || type_ == kFloat32 || type_ == kFloat64;
}
private:
DataType type_ = kUnknown;
};
std::ostream& operator<<(std::ostream& os, const Dtype& dtype);
} // namespace chainer_compiler