@@ -2330,34 +2330,42 @@ TfLiteStatus ParseStablehloGather(const Operator* op,
23302330 op->builtin_options_2_as_StablehloGatherOptions ();
23312331
23322332 if (schema_params != nullptr ) {
2333- TF_LITE_ENSURE_STATUS (FlatBufferIntVectorToArray<int64_t >(
2334- /* max_size_of_buffer=*/ schema_params->offset_dims ()->size () *
2335- sizeof (int64_t ),
2336- /* flat_vector=*/ schema_params->offset_dims (),
2337- /* buffer=*/ params->offset_dims , /* error_reporter=*/ error_reporter,
2338- /* op_name=*/ " stablehlo_gather" ));
2339- params->num_offset_dims = schema_params->offset_dims ()->size ();
2340-
2341- TF_LITE_ENSURE_STATUS (FlatBufferIntVectorToArray<int64_t >(
2342- schema_params->collapsed_slice_dims ()->size () * sizeof (int64_t ),
2343- schema_params->collapsed_slice_dims (), params->collapsed_slice_dims ,
2344- error_reporter, " stablehlo_gather" ));
2345- params->num_collapsed_slice_dims =
2346- schema_params->collapsed_slice_dims ()->size ();
2347-
2348- TF_LITE_ENSURE_STATUS (FlatBufferIntVectorToArray<int64_t >(
2349- schema_params->start_index_map ()->size () * sizeof (int64_t ),
2350- schema_params->start_index_map (), params->start_index_map ,
2351- error_reporter, " stablehlo_gather" ));
2352- params->num_start_index_map = schema_params->start_index_map ()->size ();
2333+ if (schema_params->offset_dims ()) {
2334+ TF_LITE_ENSURE_STATUS (FlatBufferIntVectorToArray<int64_t >(
2335+ /* max_size_of_buffer=*/ schema_params->offset_dims ()->size () *
2336+ sizeof (int64_t ),
2337+ /* flat_vector=*/ schema_params->offset_dims (),
2338+ /* buffer=*/ params->offset_dims , /* error_reporter=*/ error_reporter,
2339+ /* op_name=*/ " stablehlo_gather" ));
2340+ params->num_offset_dims = schema_params->offset_dims ()->size ();
2341+ }
2342+
2343+ if (schema_params->collapsed_slice_dims ()) {
2344+ TF_LITE_ENSURE_STATUS (FlatBufferIntVectorToArray<int64_t >(
2345+ schema_params->collapsed_slice_dims ()->size () * sizeof (int64_t ),
2346+ schema_params->collapsed_slice_dims (), params->collapsed_slice_dims ,
2347+ error_reporter, " stablehlo_gather" ));
2348+ params->num_collapsed_slice_dims =
2349+ schema_params->collapsed_slice_dims ()->size ();
2350+ }
2351+
2352+ if (schema_params->start_index_map ()) {
2353+ TF_LITE_ENSURE_STATUS (FlatBufferIntVectorToArray<int64_t >(
2354+ schema_params->start_index_map ()->size () * sizeof (int64_t ),
2355+ schema_params->start_index_map (), params->start_index_map ,
2356+ error_reporter, " stablehlo_gather" ));
2357+ params->num_start_index_map = schema_params->start_index_map ()->size ();
2358+ }
23532359
23542360 params->index_vector_dim = schema_params->index_vector_dim ();
23552361
2356- TF_LITE_ENSURE_STATUS (FlatBufferIntVectorToArray<int64_t >(
2357- schema_params->slice_sizes ()->size () * sizeof (int64_t ),
2358- schema_params->slice_sizes (), params->slice_sizes , error_reporter,
2359- " stablehlo_gather" ));
2360- params->num_slice_sizes = schema_params->slice_sizes ()->size ();
2362+ if (schema_params->slice_sizes ()) {
2363+ TF_LITE_ENSURE_STATUS (FlatBufferIntVectorToArray<int64_t >(
2364+ schema_params->slice_sizes ()->size () * sizeof (int64_t ),
2365+ schema_params->slice_sizes (), params->slice_sizes , error_reporter,
2366+ " stablehlo_gather" ));
2367+ params->num_slice_sizes = schema_params->slice_sizes ()->size ();
2368+ }
23612369
23622370 params->indices_are_sorted = schema_params->indices_are_sorted ();
23632371 } else {
0 commit comments