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

Function Flatten

tensorflow/python/util/util.cc:875–887  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

873}
874
875PyObject* Flatten(PyObject* nested, bool expand_composites) {
876 PyObject* list = PyList_New(0);
877 const std::function<int(PyObject*)>& is_sequence_helper =
878 expand_composites ? IsSequenceOrCompositeHelper : IsSequenceHelper;
879 const std::function<ValueIteratorPtr(PyObject*)>& get_value_iterator =
880 expand_composites ? GetValueIteratorForComposite : GetValueIterator;
881 if (FlattenHelper(nested, list, is_sequence_helper, get_value_iterator)) {
882 return list;
883 } else {
884 Py_DECREF(list);
885 return nullptr;
886 }
887}
888
889bool IsSequenceOrComposite(PyObject* o) {
890 return IsSequenceOrCompositeHelper(o) == 1;

Callers 2

RecordGradientFunction · 0.50
CollectiveAdapterImplMethod · 0.50

Calls 1

FlattenHelperFunction · 0.85

Tested by

no test coverage detected