| 1164 | } |
| 1165 | |
| 1166 | Status InferenceContext::AttachContext(const Status& status) { |
| 1167 | std::vector<string> input_shapes; |
| 1168 | input_shapes.reserve(inputs_.size()); |
| 1169 | for (const ShapeHandle& input_shape : inputs_) { |
| 1170 | input_shapes.emplace_back(DebugString(input_shape)); |
| 1171 | } |
| 1172 | |
| 1173 | // Add information about the input tensors and partial tensor shapes used. |
| 1174 | std::vector<string> input_from_tensors_str; |
| 1175 | std::vector<string> input_from_tensors_as_shape_str; |
| 1176 | input_from_tensors_as_shape_str.reserve(inputs_.size()); |
| 1177 | for (int i = 0; i < inputs_.size(); ++i) { |
| 1178 | if (requested_input_tensor_as_partial_shape_[i] && |
| 1179 | i < input_tensors_as_shapes_.size() && |
| 1180 | input_tensors_as_shapes_[i].IsSet() && |
| 1181 | RankKnown(input_tensors_as_shapes_[i])) { |
| 1182 | input_from_tensors_as_shape_str.push_back(strings::StrCat( |
| 1183 | "input[", i, "] = ", DebugString(input_tensors_as_shapes_[i]))); |
| 1184 | } else if (requested_input_tensor_[i] && i < input_tensors_.size() && |
| 1185 | input_tensors_[i] != nullptr) { |
| 1186 | input_from_tensors_str.push_back(strings::StrCat( |
| 1187 | "input[", i, "] = <", |
| 1188 | input_tensors_[i]->SummarizeValue(256 /* max_values */), ">")); |
| 1189 | } |
| 1190 | } |
| 1191 | |
| 1192 | string error_context = strings::StrCat( |
| 1193 | " for '", node_def_->name(), "' (op: '", node_def_->op(), |
| 1194 | "') with input shapes: ", absl::StrJoin(input_shapes, ", ")); |
| 1195 | if (!input_from_tensors_str.empty()) { |
| 1196 | strings::StrAppend(&error_context, " and with computed input tensors: ", |
| 1197 | absl::StrJoin(input_from_tensors_str, ", ")); |
| 1198 | } |
| 1199 | if (!input_from_tensors_as_shape_str.empty()) { |
| 1200 | strings::StrAppend(&error_context, |
| 1201 | " and with input tensors computed as partial shapes: ", |
| 1202 | absl::StrJoin(input_from_tensors_as_shape_str, ",")); |
| 1203 | } |
| 1204 | |
| 1205 | strings::StrAppend(&error_context, "."); |
| 1206 | return Status(status.code(), |
| 1207 | strings::StrCat(status.error_message(), error_context)); |
| 1208 | } |
| 1209 | |
| 1210 | bool InferenceContext::MergeHandleShapesAndTypes( |
| 1211 | const std::vector<ShapeAndType>& shapes_and_types, |
nothing calls this directly
no test coverage detected