You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `TfLiteContext::RequestScratchBufferInArena` method is available only within
335
370
the scope of your operator's `Prepare` method.
336
371
The `TfLiteContext::GetScratchBuffer` method is available only within
337
372
the scope of your operator's `Invoke` method.
338
373
339
-
## Can I resize my input/output tensors?
340
-
No. The storage space for each input/output tensor is a fixed, calculated value
341
-
determined at the time the TensorFlow Lite (TfLite) model converter is executed.
342
-
During the `Init` phase of the `tflite::MicroInterpreter` all tensor storage is
343
-
allocated by the `tflite::MicroInterpreter` instance, using the calculated values
344
-
of the model converter.
374
+
The `MicroContext::AllocateTempBuffer` and `MicroContext::DeallocateTempBuffer`
375
+
methods are only available within the scope of your operator's `Prepare` method.
376
+
377
+
## Can I resize the tensors of my model?
378
+
No. The storage space for each `input`/`output`/`const` tensor is a fixed,
379
+
calculated value determined at the time the TensorFlow Lite (TfLite) model
380
+
converter is executed.
381
+
All tensor storage is allocated by the `tflite::MicroInterpreter` instance,
382
+
using the tensor shape values of the TfLite model converter.
383
+
384
+
TFLM does not support dynamic tensors. A dynamic tensor is one whose storage
385
+
(and shape) can change during inference.
386
+
345
387
For more information see: [Memory Allocation Overview](online_memory_allocation_overview.md)
346
388
347
389
## Can I change the shape of tensors in my operator code?
348
-
Yes. The new shape must not exceed the storage space indicated by the old shape.
349
-
Because tensor shape values may live in memory that is not directly writable
350
-
(ex. Flash, EEPROM, ROM), a special method must be called before modification
390
+
Yes. The new shape must be exactly equal to the storage space indicated by the
391
+
old shape.
392
+
Because tensor shape values may live in non-volatile memory that is not directly
393
+
writable (ex. Flash, ROM), a special method must be called before modification
351
394
is attempted. The `tflite::micro::CreateWritableTensorDimsWithCopy` method will
352
395
move the tensor shape values to guaranteed persistent writable memory.
353
396
@@ -378,8 +421,46 @@ structures. Your code should not modify these data structures. The only
378
421
directly allowed modification of tensors is to change their data values, or
379
422
their shape values.
380
423
424
+
## When can I inspect tensor data?
425
+
Tensor data can always be inspected within the scope of your operator's `Invoke`
426
+
method.
427
+
428
+
Within the scope of your operator's `Prepare` method, use
429
+
`tflite::IsConstantTensor` before inspecting the tensor data.
430
+
Only when `tflite::IsConstantTensor` returns `true`, does the tensor have valid
431
+
data.
432
+
381
433
## How do I fix optimized kernel unit test failures?
382
-
Kernel unit tests for all optimizated kernels should pass. By default kernel unit
383
-
tests for the newly added op may fail for optimized kernels as they may not have the
384
-
correct references. In this case, we should let the optimized kernels fall back
385
-
to the newly added reference kernels. For example, refer to this [this commit](https://github.com/tensorflow/tflite-micro/pull/1274/commits/d36c9dd598dcbf352f2c60463fd0d4153703a1cd).
434
+
Kernel unit tests for all optimized kernels should pass.
435
+
It should be noted that optimized kernels may not handle all tensor types or
436
+
operator parameters.
437
+
In this case, the optimized kernel should fallback on calling the reference
438
+
kernel methods. The following code snippet example can be found [here](https://github.com/tensorflow/tflite-micro/blob/a1eb0480ed9f98e9ea5f5fb9b8e3da98ec512caf/tensorflow/lite/micro/kernels/cmsis_nn/softmax.cc#L98C1-L123C6):
0 commit comments