KhronosGroup / NNEF-Tools

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

Mismatch between specification and NNEF-tools in tensor item type #151

Closed TimotheeLeBerresonos closed 3 years ago

TimotheeLeBerresonos commented 3 years ago

In the specification, the khronos item types are defined as:

• 0x0000 - float values in IEEE format, valid bits per item is 16, 32, 64. • 0x0001 - unsigned integer values, maximum bits per item is 64. • 0x0010 - quantized unsigned integer values, maximum bits per item is 64. • 0x0011 - quantized signed integer values, maximum bits per item is 64. • 0x0100 - signed integer values, maximum bits per item is 64. • 0x0101 - bool values, 1 bit or 8 bits (0 means false, non-zero means true)

In https://github.com/KhronosGroup/NNEF-Tools/blob/master/parser/python/nnef/binary.py, the item types are defined as:

class ItemType:    
    FLOAT = 0   
    UINT = 1    
    QUINT = 2    
    QINT = 3   
    INT = 4    
    BOOL = 5

This mismatch originates from #123 , where its seems 0x10 was converted to 2 and so on.

gyenesvi commented 3 years ago

Not sure I understand what mismatch you are referring to, since 0x10 == 2. To me all hex values seem to match their decimal counterparts.

TimotheeLeBerresonos commented 3 years ago

I think 0x10 == 16 usually. That is the case in python at least, so the behavior changed after #123 .

gyenesvi commented 3 years ago

Oh, your are right. I mistook them for binary values. Actually, that is what they are meant to be, otherwise, the values would be quite scattered. This is an error in the spec, not the tools, which needs a bit of consideration to fix.

TimotheeLeBerresonos commented 3 years ago

Alright, thank you !

gyenesvi commented 3 years ago

The spec has been updated to clarify that the literals are meant to be binary.