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

Function GetValueIteratorForComposite

tensorflow/python/util/util.cc:563–589  ·  view source on GitHub ↗

Similar to GetValueIterator above, but expands CompositeTensor and TypeSpec.

Source from the content-addressed store, hash-verified

561
562// Similar to GetValueIterator above, but expands CompositeTensor and TypeSpec.
563ValueIteratorPtr GetValueIteratorForComposite(PyObject* nested) {
564 if (IsCompositeTensor(nested)) {
565 Safe_PyObjectPtr spec(PyObject_GetAttrString(nested, "_type_spec"));
566 if (PyErr_Occurred() || !spec) {
567 return absl::make_unique<ErrorValueIterator>();
568 }
569
570 static char to_components[] = "_to_components";
571 static char argspec[] = "(O)";
572 Safe_PyObjectPtr components(
573 PyObject_CallMethod(spec.get(), to_components, argspec, nested));
574 if (PyErr_Occurred() || components == nullptr) {
575 return absl::make_unique<ErrorValueIterator>();
576 }
577 return absl::make_unique<SingleValueIterator>(components.get());
578 }
579
580 if (IsTypeSpec(nested)) {
581 Safe_PyObjectPtr specs(PyObject_GetAttrString(nested, "_component_specs"));
582 if (PyErr_Occurred() || specs == nullptr) {
583 return absl::make_unique<ErrorValueIterator>();
584 }
585 return absl::make_unique<SingleValueIterator>(specs.get());
586 }
587
588 return GetValueIterator(nested);
589}
590
591bool FlattenHelper(
592 PyObject* nested, PyObject* list,

Callers

nothing calls this directly

Calls 4

IsCompositeTensorFunction · 0.85
IsTypeSpecFunction · 0.85
GetValueIteratorFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected