MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / flatten

Function flatten

python/paddle/utils/layers_utils.py:177–188  ·  view source on GitHub ↗

:alias_main: paddle.flatten :alias: paddle.flatten,paddle.tensor.flatten,paddle.tensor.manipulation.flatten :old_api: paddle.base.layers.flatten Traverse all entries in the nested structure and put them into an list.

(nest: NestedStructure[_T])

Source from the content-addressed store, hash-verified

175
176
177def flatten(nest: NestedStructure[_T]) -> typing.Sequence[_T]:
178 """
179 :alias_main: paddle.flatten
180 :alias: paddle.flatten,paddle.tensor.flatten,paddle.tensor.manipulation.flatten
181 :old_api: paddle.base.layers.flatten
182
183 Traverse all entries in the nested structure and put them into an list.
184 """
185 if is_sequence(nest):
186 return list(_yield_flat_nest(nest))
187 else:
188 return [nest]
189
190
191def _sequence_like(instance, args):

Callers 15

hasherMethod · 0.90
while_loopFunction · 0.90
check_ret_noneFunction · 0.90
condFunction · 0.90
pack_undefined_var_asFunction · 0.90
__call__Method · 0.90
static_pylayerFunction · 0.90
wrappedFunction · 0.90
_split_args_helperFunction · 0.90
merge_chunksFunction · 0.90

Calls 3

is_sequenceFunction · 0.85
listFunction · 0.85
_yield_flat_nestFunction · 0.85

Tested by

no test coverage detected