code: def _apply_simd_optimizations(
      instruction_tuples,
  ) -> Iterator[SMLAInstruction]:
      """When possible, fuses single MACs into SIMD MAC instructions.
  
      The compiler cannot do this automatically, as calling __smlaxy forces the SMLAxy instruction to
      be used. This function takes as input an iterator of SMLAInstructions and returns an iterator of
      SMLAInstructions (possibly of different length).
      """
      curr_tuple = next(instruction_tuples, None)
      while curr_tuple:
          next_tuple = next(instruction_tuples, None)
          if next_tuple is None:
              yield curr_tuple
              break
  
          if curr_tuple.has_same_operands(next_tuple):
              instructions = sorted(
                  [curr_tuple.instruction, next_tuple.instruction]
              )
              if instructions == ["smlabb", "smlatt"]:
                  yield SMLAInstruction(
                      "smlad",
                      curr_tuple.tensor_var,
                      curr_tuple.kernel_var,
                  )
                  next_tuple = next(instruction_tuples, None)
              elif instructions == ["smlabt", "smlatb"]:
                  yield SMLAInstruction(
                      "smladx",
                      curr_tuple.tensor_var,
                      curr_tuple.kernel_var,
                  )
                  next_tuple = next(instruction_tuples, None)
              else:
                  yield curr_tuple
  
          else:
              yield curr_tuple
          curr_tuple = next_tuple
  
file_path: tvm/python/tvm/topi/arm_cpu/mprofile/dsp/micro_kernel/tensordot.py
imports: from dataclasses import dataclass
  from itertools import chain
  import textwrap
  from typing import Iterator, Optional, Tuple
label_desc: Use image node_id 9 for calling a global function with example usage: _apply_simd_optimizations(instruction_tuples) without return types