am15h/tflite_flutter_helper

Is it possible to get values from TensorBuffer in a way other than .getDoubleList()?

farazk86 opened this issue · 1 comments

Hi,

I have a NLP network that returns output in the shape [1][64][5027]. I preallocate a list for this before giving to interpreter.run() but that is very slow, so I hope that using TensorBuffer can help speed this up a bit.

Currently, I access the output logits using output[0][63] to get the last list of size 5027. But I cannot seem to do this when using TensorBuffer as the function outputBuffer.getDoubleList() returns a flat list of all the elements. This is not what I want..

So, using TensorBuffer is there a way to access the output as outputBuffer[0][63]?

Thank you

am15h commented

Hi @farazk86, getDoubleList will return a flattened version of the outputs, in your case it should return a List of size 1645067.

So to get list at [0][63] you may do,

outputBuffer.getDoubleList().sublist(63 * 5067, 64 * 5067).

You may also directly get a particular value from the output buffer using output buffer.getDoubleValue(int absIdx) where absIndx is the corresponding index of required element in the flattened list.