MCPcopy Create free account
hub / github.com/ml-explore/mlx / tree_unflatten_from_structure

Function tree_unflatten_from_structure

python/src/trees.cpp:299–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299nb::object tree_unflatten_from_structure(
300 nb::object structure,
301 const std::vector<mx::array>& values,
302 int index /* = 0 */) {
303 auto sentinel = structure_sentinel();
304 return tree_map(structure, [&](nb::handle obj) {
305 if (obj.is(sentinel)) {
306 return nb::cast(values[index++]);
307 } else {
308 return nb::cast<nb::object>(obj);
309 }
310 });
311}

Callers 8

call_implMethod · 0.85
operator()Method · 0.85
call_implMethod · 0.85
operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85
call_implMethod · 0.85

Calls 2

structure_sentinelFunction · 0.85
tree_mapFunction · 0.70

Tested by

no test coverage detected