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

Regarding 0-d tensor #79

Closed hansely closed 5 years ago

hansely commented 5 years ago

Hi, I was looking at the sample NNEF models on the website and found some instructions with scalar values for the tensor. For example in the vgg19, it has

mul_5 = mul(1.0, variable_37) where mul operation requires two tensors as inputs. Does above operation mean multiplying 1.0 to each elements in the tensor? If yes, what is the point of multiplying 1?

In addition, in NNEF, each tensor variables are saved as a binary data file. Does the 0-d tensor also saved as a binary data file and loaded when load_graph function is called?

gyenesvi commented 5 years ago

Yes, it means multiplying each element in the tensor with a scalar, and it is essentially the same as a 0-d tensor. The fact that in this case it happens to be 1.0 is just a coincidence in this particular example, it was like that in the original model from which it was converted, but it could be any other scalar.

Constants are not saved to a binary file, they are directly included inside the graph, but they have the same effect.

hansely commented 5 years ago

I get it. Thanks!