MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / NodeItemBytes

Method NodeItemBytes

tensorflow/core/common_runtime/graph_view.cc:83–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81} // namespace
82
83size_t GraphView::NodeItemBytes(const Node* n) {
84 int32_t num_output_edges;
85 int32_t num_output_control_edges;
86 std::tie(num_output_edges, num_output_control_edges) = CountOutputEdges(n);
87 const int num_inputs = n->num_inputs();
88 const int num_outputs = n->num_outputs();
89
90 // Compute number of bytes needed for NodeItem and variable length data.
91 // We do not subtract sizeof(var) since num_inputs/num_outputs might
92 // both be zero.
93 const size_t raw_bytes =
94 sizeof(NodeItem) // Fixed
95 + num_output_edges * sizeof(EdgeInfo) // output_edges[...]
96 + num_output_control_edges * //
97 sizeof(ControlEdgeInfo) // output_control_edges[...]
98 + num_outputs * sizeof(AllocatorAttributes) // output_attr[...]
99 + num_outputs * sizeof(int) // forward_from[num_outputs]
100 + num_inputs * sizeof(uint8) // input_type[num_inputs]
101 + num_outputs * sizeof(uint8); // output_type[num_outputs]
102 static constexpr size_t kItemAlignment = sizeof(NodeItem*);
103 static_assert(kItemAlignment % alignof(NodeItem) == 0,
104 "NodeItem must be aligned with kItemAlignment");
105 static_assert(kItemAlignment % alignof(EdgeInfo) == 0,
106 "EdgeInfo must be aligned with kItemAlignment");
107 static_assert(kItemAlignment % alignof(ControlEdgeInfo) == 0,
108 "ControlEdgeInfo must be aligned with kItemAlignment");
109 static_assert(kItemAlignment % alignof(AllocatorAttributes) == 0,
110 "AllocatorAttributes must be aligned with kItemAlignment");
111 static_assert(sizeof(NodeItem) % alignof(EdgeInfo) == 0,
112 "NodeItem must be aligned with EdgeInfo");
113 static_assert(sizeof(NodeItem) % alignof(AllocatorAttributes) == 0,
114 "NodeItem must be aligned with AllocatorAttributes");
115 static_assert(sizeof(EdgeInfo) % alignof(AllocatorAttributes) == 0,
116 "EdgeInfo must be aligned with AllocatorAttributes");
117 const size_t bytes =
118 ((raw_bytes + kItemAlignment - 1) / kItemAlignment) * kItemAlignment;
119 return bytes;
120}
121
122char* GraphView::InitializeNode(char* ptr, const Node* n) {
123 const int id = n->id();

Callers

nothing calls this directly

Calls 3

CountOutputEdgesFunction · 0.85
num_inputsMethod · 0.45
num_outputsMethod · 0.45

Tested by

no test coverage detected