doc-ai / tensorio-ios

Tensor/IO for iOS, with support for on-device inference and training with TensorFlow and TensorFlow Lite
Other
31 stars 10 forks source link

Correct indexing of TF Lite inputs or reference by name #226

Open phildow opened 3 years ago

phildow commented 3 years ago

As reported in https://github.com/doc-ai/tensorio-ios/issues/225 I'm seeing a number of these errors in a model we're using:

There was a problem writing the data buffer to the tensor, error: Error Domain=org.tensorflow.lite.interpreter Code=1 "Input tensor at index (0) expects data size (8), but got (4)." UserInfo={NSLocalizedDescription=Input tensor at index (0) expects data size (8), but got (4).}

Hypothesis 2: Indices in the JSON are out of order and I'm trying to write float32s to inputs that expected int64s

I take the order of the inputs from the saved_model_cli and have always assumed this is the order they will be in TF Lite as well, but I don't actually know if that's the case or how to check input indices. Would be nice if we could reference these by name.

phildow commented 3 years ago

Ordering is in fact an issue and the order of the inputs does not match the order of the inputs as described by the saved_model_cli.

The simplest solution is just to require the consumer to order correctly, since even just figuring out the names can be a hassle. not sure what tool is available for getting indices in tf lite models though.