| 161 | } |
| 162 | |
| 163 | std::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 | |
| 200 | int64 CalculateTensorSize(const OpInfo::TensorProperties& prop) { |
| 201 | int64 size = DataTypeSize(BaseType(prop.dtype())); |
no test coverage detected