KhronosGroup / NNEF-Tools

The NNEF Tools repository contains tools to generate and consume NNEF documents
https://www.khronos.org/nnef
222 stars 58 forks source link

flatten a composite #27

Closed jnorwood closed 6 years ago

jnorwood commented 6 years ago

The NNEF spec states, "Conceptually, a document processor should be able to take in a document, and if it is well-formatted, the processor should be able to output another document, which represents the same graph in a flattened format built only as a sequence of primitives with concrete arguments, without any compound fragment definitions and formal parameter expressions.".

I'm wondering if one of the tools provides this feature.

gyenesvi commented 6 years ago

Yes, the parser/validator does exactly this if the input is valid, i.e. it echoes back the flattened version of the graph. The atomics parameter controls which operations should not be flattened, which is by default set to all operations defined in the spec (so if you only use standard operations, the output of the tool should be the same as its input). If you remove some op from the list of atomics by setting for example --atomics -batch_normalization in the command line of the C++ version then it will be flattened. Alternatively, you could try the python interface by setting atomics = [], then everything should be flattened to primitives.

jnorwood commented 6 years ago

good to know. --atomics wasn't in my current clone of the parser code, but I see it was added a couple of months ago. I'll close this.