@@ -313,6 +313,8 @@ Error Method::parse_values() {
313
313
" Null value at index %zu" ,
314
314
i);
315
315
316
+ const auto val = serialization_value->val ();
317
+
316
318
switch (serialization_value->val_type ()) {
317
319
case executorch_flatbuffer::KernelTypes::Null: {
318
320
// Placement new as the list elements are not initialized, so calling
@@ -321,18 +323,21 @@ Error Method::parse_values() {
321
323
new (&values_[i]) EValue ();
322
324
} break ;
323
325
case executorch_flatbuffer::KernelTypes::Int: {
324
- new (&values_[i]) EValue (serialization_value->val_as_Int ()->int_val ());
326
+ new (&values_[i]) EValue (
327
+ static_cast <const executorch_flatbuffer::Int*>(val)->int_val ());
325
328
} break ;
326
329
case executorch_flatbuffer::KernelTypes::Double: {
327
330
new (&values_[i])
328
- EValue (serialization_value->val_as_Double ()->double_val ());
331
+ EValue (static_cast <const executorch_flatbuffer::Double*>(val)
332
+ ->double_val ());
329
333
} break ;
330
334
case executorch_flatbuffer::KernelTypes::Bool: {
331
- new (&values_[i])
332
- EValue (serialization_value-> val_as_Bool ( )->bool_val ());
335
+ new (&values_[i]) EValue (
336
+ static_cast < const executorch_flatbuffer::Bool*>(val )->bool_val ());
333
337
} break ;
334
338
case executorch_flatbuffer::KernelTypes::IntList: {
335
- const auto items = serialization_value->val_as_IntList ()->items ();
339
+ const auto items =
340
+ static_cast <const executorch_flatbuffer::IntList*>(val)->items ();
336
341
ET_CHECK_OR_RETURN_ERROR (
337
342
items != nullptr , InvalidProgram, " Missing list at index %zu" , i);
338
343
// Allocate space for boxed and unboxed list representations using
@@ -352,7 +357,8 @@ Error Method::parse_values() {
352
357
BoxedEvalueList<int64_t >(evalp_list, int_list, items->size ()));
353
358
} break ;
354
359
case executorch_flatbuffer::KernelTypes::BoolList: {
355
- const auto items = serialization_value->val_as_BoolList ()->items ();
360
+ const auto items =
361
+ static_cast <const executorch_flatbuffer::BoolList*>(val)->items ();
356
362
ET_CHECK_OR_RETURN_ERROR (
357
363
items != nullptr , InvalidProgram, " Missing list at index %zu" , i);
358
364
// NOTE: This is technically not portable. A platform could technically
@@ -366,14 +372,17 @@ Error Method::parse_values() {
366
372
(const bool *)items->data (), items->size ()));
367
373
} break ;
368
374
case executorch_flatbuffer::KernelTypes::DoubleList: {
369
- const auto items = serialization_value->val_as_DoubleList ()->items ();
375
+ const auto items =
376
+ static_cast <const executorch_flatbuffer::DoubleList*>(val)->items ();
370
377
ET_CHECK_OR_RETURN_ERROR (
371
378
items != nullptr , InvalidProgram, " Missing list at index %zu" , i);
372
379
new (&values_[i])
373
380
EValue (exec_aten::ArrayRef<double >(items->data (), items->size ()));
374
381
} break ;
375
382
case executorch_flatbuffer::KernelTypes::String: {
376
- const auto fb_str = serialization_value->val_as_String ()->string_val ();
383
+ const auto fb_str =
384
+ static_cast <const executorch_flatbuffer::String*>(val)
385
+ ->string_val ();
377
386
ET_CHECK_OR_RETURN_ERROR (
378
387
fb_str != nullptr ,
379
388
InvalidProgram,
@@ -383,7 +392,9 @@ Error Method::parse_values() {
383
392
} break ;
384
393
case executorch_flatbuffer::KernelTypes::Tensor: {
385
394
auto t = deserialization::parseTensor (
386
- program_, memory_manager_, serialization_value->val_as_Tensor ());
395
+ program_,
396
+ memory_manager_,
397
+ static_cast <const executorch_flatbuffer::Tensor*>(val));
387
398
if (!t.ok ()) {
388
399
ET_LOG (
389
400
Error,
@@ -398,7 +409,7 @@ Error Method::parse_values() {
398
409
// get list of serialization tensors and allocate storage for executor
399
410
// tensors
400
411
auto tensors = deserialization::parseTensorList (
401
- serialization_value-> val_as_TensorList ( )->items (),
412
+ static_cast < const executorch_flatbuffer::TensorList*>(val )->items (),
402
413
values_,
403
414
memory_manager_);
404
415
if (!tensors.ok ()) {
@@ -415,7 +426,9 @@ Error Method::parse_values() {
415
426
// Same as TensorList but optional<Tensor> instead of Tensor
416
427
auto tensors =
417
428
deserialization::parseListOptionalType<exec_aten::Tensor>(
418
- serialization_value->val_as_OptionalTensorList ()->items (),
429
+ static_cast <const executorch_flatbuffer::OptionalTensorList*>(
430
+ val)
431
+ ->items (),
419
432
values_,
420
433
memory_manager_);
421
434
if (!tensors.ok ()) {
0 commit comments