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

Function FindInputFeatures

tensorflow/core/grappler/costs/utils.cc:163–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163std::vector<OpInfo::TensorProperties> FindInputFeatures(
164 const NodeDef& node,
165 const std::unordered_map<string, const CostGraphDef::Node*>& name_to_cost,
166 const std::unordered_map<string, const NodeDef*>& name_to_node) {
167 std::vector<OpInfo::TensorProperties> inputs;
168 for (const auto& input_name : node.input()) {
169 CHECK(!input_name.empty());
170 TensorId input_tensor_id = ParseTensorName(input_name);
171 const string input_node_name(input_tensor_id.first);
172 const int output_index = input_tensor_id.second;
173
174 // Skip control inputs.
175 if (output_index == Graph::kControlSlot) {
176 continue;
177 }
178
179 auto it = name_to_cost.find(input_node_name);
180 if (it == name_to_cost.end() || output_index < 0) {
181 inputs.push_back(UnknownInput());
182 } else {
183 const CostGraphDef::Node* input_cost = it->second;
184 if (input_cost->output_info_size() == 0) {
185 inputs.push_back(UnknownInput());
186 } else {
187 const CostGraphDef::Node::OutputInfo& output =
188 input_cost->output_info(output_index);
189 OpInfo::TensorProperties input;
190 input.set_dtype(output.dtype());
191 *input.mutable_shape() = output.shape();
192 inputs.push_back(input);
193 }
194 }
195 }
196
197 return inputs;
198}
199
200int64 CalculateTensorSize(const OpInfo::TensorProperties& prop) {
201 int64 size = DataTypeSize(BaseType(prop.dtype()));

Callers 2

InferFromCostGraphMethod · 0.85

Calls 11

ParseTensorNameFunction · 0.85
UnknownInputFunction · 0.85
inputMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
set_dtypeMethod · 0.45
dtypeMethod · 0.45
mutable_shapeMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected