载入中...
搜索中...
未找到
Optimizer.h
浏览该文件的文档.
1#ifndef EVE_TENSOR_OPTIMIZER_H
2#define EVE_TENSOR_OPTIMIZER_H
3
4#include "tensor/Graph.h"
5
6#include <vector>
7
8namespace eve::tensor {
9
21enum class GroupKind : uint8_t {
23 MatMul,
24 Conv1d,
25 Conv2d,
28 Softmax,
30 RMSNorm,
31 Reduce,
32 ArgMax,
34 Concat,
35 Slice,
36 Permute,
37 Sdpa,
39 Alias,
40};
41
42struct FusedGroup {
47 std::vector<int> nodes;
49 std::vector<int> inputs;
50 int outputNode = -1;
51
52 // attributes copied from the root node for convenience
53 float s0 = 0.f, s1 = 0.f, s2 = 0.f, s3 = 0.f;
54 int i0 = 0, i1 = 0, i2 = 0, i3 = 0;
55 int perm[Tensor::kMaxRank] = {0, 1, 2, 3, 4, 5};
56 int permRank = 0;
57 int dtype = static_cast<int>(DType::Float32);
58
59 // MatMul / Conv epilogue: bias node id (or -1) + elementwise chain node ids
60 int biasNode = -1;
61 std::vector<int> epilogue;
62 bool hasScale = false;
63 bool hasBias = false;
64 bool masked = false;
65 bool logMode = false;
66};
67
74 std::vector<int> order;
76 std::vector<FusedGroup> groups;
78 std::vector<int> groupOrder;
80 std::vector<int> nodeSlot;
82 std::vector<int> slotSize;
84 std::vector<int> persistentSlots;
85 int outputNode = -1;
86};
87
96OptimizedGraph optimizeGraph(const Graph &graph, int outputNode);
97
99int groupKernelCount(const OptimizedGraph &opt);
100
101} // namespace eve::tensor
102
103#endif // EVE_TENSOR_OPTIMIZER_H
const Graph & graph
static constexpr int kMaxRank
Definition Tensor.h:45
int groupKernelCount(const OptimizedGraph &opt)
OptimizedGraph optimizeGraph(const Graph &graph, int outputNode)
std::vector< int > epilogue
Definition Optimizer.h:61
int perm[Tensor::kMaxRank]
Definition Optimizer.h:55
std::vector< int > nodes
Definition Optimizer.h:47
std::vector< int > inputs
Definition Optimizer.h:49
std::vector< int > order
Definition Optimizer.h:74
std::vector< int > slotSize
Definition Optimizer.h:82
std::vector< int > persistentSlots
Definition Optimizer.h:84
std::vector< int > nodeSlot
Definition Optimizer.h:80
std::vector< int > groupOrder
Definition Optimizer.h:78
std::vector< FusedGroup > groups
Definition Optimizer.h:76