refactor: move tflite::Span to independent header (#2638)

Hoist the universally-useful tflite::Span out of
codegen/runtime/micro_codegen_context.h and into an independent header
usable from elsewhere in the project.

BUG=#2636
diff --git a/codegen/runtime/BUILD b/codegen/runtime/BUILD
index a1cb6c1..d23cb70 100644
--- a/codegen/runtime/BUILD
+++ b/codegen/runtime/BUILD
@@ -14,5 +14,6 @@
         "//tensorflow/lite/micro:micro_context",
         "//tensorflow/lite/micro:micro_graph",
         "//tensorflow/lite/micro:micro_log",
+        "//tensorflow/lite/micro:span",
     ],
 )
diff --git a/codegen/runtime/micro_codegen_context.h b/codegen/runtime/micro_codegen_context.h
index ca01a63..3693ad2 100644
--- a/codegen/runtime/micro_codegen_context.h
+++ b/codegen/runtime/micro_codegen_context.h
@@ -19,25 +19,10 @@
 #include "tensorflow/lite/c/common.h"
 #include "tensorflow/lite/micro/micro_context.h"
 #include "tensorflow/lite/micro/micro_graph.h"
+#include "tensorflow/lite/micro/span.h"
 
 namespace tflite {
 
-// A poor man's std::span, we should consider using the Pigweed span instead.
-template <typename T>
-class Span {
- public:
-  constexpr Span(T* data, size_t size) noexcept : data_(data), size_(size) {}
-
-  constexpr T& operator[](size_t idx) const noexcept { return *(data_ + idx); }
-
-  constexpr T* data() const noexcept { return data_; }
-  constexpr size_t size() const noexcept { return size_; }
-
- private:
-  T* data_;
-  size_t size_;
-};
-
 struct Subgraph {
   Span<const size_t> inputs;
   Span<const size_t> outputs;
diff --git a/tensorflow/lite/micro/BUILD b/tensorflow/lite/micro/BUILD
index 60ace25..527b85a 100644
--- a/tensorflow/lite/micro/BUILD
+++ b/tensorflow/lite/micro/BUILD
@@ -402,6 +402,12 @@
 )
 
 cc_library(
+    name = "span",
+    hdrs = ["span.h"],
+    copts = micro_copts(),
+)
+
+cc_library(
     name = "system_setup",
     srcs = [
         "system_setup.cc",
diff --git a/tensorflow/lite/micro/span.h b/tensorflow/lite/micro/span.h
new file mode 100644
index 0000000..eeb4c0b
--- /dev/null
+++ b/tensorflow/lite/micro/span.h
@@ -0,0 +1,41 @@
+/* Copyright 2024 The TensorFlow Authors. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+#ifndef TENSORFLOW_LITE_MICRO_SPAN_H_
+#define TENSORFLOW_LITE_MICRO_SPAN_H_
+
+#include <cstddef>
+
+namespace tflite {
+
+// A poor man's std::span, we should consider using the Pigweed span instead.
+template <typename T>
+class Span {
+ public:
+  constexpr Span(T* data, size_t size) noexcept : data_(data), size_(size) {}
+
+  constexpr T& operator[](size_t idx) const noexcept { return *(data_ + idx); }
+
+  constexpr T* data() const noexcept { return data_; }
+  constexpr size_t size() const noexcept { return size_; }
+
+ private:
+  T* data_;
+  size_t size_;
+};
+
+}  // end namespace tflite
+
+#endif  // TENSORFLOW_LITE_MICRO_SPAN_H_