@@ -1388,7 +1388,7 @@ TF_LITE_MICRO_TEST(TestMultiSubgraphNumScratchAllocations) {
13881388// New tests validating invalid buffer index guards in tensor initialization
13891389// and model allocation paths.
13901390
1391- TF_LITE_MICRO_TEST (InitializeTfLiteTensorFromFlatbuffer_InvalidBufferIndexReturnsError ) {
1391+ TF_LITE_MICRO_TEST (TestInitializeTensorInvalidBufferIndex ) {
13921392 // Arena and allocator for temporary/persistent allocations used by init.
13931393 constexpr size_t arena_size = 1024 ;
13941394 uint8_t arena[arena_size];
@@ -1415,44 +1415,21 @@ TF_LITE_MICRO_TEST(InitializeTfLiteTensorFromFlatbuffer_InvalidBufferIndexReturn
14151415 tflite::testing::CreateFlatbufferBuffers ();
14161416
14171417 TfLiteTensor out_tensor;
1418+ TfLiteEvalTensor out_eval_tensor;
1419+
14181420 // Expect kTfLiteError due to invalid buffer index.
14191421 TF_LITE_MICRO_EXPECT_EQ (
14201422 kTfLiteError ,
14211423 tflite::internal::InitializeTfLiteTensorFromFlatbuffer (
14221424 simple_allocator, simple_allocator, /* allocate_temp=*/ false ,
14231425 *bad_tensor, buffers, &out_tensor));
1424-
1425- simple_allocator->~SingleArenaBufferAllocator ();
1426- }
1427-
1428- TF_LITE_MICRO_TEST (InitializeTfLiteEvalTensorFromFlatbuffer_InvalidBufferIndexReturnsError) {
1429- // Build a flatbuffer Tensor that references a non-existent buffer index.
1430- flatbuffers::FlatBufferBuilder builder;
1431- const int32_t dims_data[] = {1 };
1432- auto dims_vec = builder.CreateVector (dims_data, 1 );
1433- const uint32_t kInvalidBufferIndex = 7 ;
1434- auto name_str = builder.CreateString (" invalid_eval_buffer_tensor" );
1435- auto tensor_offset = tflite::CreateTensor (
1436- builder, /* shape=*/ dims_vec, tflite::TensorType_INT32,
1437- /* buffer=*/ kInvalidBufferIndex , /* name=*/ name_str,
1438- /* quantization=*/ 0 , /* is_variable=*/ false , /* sparsity=*/ 0 );
1439- builder.Finish (tensor_offset);
1440- const tflite::Tensor* bad_tensor =
1441- flatbuffers::GetRoot<tflite::Tensor>(builder.GetBufferPointer ());
1442-
1443- // Create a buffers vector with a single empty buffer.
1444- const flatbuffers::Vector<flatbuffers::Offset<tflite::Buffer>>* buffers =
1445- tflite::testing::CreateFlatbufferBuffers ();
1446-
1447- TfLiteEvalTensor out_eval_tensor;
1448- // Expect kTfLiteError due to invalid buffer index.
14491426 TF_LITE_MICRO_EXPECT_EQ (
14501427 kTfLiteError ,
14511428 tflite::internal::InitializeTfLiteEvalTensorFromFlatbuffer (
14521429 *bad_tensor, buffers, &out_eval_tensor));
14531430}
14541431
1455- TF_LITE_MICRO_TEST (StartModelAllocation_FailsWhenSubgraphHasTensorWithInvalidBufferIndex ) {
1432+ TF_LITE_MICRO_TEST (TestModelAllocationSubgraphInvalidBufferIndex ) {
14561433 // Build a minimal model with a single tensor that references an invalid
14571434 // buffer index. Make it an output tensor to mimic output-table invalid case
14581435 // but the allocator will validate all tensors equally, so this also
0 commit comments