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

Function ValidateEinsumEllipsis

tensorflow/core/framework/common_shape_fns.cc:279–293  ·  view source on GitHub ↗

Validate that an Einsum subscript contains exactly one or zero ellipsis; and that periods (.) occur only within an ellipses (...).

Source from the content-addressed store, hash-verified

277// Validate that an Einsum subscript contains exactly one or zero ellipsis; and
278// that periods (.) occur only within an ellipses (...).
279Status ValidateEinsumEllipsis(absl::string_view subscript,
280 bool* found_ellipsis) {
281 const int num_periods = absl::c_count(subscript, '.');
282 if (num_periods != 0 && num_periods != 3) {
283 return errors::InvalidArgument(
284 "Expected at most one ellipsis (...), but found ", num_periods,
285 " periods (.) in the input subscript: ", subscript);
286 }
287 if (num_periods == 3 && !absl::StrContains(subscript, "...")) {
288 return errors::InvalidArgument(
289 "Periods found outside of ellipsis in subscript: ", subscript);
290 }
291 *found_ellipsis = num_periods > 0;
292 return Status::OK();
293}
294
295} // namespace
296

Callers 1

EinsumShapeFunction · 0.85

Calls 2

InvalidArgumentFunction · 0.85
StrContainsFunction · 0.50

Tested by

no test coverage detected