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

No data when loading the NNEF graph #93

Closed hansely closed 5 years ago

hansely commented 5 years ago

When I load graph using the nnef graph path,

graph = nnef.load_graph(path) nnef.infer_shapes(nnef_graph)

I was able to get the data and the data type of the variable tensor as follows:

if operation.name == 'variable': tensor_name = nnef_operation.outputs['output'] tensor = nnef_graph.tensors[tensor_name] data = tensor.data dtype = tensor.data.dtype

However, if I load graph using the nnef graph file itself,

graph = nnef.load_graph(nnef.graph) nnef.infer_shapes(nnef_graph)

the data comes out as None.

Is this a bug?

gyenesvi commented 5 years ago

No, this is not a bug. If you give it the folder path, it loads the graph and the weights (variables). If you just give it the graph file, it only loads the graph, without the weights, that is why there is no data in it. The readme describes this behavior under "Using the Python module".

hansely commented 5 years ago

Then is there a way to load the weights as well?

gyenesvi commented 5 years ago

What do you mean? You said in the beginning, that if you give it the path to the NNEF folder, then it successfully loaded the weights. So what is the problem?

hansely commented 5 years ago

I mean I want to load the weights by giving the graph itself instead of the path.

gyenesvi commented 5 years ago

Well, the graph itself does not contain the variables data, so it cannot load it just based on that info. It's the path that contains the whole info.

But I don't quite get what you want to achieve, why is it not good enough to give the path. Think about it as a container that contains multiple pieces of info. You need to point to the container if you want to mean the whole.

hansely commented 5 years ago

I get it. I think path would be good enough. Thanks.