-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSOFIE_common.hxx
More file actions
93 lines (72 loc) · 2.65 KB
/
SOFIE_common.hxx
File metadata and controls
93 lines (72 loc) · 2.65 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef TMVA_SOFIE_SOFIE_COMMON
#define TMVA_SOFIE_SOFIE_COMMON
//#include "RTensor.hxx"
#include <type_traits>
#include <cstdint>
#include <string>
#include <vector>
#include <memory>
#include <regex>
namespace TMVA{
namespace Experimental{
namespace SOFIE{
const bool fUseEigen = false;
//typedef RTensor tensor_t;
enum class ETensorType{
UNDEFINED = 0, FLOAT = 1, UNINT8 = 2, INT8 = 3, UINT16 = 4, INT16 = 5, INT32 = 6, INT64 = 7, STRING = 8, BOOL = 9, //order sensitive
FLOAT16 = 10, DOUBLE = 11, UINT32 = 12, UINT64 = 13, COMPLEX64 = 14, COMPLEX28 = 15, BFLOAT16 = 16
};
typedef std::int64_t int_t;
std::string ConvertTypeToString(ETensorType type);
struct Dim{
bool isParam = false;
size_t dim;
std::string param;
};
std::vector<Dim> ConvertShapeToDim(std::vector<size_t> shape);
struct InputTensorInfo{
ETensorType type;
std::vector<Dim> shape;
};
struct TensorInfo{
ETensorType type;
std::vector<size_t> shape;
};
std::size_t ConvertShapeToLength(std::vector<size_t> shape);
struct InitializedTensor{
ETensorType type;
std::vector<std::size_t> shape;
std::shared_ptr<void> data;
//void* data;
};
template <typename T>
ETensorType GetTemplatedType(T obj){
if (std::is_same<T, float>::value) return ETensorType::FLOAT;
if (std::is_same<T, uint8_t>::value) return ETensorType::UNINT8;
if (std::is_same<T, int8_t>::value) return ETensorType::INT8;
if (std::is_same<T, uint16_t>::value) return ETensorType::UINT16;
if (std::is_same<T, int16_t>::value) return ETensorType::INT16;
if (std::is_same<T, int32_t>::value) return ETensorType::INT32;
if (std::is_same<T, int64_t>::value) return ETensorType::INT64;
if (std::is_same<T, std::string>::value) return ETensorType::STRING;
if (std::is_same<T, bool>::value) return ETensorType::BOOL;
//float16 unimplemented
if (std::is_same<T, double>::value) return ETensorType::DOUBLE;
if (std::is_same<T, uint32_t>::value) return ETensorType::UINT32;
if (std::is_same<T, uint64_t>::value) return ETensorType::UINT64;
//complex 64, 28, bfloat 16 unimplemented
}
namespace UTILITY{
template<typename T>
T* Unidirectional_broadcast(const T* original_data, const std::vector<size_t> original_shape, const std::vector<size_t> target_shape);
std::string Clean_name(std::string input_tensor_name);
}
namespace BLAS{
extern "C" void sgemm_(const char * transa, const char * transb, const int * m, const int * n, const int * k,
const float * alpha, const float * A, const int * lda, const float * B, const int * ldb,
const float * beta, float * C, const int * ldc);
}//BLAS
}//SOFIE
}//Experimental
}//TMVA
#endif //TMVA_SOFIE_RMODEL