FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
taskflow/sandbox/tensorframe/tensor_graph.hpp at task_isolation · ModuleWorks/taskflow · GitHub
ModuleWorks
/
taskflow
Public
forked from
taskflow/taskflow
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
taskflow
/
sandbox
/
tensorframe
/
tensor_graph.hpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
115 lines (82 loc) · 2.62 KB
Breadcrumbs
taskflow
/
sandbox
/
tensorframe
/
tensor_graph.hpp
Copy path
File metadata and controls
115 lines (82 loc) · 2.62 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
94
95
96
97
98
99
100
101
102
103
104
105
106
#
pragma
once
#
include
"
tensor.hpp
"
namespace
tf
{
template
<
typename
T>
class
TensorNode
{
template
<
typename
U>
friend
class
TensorExpr
;
template
<
typename
U>
friend
class
TensorFrame
;
//
using tensor_t = std::variant<
//
std::monostate, // not yet assigned - placeholder
//
std::shared_ptr<Tensor<int>>,
//
std::shared_ptr<Tensor<float>>
//
>;
struct
Input
{
std::shared_ptr<Tensor<T>> tensor;
Input
(Tensor<T>&);
};
struct
Output
{
std::shared_ptr<Tensor<T>> tensor;
Output
(Tensor<T>&);
};
struct
Add
{
std::shared_ptr<Tensor<T>> tensor;
TensorNode* lhs {
nullptr
};
TensorNode* rhs {
nullptr
};
Add
(TensorNode*, TensorNode*);
};
using
handle_t
= std::variant<
Input,
Output,
Add
>;
public:
template
<
typename
... Args>
TensorNode
(Args&&... args);
private:
std::string _name;
handle_t
_handle;
std::vector<TensorNode*> _successors;
std::vector<TensorNode*> _dependents;
void
_precede
(TensorNode*);
};
//
----------------------------------------------------------------------------
//
TensorNode::Input
//
----------------------------------------------------------------------------
template
<
typename
T>
TensorNode<T>::Input::Input(Tensor<T>& in) :
tensor { std::shared_ptr<Tensor<T>>(&in, [](Tensor<T>*){}) } {
//
std::cout << "input " << in.index() << '\n';
}
//
----------------------------------------------------------------------------
//
TensorNode::Output
//
----------------------------------------------------------------------------
template
<
typename
T>
TensorNode<T>::Output::Output(Tensor<T>& out) :
tensor { std::shared_ptr<Tensor<T>>(&out, [](Tensor<T>*){}) } {
//
std::cout << "output " << out.index() << '\n';
}
//
----------------------------------------------------------------------------
//
TensorNode::Add
//
----------------------------------------------------------------------------
template
<
typename
T>
TensorNode<T>::Add::Add(TensorNode* l, TensorNode* r) :
lhs {l}, rhs {r} {
std::cout <<
"
add:
"
<< l <<
'
'
<< r <<
'
\n
'
;
}
//
----------------------------------------------------------------------------
//
TensorNode member definition
//
----------------------------------------------------------------------------
//
Constructor
template
<
typename
T>
template
<
typename
... Args>
TensorNode<T>::TensorNode(Args&&... args) : _handle{std::forward<Args>(args)...} {
}
//
Procedure: _precede
template
<
typename
T>
void
TensorNode<T>::_precede(TensorNode* v) {
_successors.
push_back
(v);
v->
_dependents
.
push_back
(
this
);
}
}
//
end of namespace tf -----------------------------------------------------
Back
|
FazBrowse Home
|
New Git URL