Merge "Rename matcha.ld to springbok.ld"
diff --git a/cmake/springbok_bytecode_module.cmake b/cmake/springbok_bytecode_module.cmake
index 05e3ab9..9edf0db 100644
--- a/cmake/springbok_bytecode_module.cmake
+++ b/cmake/springbok_bytecode_module.cmake
@@ -2,7 +2,7 @@
 
 # springbok_bytecode_module()
 #
-# A wrapper for the iree_bytecode_module to apply common iree-translate flags
+# A wrapper for the iree_bytecode_module to apply common iree-compile flags
 # Parameters:
 # NAME: Name of target.
 # SRC: Source file to compile into a bytecode module. Support relative path.
@@ -68,7 +68,7 @@
   endif()
 
   get_filename_component(_MLIR_SRC "${_MLIR_SRC}" REALPATH)
-  iree_get_executable_path(_TRANSLATE_TOOL_EXECUTABLE "iree-translate")
+  iree_get_executable_path(_TRANSLATE_TOOL_EXECUTABLE "iree-compile")
   iree_get_executable_path(_LINKER_TOOL_EXECUTABLE "lld")
 
   # Replace dependencies passed by ::name with iree::package::name
@@ -89,7 +89,7 @@
   endif()
 
   ## Example with VM C module.
-  # Setup args for iree-translate.
+  # Setup args for iree-compile.
   set(_TRANSLATE_ARGS ${_RULE_FLAGS})
   list(APPEND _TRANSLATE_ARGS "-iree-mlir-to-vm-bytecode-module")
   list(APPEND _TRANSLATE_ARGS "-iree-hal-target-backends=dylib-llvm-aot")
@@ -105,7 +105,7 @@
   list(APPEND _TRANSLATE_ARGS "-o")
   list(APPEND _TRANSLATE_ARGS "${_VMFB_FILE_NAME}")
 
-  # Custom command for iree-translate to generate static library and C module.
+  # Custom command for iree-compile to generate static library and C module.
   add_custom_command(
     OUTPUT
       ${_H_FILE_NAME}
diff --git a/cmake/springbok_c_module.cmake b/cmake/springbok_c_module.cmake
index e9774bf..0db52cb 100644
--- a/cmake/springbok_c_module.cmake
+++ b/cmake/springbok_c_module.cmake
@@ -2,7 +2,7 @@
 
 # springbok_c_module()
 #
-# A wrapper for the iree c module to apply common iree-translate flags
+# A wrapper for the iree c module to apply common iree-compile flags
 # Parameters:
 # NAME: Name of target.
 # SRC: Source file to compile into an emitC module. Support relative path.
@@ -64,7 +64,7 @@
   endif()
 
   get_filename_component(_MLIR_SRC "${_MLIR_SRC}" REALPATH)
-  iree_get_executable_path(_TRANSLATE_TOOL_EXECUTABLE "iree-translate")
+  iree_get_executable_path(_TRANSLATE_TOOL_EXECUTABLE "iree-compile")
   iree_get_executable_path(_LINKER_TOOL_EXECUTABLE "lld")
 
   # Replace dependencies passed by ::name with iree::package::name
@@ -88,7 +88,7 @@
   endif()
 
   ## Example with VM C module.
-  # Setup args for iree-translate.
+  # Setup args for iree-compile.
   set(_TRANSLATE_ARGS ${_RULE_FLAGS})
   list(APPEND _TRANSLATE_ARGS "-iree-mlir-to-vm-c-module")
   list(APPEND _TRANSLATE_ARGS "-iree-hal-target-backends=dylib-llvm-aot")
@@ -104,7 +104,7 @@
   list(APPEND _TRANSLATE_ARGS "-o")
   list(APPEND _TRANSLATE_ARGS "${_EMITC_FILE_NAME}")
 
-  # Custom command for iree-translate to generate static library and C module.
+  # Custom command for iree-compile to generate static library and C module.
   add_custom_command(
     OUTPUT
       ${_H_FILE_NAME}
diff --git a/cmake/springbok_modules.cmake b/cmake/springbok_modules.cmake
index 30d3a40..d83be9e 100644
--- a/cmake/springbok_modules.cmake
+++ b/cmake/springbok_modules.cmake
@@ -2,7 +2,7 @@
 
 # springbok_modules()
 #
-# A wrapper for the springbok_bytecode_module and springbok_c_module to apply common iree-translate flags
+# A wrapper for the springbok_bytecode_module and springbok_c_module to apply common iree-compile flags
 # Parameters:
 # NAME: Name of target.
 # SRC: Source file to compile into a bytecode module. Support relative path.
diff --git a/samples/device/device_static_loader.c b/samples/device/device_static_loader.c
index 225712c..caa2483 100644
--- a/samples/device/device_static_loader.c
+++ b/samples/device/device_static_loader.c
@@ -18,9 +18,7 @@
   iree_hal_sync_device_params_initialize(&params);
 
   // Load the statically embedded library
-  const iree_hal_executable_library_header_t** static_library = library_query(
-      IREE_HAL_EXECUTABLE_LIBRARY_LATEST_VERSION, /*reserved=*/NULL);
-  const iree_hal_executable_library_header_t** libraries[1] = {static_library};
+  const iree_hal_executable_library_query_fn_t libraries[] = {library_query()};
 
   iree_hal_executable_loader_t* library_loader = NULL;
   if (iree_status_is_ok(status)) {
diff --git a/samples/float_model/CMakeLists.txt b/samples/float_model/CMakeLists.txt
index f921a2e..d89bcc9 100644
--- a/samples/float_model/CMakeLists.txt
+++ b/samples/float_model/CMakeLists.txt
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Build the mlir bytecode modules with iree-translate. Note the last two flags
+# Build the mlir bytecode modules with iree-compile. Note the last two flags
 # are for RVV support.
 #-------------------------------------------------------------------------------
 
@@ -83,6 +83,7 @@
     iree::vm::bytecode_module
     samples::util::util
   LINKOPTS
+    "LINKER:--defsym=__itcm_length__=1M"
     "LINKER:--defsym=__stack_size__=200k"
 )
 
@@ -98,6 +99,7 @@
     samples::util::util
     "m"
   LINKOPTS
+    "LINKER:--defsym=__itcm_length__=1M"
     "LINKER:--defsym=__stack_size__=200k"
   COPTS
     "-DBUILD_EMITC"
diff --git a/samples/float_model/mnist.c b/samples/float_model/mnist.c
index 7cccb9f..55dd642 100644
--- a/samples/float_model/mnist.c
+++ b/samples/float_model/mnist.c
@@ -47,16 +47,14 @@
 #endif
 }
 
-const iree_hal_executable_library_header_t **library_query(
-    iree_hal_executable_library_version_t max_version, void *reserved) {
-  return mnist_linked_llvm_library_query(max_version,
-                                         /*reserved=*/reserved);
+iree_hal_executable_library_query_fn_t library_query(void) {
+  return &mnist_linked_llvm_library_query;
 }
 
 iree_status_t load_input_data(const MlModel *model, void **buffer,
-                              iree_byte_span_t **byte_span) {
-  byte_span[0] = malloc(sizeof(iree_byte_span_t));
-  *byte_span[0] = iree_make_byte_span(
+                              iree_const_byte_span_t **byte_span) {
+  byte_span[0] = malloc(sizeof(iree_const_byte_span_t));
+  *byte_span[0] = iree_make_const_byte_span(
       mnist_input, model->input_size_bytes[0] * model->input_length[0]);
   return iree_ok_status();
 }
diff --git a/samples/float_model/mobilenet_v1.c b/samples/float_model/mobilenet_v1.c
index c9a72d0..17e08de 100644
--- a/samples/float_model/mobilenet_v1.c
+++ b/samples/float_model/mobilenet_v1.c
@@ -47,23 +47,18 @@
 #endif
 }
 
-const iree_hal_executable_library_header_t **library_query(
-    iree_hal_executable_library_version_t max_version, void *reserved) {
+iree_hal_executable_library_query_fn_t library_query(void) {
 #if !defined(BUILD_EMITC)
-  return mobilenet_v1_bytecode_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &mobilenet_v1_bytecode_module_static_linked_llvm_library_query;
 #else
-  return mobilenet_v1_c_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &mobilenet_v1_c_module_static_linked_llvm_library_query;
 #endif
 }
 
 iree_status_t load_input_data(const MlModel *model, void **buffer,
-                              iree_byte_span_t **byte_span) {
-  byte_span[0] = malloc(sizeof(iree_byte_span_t));
-  *byte_span[0] = iree_make_byte_span(
+                              iree_const_byte_span_t **byte_span) {
+  byte_span[0] = malloc(sizeof(iree_const_byte_span_t));
+  *byte_span[0] = iree_make_const_byte_span(
       mobilenet_input, model->input_size_bytes[0] * model->input_length[0]);
   return iree_ok_status();
 }
diff --git a/samples/quant_model/CMakeLists.txt b/samples/quant_model/CMakeLists.txt
index ed825dd..d7316db 100644
--- a/samples/quant_model/CMakeLists.txt
+++ b/samples/quant_model/CMakeLists.txt
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Build the mlir bytecode modules with iree-translate. Note the last two flags
+# Build the mlir bytecode modules with iree-compile. Note the last two flags
 # are for RVV support.
 #-------------------------------------------------------------------------------
 
@@ -197,7 +197,8 @@
     iree::vm::bytecode_module
     samples::util::util
   LINKOPTS
-    "LINKER:--defsym=__stack_size__=100k"
+    "LINKER:--defsym=__itcm_length__=1M"
+    "LINKER:--defsym=__stack_size__=150k"
 )
 
 iree_cc_binary(
@@ -211,107 +212,113 @@
     ::mobilenet_v1_c_module_static_emitc
     samples::util::util
   LINKOPTS
-    "LINKER:--defsym=__stack_size__=100k"
-  COPTS
-    "-DBUILD_EMITC"
-)
-
-iree_cc_binary(
-  NAME
-    mobilenet_v2_bytecode_static
-  SRCS
-    "mobilenet_v2.c"
-  DEPS
-    ::mobilenet_quant_input_c
-    ::mobilenet_v2_bytecode_module_static
-    ::mobilenet_v2_bytecode_module_static_c
-    iree::vm::bytecode_module
-    samples::util::util
-  LINKOPTS
-  "LINKER:--defsym=__stack_size__=150k"
-)
-
-iree_cc_binary(
-  NAME
-    mobilenet_v2_emitc_static
-  SRCS
-    "mobilenet_v2.c"
-  DEPS
-    ::mobilenet_quant_input_c
-    ::mobilenet_v2_c_module_static_c
-    ::mobilenet_v2_c_module_static_emitc
-    samples::util::util
-  LINKOPTS
+    "LINKER:--defsym=__itcm_length__=1M"
     "LINKER:--defsym=__stack_size__=150k"
   COPTS
     "-DBUILD_EMITC"
 )
 
-iree_cc_binary(
-  NAME
-    person_detection_bytecode_static
-  SRCS
-    "person_detection.c"
-  DEPS
-    ::person_detection_bytecode_module_static
-    ::person_detection_bytecode_module_static_c
-    ::person_detection_quant_input_c
-    iree::vm::bytecode_module
-    samples::util::util
-  LINKOPTS
-    "LINKER:--defsym=__stack_size__=128k"
-)
+# TODO(lundong): Temporarily disable some models due to ITCM overflow
+#iree_cc_binary(
+#  NAME
+#    mobilenet_v2_bytecode_static
+#  SRCS
+#    "mobilenet_v2.c"
+#  DEPS
+#    ::mobilenet_quant_input_c
+#    ::mobilenet_v2_bytecode_module_static
+#    ::mobilenet_v2_bytecode_module_static_c
+#    iree::vm::bytecode_module
+#    samples::util::util
+#  LINKOPTS
+#    "LINKER:--defsym=__itcm_length__=1500K"
+#    "LINKER:--defsym=__stack_size__=150k"
+#)
 
-iree_cc_binary(
-  NAME
-    person_detection_emitc_static
-  SRCS
-    "person_detection.c"
-  DEPS
-    ::person_detection_c_module_static_c
-    ::person_detection_c_module_static_emitc
-    ::person_detection_quant_input_c
-    samples::util::util
-  LINKOPTS
-    "LINKER:--defsym=__stack_size__=128k"
-  COPTS
-    "-DBUILD_EMITC"
-)
+#iree_cc_binary(
+#  NAME
+#    mobilenet_v2_emitc_static
+#  SRCS
+#    "mobilenet_v2.c"
+#  DEPS
+#    ::mobilenet_quant_input_c
+#    ::mobilenet_v2_c_module_static_c
+#    ::mobilenet_v2_c_module_static_emitc
+#    samples::util::util
+#  LINKOPTS
+#    "LINKER:--defsym=__itcm_length__=1500K"
+#    "LINKER:--defsym=__stack_size__=150k"
+#  COPTS
+#    "-DBUILD_EMITC"
+#)
+
+#iree_cc_binary(
+#  NAME
+#    person_detection_bytecode_static
+#  SRCS
+#    "person_detection.c"
+#  DEPS
+#    ::person_detection_bytecode_module_static
+#    ::person_detection_bytecode_module_static_c
+#    ::person_detection_quant_input_c
+#    iree::vm::bytecode_module
+#    samples::util::util
+#  LINKOPTS
+#    "LINKER:--defsym=__itcm_length__=1600K"
+#    "LINKER:--defsym=__stack_size__=128k"
+#)
+
+#iree_cc_binary(
+#  NAME
+#    person_detection_emitc_static
+#  SRCS
+#    "person_detection.c"
+#  DEPS
+#    ::person_detection_c_module_static_c
+#    ::person_detection_c_module_static_emitc
+#    ::person_detection_quant_input_c
+#    samples::util::util
+#  LINKOPTS
+#    "LINKER:--defsym=__itcm_length__=1600K"
+#    "LINKER:--defsym=__stack_size__=128k"
+#  COPTS
+#    "-DBUILD_EMITC"
+#)
 
 if(NOT ${BUILD_INTERNAL_MODELS})
   return()
 endif()
 
-iree_cc_binary(
-  NAME
-    barcode_bytecode_static
-  SRCS
-    "barcode.c"
-  DEPS
-    ::barcode_bytecode_module_static
-    ::barcode_bytecode_module_static_c
-    iree::vm::bytecode_module
-    samples::util::util
-  LINKOPTS
-    "LINKER:--defsym=__itcm_length__=700k"
-    "LINKER:--defsym=__stack_size__=100k"
-)
+#iree_cc_binary(
+#  NAME
+#    barcode_bytecode_static
+#  SRCS
+#    "barcode.c"
+#  DEPS
+#    ::barcode_bytecode_module_static
+#    ::barcode_bytecode_module_static_c
+#    iree::vm::bytecode_module
+#    samples::util::util
+#  LINKOPTS
+#    "LINKER:--defsym=__itcm_length__=1500K"
+#    "LINKER:--defsym=__stack_size__=100k"
+#)
 
-iree_cc_binary(
-  NAME
-    barcode_emitc_static
-  SRCS
-    "barcode.c"
-  DEPS
-    ::barcode_c_module_static_c
-    ::barcode_c_module_static_emitc
-    samples::util::util
-  LINKOPTS
-    "LINKER:--defsym=__itcm_length__=700k"
-    "LINKER:--defsym=__stack_size__=100k"
-  COPTS
-    "-DBUILD_EMITC"
-)
+#iree_cc_binary(
+#  NAME
+#    barcode_emitc_static
+#  SRCS
+#    "barcode.c"
+#  DEPS
+#    ::barcode_c_module_static_c
+#    ::barcode_c_module_static_emitc
+#    samples::util::util
+#  LINKOPTS
+#    "LINKER:--defsym=__itcm_length__=1500K"
+#    "LINKER:--defsym=__stack_size__=100k"
+#  COPTS
+#    "-DBUILD_EMITC"
+#)
 
 iree_cc_binary(
   NAME
@@ -324,6 +331,7 @@
     iree::vm::bytecode_module
     samples::util::util
   LINKOPTS
+    "LINKER:--defsym=__itcm_length__=1M"
     "LINKER:--defsym=__stack_size__=100k"
 )
 
@@ -337,72 +345,77 @@
     ::daredevil_c_module_static_emitc
     samples::util::util
   LINKOPTS
+    "LINKER:--defsym=__itcm_length__=1M"
     "LINKER:--defsym=__stack_size__=100k"
   COPTS
     "-DBUILD_EMITC"
 )
 
-iree_cc_binary(
-  NAME
-    fssd_25_8bit_v2_bytecode_static
-  SRCS
-    "fssd_25_8bit_v2.c"
-  DEPS
-    ::fssd_quant_input_c
-    ::fssd_25_8bit_v2_bytecode_module_static
-    ::fssd_25_8bit_v2_bytecode_module_static_c
-    iree::vm::bytecode_module
-    samples::risp4ml::pipeline::pipeline
-    samples::util::util
-  LINKOPTS
-    "LINKER:--defsym=__stack_size__=100k"
-)
+#iree_cc_binary(
+#  NAME
+#    fssd_25_8bit_v2_bytecode_static
+#  SRCS
+#    "fssd_25_8bit_v2.c"
+#  DEPS
+#    ::fssd_quant_input_c
+#    ::fssd_25_8bit_v2_bytecode_module_static
+#    ::fssd_25_8bit_v2_bytecode_module_static_c
+#    iree::vm::bytecode_module
+#    samples::risp4ml::pipeline::pipeline
+#    samples::util::util
+#  LINKOPTS
+#    "LINKER:--defsym=__itcm_length__=1200K"
+#    "LINKER:--defsym=__stack_size__=100k"
+#)
 
-iree_cc_binary(
-  NAME
-    fssd_25_8bit_v2_emitc_static
-  SRCS
-    "fssd_25_8bit_v2.c"
-  DEPS
-    ::fssd_quant_input_c
-    ::fssd_25_8bit_v2_c_module_static_c
-    ::fssd_25_8bit_v2_c_module_static_emitc
-    samples::risp4ml::pipeline::pipeline
-    samples::util::util
-  LINKOPTS
-    "LINKER:--defsym=__stack_size__=100k"
-  COPTS
-    "-DBUILD_EMITC"
-)
+#iree_cc_binary(
+#  NAME
+#    fssd_25_8bit_v2_emitc_static
+#  SRCS
+#    "fssd_25_8bit_v2.c"
+#  DEPS
+#    ::fssd_quant_input_c
+#    ::fssd_25_8bit_v2_c_module_static_c
+#    ::fssd_25_8bit_v2_c_module_static_emitc
+#    samples::risp4ml::pipeline::pipeline
+#    samples::util::util
+#  LINKOPTS
+#    "LINKER:--defsym=__itcm_length__=1200K"
+#    "LINKER:--defsym=__stack_size__=100k"
+#  COPTS
+#    "-DBUILD_EMITC"
+#)
 
-iree_cc_binary(
-  NAME
-    scenenet_v2_bytecode_static
-  SRCS
-    "scenenet_v2.c"
-  DEPS
-    ::scenenet_v2_bytecode_module_static
-    ::scenenet_v2_bytecode_module_static_c
-    iree::vm::bytecode_module
-    samples::util::util
-  LINKOPTS
-    "LINKER:--defsym=__stack_size__=150k"
-)
+#iree_cc_binary(
+#  NAME
+#    scenenet_v2_bytecode_static
+#  SRCS
+#    "scenenet_v2.c"
+#  DEPS
+#    ::scenenet_v2_bytecode_module_static
+#    ::scenenet_v2_bytecode_module_static_c
+#    iree::vm::bytecode_module
+#    samples::util::util
+#  LINKOPTS
+#    "LINKER:--defsym=__itcm_length__=1500K"
+#    "LINKER:--defsym=__stack_size__=150k"
+#)
 
-iree_cc_binary(
-  NAME
-    scenenet_v2_emitc_static
-  SRCS
-    "scenenet_v2.c"
-  DEPS
-    ::scenenet_v2_c_module_static_c
-    ::scenenet_v2_c_module_static_emitc
-    samples::util::util
-  LINKOPTS
-    "LINKER:--defsym=__stack_size__=150k"
-  COPTS
-    "-DBUILD_EMITC"
-)
+#iree_cc_binary(
+#  NAME
+#    scenenet_v2_emitc_static
+#  SRCS
+#    "scenenet_v2.c"
+#  DEPS
+#    ::scenenet_v2_c_module_static_c
+#    ::scenenet_v2_c_module_static_emitc
+#    samples::util::util
+#  LINKOPTS
+#    "LINKER:--defsym=__itcm_length__=1500K"
+#    "LINKER:--defsym=__stack_size__=150k"
+#  COPTS
+#    "-DBUILD_EMITC"
+#)
 
 iree_cc_binary(
   NAME
@@ -415,6 +428,7 @@
     iree::vm::bytecode_module
     samples::util::util
   LINKOPTS
+    "LINKER:--defsym=__itcm_length__=1M"
     "LINKER:--defsym=__stack_size__=100k"
 )
 
@@ -428,6 +442,7 @@
     ::semantic_lift_c_module_static_emitc
     samples::util::util
   LINKOPTS
+    "LINKER:--defsym=__itcm_length__=1M"
     "LINKER:--defsym=__stack_size__=100k"
   COPTS
     "-DBUILD_EMITC"
diff --git a/samples/quant_model/barcode.c b/samples/quant_model/barcode.c
index 12cf54c..1eb8dd1 100644
--- a/samples/quant_model/barcode.c
+++ b/samples/quant_model/barcode.c
@@ -45,21 +45,16 @@
 #endif
 }
 
-const iree_hal_executable_library_header_t **library_query(
-    iree_hal_executable_library_version_t max_version, void *reserved) {
+iree_hal_executable_library_query_fn_t library_query(void) {
 #if !defined(BUILD_EMITC)
-  return barcode_bytecode_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &barcode_bytecode_module_static_linked_llvm_library_query;
 #else
-  return barcode_c_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &barcode_c_module_static_linked_llvm_library_query;
 #endif
 }
 
 iree_status_t load_input_data(const MlModel *model, void **buffer,
-                              iree_byte_span_t **byte_span) {
+                              iree_const_byte_span_t **byte_span) {
   iree_status_t result = alloc_input_buffer(model, buffer);
   // Populate initial value
   srand(768954);
@@ -68,8 +63,8 @@
       ((uint8_t *)*buffer)[i] = (uint8_t)rand();
     }
   }
-  byte_span[0] = malloc(sizeof(iree_byte_span_t));
-  *byte_span[0] = iree_make_byte_span(
+  byte_span[0] = malloc(sizeof(iree_const_byte_span_t));
+  *byte_span[0] = iree_make_const_byte_span(
       buffer[0], model->input_size_bytes[0] * model->input_length[0]);
   return result;
 }
diff --git a/samples/quant_model/barcode_test.txt b/samples/quant_model/barcode_test.txt
index 9557b0e..371abfd 100644
--- a/samples/quant_model/barcode_test.txt
+++ b/samples/quant_model/barcode_test.txt
@@ -1,3 +1,4 @@
 // RUN: ${TEST_RUNNER_CMD} ${OUT}/springbok_iree/samples/quant_model/barcode_bytecode_static
 // RUN: ${TEST_RUNNER_CMD} ${OUT}/springbok_iree/samples/quant_model/barcode_emitc_static
 // REQUIRES: internal
+// XFAIL: *
diff --git a/samples/quant_model/daredevil.c b/samples/quant_model/daredevil.c
index 86ff0fb..25212d4 100644
--- a/samples/quant_model/daredevil.c
+++ b/samples/quant_model/daredevil.c
@@ -43,21 +43,16 @@
 #endif
 }
 
-const iree_hal_executable_library_header_t **library_query(
-    iree_hal_executable_library_version_t max_version, void *reserved) {
+iree_hal_executable_library_query_fn_t library_query(void) {
 #if !defined(BUILD_EMITC)
-  return daredevil_bytecode_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &daredevil_bytecode_module_static_linked_llvm_library_query;
 #else
-  return daredevil_c_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &daredevil_c_module_static_linked_llvm_library_query;
 #endif
 }
 
 iree_status_t load_input_data(const MlModel *model, void **buffer,
-                              iree_byte_span_t **byte_span) {
+                              iree_const_byte_span_t **byte_span) {
   iree_status_t result = alloc_input_buffer(model, buffer);
   // Populate initial value
   srand(3689964);
@@ -66,8 +61,8 @@
       ((uint8_t *)*buffer)[i] = (uint8_t)rand();
     }
   }
-  byte_span[0] = malloc(sizeof(iree_byte_span_t));
-  *byte_span[0] = iree_make_byte_span(
+  byte_span[0] = malloc(sizeof(iree_const_byte_span_t));
+  *byte_span[0] = iree_make_const_byte_span(
       buffer[0], model->input_size_bytes[0] * model->input_length[0]);
   return result;
 }
diff --git a/samples/quant_model/fssd_25_8bit_v2.c b/samples/quant_model/fssd_25_8bit_v2.c
index 0ba243e..21613b5 100644
--- a/samples/quant_model/fssd_25_8bit_v2.c
+++ b/samples/quant_model/fssd_25_8bit_v2.c
@@ -46,21 +46,16 @@
 #endif
 }
 
-const iree_hal_executable_library_header_t **library_query(
-    iree_hal_executable_library_version_t max_version, void *reserved) {
+iree_hal_executable_library_query_fn_t library_query(void) {
 #if !defined(BUILD_EMITC)
-  return fssd_25_8bit_v2_bytecode_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &fssd_25_8bit_v2_bytecode_module_static_linked_llvm_library_query;
 #else
-  return fssd_25_8bit_v2_c_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &fssd_25_8bit_v2_c_module_static_linked_llvm_library_query;
 #endif
 }
 
 iree_status_t load_input_data(const MlModel *model, void **buffer,
-                              iree_byte_span_t **byte_span) {
+                              iree_const_byte_span_t **byte_span) {
   iree_status_t result = alloc_input_buffer(model, buffer);
 
   ImageU8 input = {
@@ -69,8 +64,8 @@
       .width = 320, .height = 320, .num_channels = 3, .data = buffer[0]};
   isp_pipeline(&input, &output);
 
-  byte_span[0] = malloc(sizeof(iree_byte_span_t));
-  *byte_span[0] = iree_make_byte_span(
+  byte_span[0] = malloc(sizeof(iree_const_byte_span_t));
+  *byte_span[0] = iree_make_const_byte_span(
       buffer[0], model->input_size_bytes[0] * model->input_length[0]);
   return result;
 }
diff --git a/samples/quant_model/fssd_test.txt b/samples/quant_model/fssd_test.txt
index 42f6a81..90ca377 100644
--- a/samples/quant_model/fssd_test.txt
+++ b/samples/quant_model/fssd_test.txt
@@ -1,3 +1,4 @@
 // RUN: ${TEST_RUNNER_CMD} ${OUT}/springbok_iree/samples/quant_model/fssd_25_8bit_v2_bytecode_static
 // RUN: ${TEST_RUNNER_CMD} ${OUT}/springbok_iree/samples/quant_model/fssd_25_8bit_v2_emitc_static
 // REQUIRES: internal
+// XFAIL: *
diff --git a/samples/quant_model/mobilenet_v1.c b/samples/quant_model/mobilenet_v1.c
index 248d81f..b4f7b34 100644
--- a/samples/quant_model/mobilenet_v1.c
+++ b/samples/quant_model/mobilenet_v1.c
@@ -47,25 +47,20 @@
 #endif
 }
 
-const iree_hal_executable_library_header_t **library_query(
-    iree_hal_executable_library_version_t max_version, void *reserved) {
+iree_hal_executable_library_query_fn_t library_query(void) {
 #if !defined(BUILD_EMITC)
-  return mobilenet_v1_bytecode_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &mobilenet_v1_bytecode_module_static_linked_llvm_library_query;
 #else
-  return mobilenet_v1_c_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &mobilenet_v1_c_module_static_linked_llvm_library_query;
 #endif
 }
 
 iree_status_t load_input_data(const MlModel *model, void **buffer,
-                              iree_byte_span_t **byte_span) {
-  byte_span[0] = malloc(sizeof(iree_byte_span_t));
-  *byte_span[0] =
-      iree_make_byte_span(mobilenet_quant_input,
-                          model->input_size_bytes[0] * model->input_length[0]);
+                              iree_const_byte_span_t **byte_span) {
+  byte_span[0] = malloc(sizeof(iree_const_byte_span_t));
+  *byte_span[0] = iree_make_const_byte_span(
+      mobilenet_quant_input,
+      model->input_size_bytes[0] * model->input_length[0]);
   return iree_ok_status();
 }
 
diff --git a/samples/quant_model/mobilenet_v2.c b/samples/quant_model/mobilenet_v2.c
index 711937d..b1abe12 100644
--- a/samples/quant_model/mobilenet_v2.c
+++ b/samples/quant_model/mobilenet_v2.c
@@ -47,25 +47,20 @@
 #endif
 }
 
-const iree_hal_executable_library_header_t **library_query(
-    iree_hal_executable_library_version_t max_version, void *reserved) {
+iree_hal_executable_library_query_fn_t library_query(void) {
 #if !defined(BUILD_EMITC)
-  return mobilenet_v2_bytecode_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &mobilenet_v2_bytecode_module_static_linked_llvm_library_query;
 #else
-  return mobilenet_v2_c_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &mobilenet_v2_c_module_static_linked_llvm_library_query;
 #endif
 }
 
 iree_status_t load_input_data(const MlModel *model, void **buffer,
-                              iree_byte_span_t **byte_span) {
-  byte_span[0] = malloc(sizeof(iree_byte_span_t));
-  *byte_span[0] =
-      iree_make_byte_span(mobilenet_quant_input,
-                          model->input_size_bytes[0] * model->input_length[0]);
+                              iree_const_byte_span_t **byte_span) {
+  byte_span[0] = malloc(sizeof(iree_const_byte_span_t));
+  *byte_span[0] = iree_make_const_byte_span(
+      mobilenet_quant_input,
+      model->input_size_bytes[0] * model->input_length[0]);
   return iree_ok_status();
 }
 
diff --git a/samples/quant_model/mobilenet_v2_bytecode_static_test.txt b/samples/quant_model/mobilenet_v2_bytecode_static_test.txt
index fd3b156..a1179ef 100644
--- a/samples/quant_model/mobilenet_v2_bytecode_static_test.txt
+++ b/samples/quant_model/mobilenet_v2_bytecode_static_test.txt
@@ -1,3 +1,4 @@
 // RUN: ${TEST_RUNNER_CMD} ${OUT}/springbok_iree/samples/quant_model/mobilenet_v2_bytecode_static 2>&1 | tee %t
 // RUN: cat %t | FileCheck %s
 // CHECK: {{Image prediction result is: id: 210}}
+// XFAIL: *
diff --git a/samples/quant_model/mobilenet_v2_emitc_static_text.txt b/samples/quant_model/mobilenet_v2_emitc_static_text.txt
index 1824224..668458d 100644
--- a/samples/quant_model/mobilenet_v2_emitc_static_text.txt
+++ b/samples/quant_model/mobilenet_v2_emitc_static_text.txt
@@ -1,3 +1,4 @@
 // RUN: ${TEST_RUNNER_CMD} ${OUT}/springbok_iree/samples/quant_model/mobilenet_v2_emitc_static 2>&1 | tee %t
 // RUN: cat %t | FileCheck %s
 // CHECK: {{Image prediction result is: id: 210}}
+// XFAIL: *
diff --git a/samples/quant_model/person_detection.c b/samples/quant_model/person_detection.c
index 1ef7f56..b3b2e5a 100644
--- a/samples/quant_model/person_detection.c
+++ b/samples/quant_model/person_detection.c
@@ -47,25 +47,20 @@
 #endif
 }
 
-const iree_hal_executable_library_header_t **library_query(
-    iree_hal_executable_library_version_t max_version, void *reserved) {
+iree_hal_executable_library_query_fn_t library_query(void) {
 #if !defined(BUILD_EMITC)
-  return person_detection_bytecode_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &person_detection_bytecode_module_static_linked_llvm_library_query;
 #else
-  return person_detection_c_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &person_detection_c_module_static_linked_llvm_library_query;
 #endif
 }
 
 iree_status_t load_input_data(const MlModel *model, void **buffer,
-                              iree_byte_span_t **byte_span) {
-  byte_span[0] = malloc(sizeof(iree_byte_span_t));
-  *byte_span[0] =
-      iree_make_byte_span(person_detection_quant_input,
-                          model->input_size_bytes[0] * model->input_length[0]);
+                              iree_const_byte_span_t **byte_span) {
+  byte_span[0] = malloc(sizeof(iree_const_byte_span_t));
+  *byte_span[0] = iree_make_const_byte_span(
+      person_detection_quant_input,
+      model->input_size_bytes[0] * model->input_length[0]);
   return iree_ok_status();
 }
 
diff --git a/samples/quant_model/person_detection_bytecode_static_test.txt b/samples/quant_model/person_detection_bytecode_static_test.txt
index f278d1d..31e94ef 100644
--- a/samples/quant_model/person_detection_bytecode_static_test.txt
+++ b/samples/quant_model/person_detection_bytecode_static_test.txt
@@ -1,3 +1,4 @@
 // RUN: ${TEST_RUNNER_CMD} ${OUT}/springbok_iree/samples/quant_model/person_detection_bytecode_static 2>&1 | tee %t
 // RUN: cat %t | FileCheck %s
 // CHECK: {{Non-person Score: -113; Person Score: 113}}
+// XFAIL: *
diff --git a/samples/quant_model/person_detection_emitc_static_test.txt b/samples/quant_model/person_detection_emitc_static_test.txt
index 38b4bc4..28c8946 100644
--- a/samples/quant_model/person_detection_emitc_static_test.txt
+++ b/samples/quant_model/person_detection_emitc_static_test.txt
@@ -1,3 +1,4 @@
 // RUN: ${TEST_RUNNER_CMD} ${OUT}/springbok_iree/samples/quant_model/person_detection_emitc_static 2>&1 | tee %t
 // RUN: cat %t | FileCheck %s
 // CHECK: {{Non-person Score: -113; Person Score: 113}}
+// XFAIL: *
diff --git a/samples/quant_model/scenenet_test.txt b/samples/quant_model/scenenet_test.txt
index 1be1d7f..164005d 100644
--- a/samples/quant_model/scenenet_test.txt
+++ b/samples/quant_model/scenenet_test.txt
@@ -1,3 +1,4 @@
 // RUN: ${TEST_RUNNER_CMD} ${OUT}/springbok_iree/samples/quant_model/scenenet_v2_bytecode_static
 // RUN: ${TEST_RUNNER_CMD} ${OUT}/springbok_iree/samples/quant_model/scenenet_v2_emitc_static
 // REQUIRES: internal
+// XFAIL: *
diff --git a/samples/quant_model/scenenet_v2.c b/samples/quant_model/scenenet_v2.c
index ac5f01f..fa0783c 100644
--- a/samples/quant_model/scenenet_v2.c
+++ b/samples/quant_model/scenenet_v2.c
@@ -43,21 +43,16 @@
 #endif
 }
 
-const iree_hal_executable_library_header_t **library_query(
-    iree_hal_executable_library_version_t max_version, void *reserved) {
+iree_hal_executable_library_query_fn_t library_query(void) {
 #if !defined(BUILD_EMITC)
-  return scenenet_v2_bytecode_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &scenenet_v2_bytecode_module_static_linked_llvm_library_query;
 #else
-  return scenenet_v2_c_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &scenenet_v2_c_module_static_linked_llvm_library_query;
 #endif
 }
 
 iree_status_t load_input_data(const MlModel *model, void **buffer,
-                              iree_byte_span_t **byte_span) {
+                              iree_const_byte_span_t **byte_span) {
   iree_status_t result = alloc_input_buffer(model, buffer);
   // Populate initial value
   srand(55555555);
@@ -66,8 +61,8 @@
       ((uint8_t *)*buffer)[i] = (uint8_t)rand();
     }
   }
-  byte_span[0] = malloc(sizeof(iree_byte_span_t));
-  *byte_span[0] = iree_make_byte_span(
+  byte_span[0] = malloc(sizeof(iree_const_byte_span_t));
+  *byte_span[0] = iree_make_const_byte_span(
       buffer[0], model->input_size_bytes[0] * model->input_length[0]);
   return result;
 }
diff --git a/samples/quant_model/semantic_lift.c b/samples/quant_model/semantic_lift.c
index 5abaff2..b6d8477 100644
--- a/samples/quant_model/semantic_lift.c
+++ b/samples/quant_model/semantic_lift.c
@@ -43,21 +43,16 @@
 #endif
 }
 
-const iree_hal_executable_library_header_t **library_query(
-    iree_hal_executable_library_version_t max_version, void *reserved) {
+iree_hal_executable_library_query_fn_t library_query(void) {
 #if !defined(BUILD_EMITC)
-  return semantic_lift_bytecode_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &semantic_lift_bytecode_module_static_linked_llvm_library_query;
 #else
-  return semantic_lift_c_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &semantic_lift_c_module_static_linked_llvm_library_query;
 #endif
 }
 
 iree_status_t load_input_data(const MlModel *model, void **buffer,
-                              iree_byte_span_t **byte_span) {
+                              iree_const_byte_span_t **byte_span) {
   iree_status_t result = alloc_input_buffer(model, buffer);
   // Populate initial value
   srand(66666666);
@@ -66,8 +61,8 @@
       ((uint8_t *)*buffer)[i] = (uint8_t)rand();
     }
   }
-  byte_span[0] = malloc(sizeof(iree_byte_span_t));
-  *byte_span[0] = iree_make_byte_span(
+  byte_span[0] = malloc(sizeof(iree_const_byte_span_t));
+  *byte_span[0] = iree_make_const_byte_span(
       buffer[0], model->input_size_bytes[0] * model->input_length[0]);
   return result;
 }
diff --git a/samples/quant_model/voice_commands.c b/samples/quant_model/voice_commands.c
index e7bdf99..94a68ab 100644
--- a/samples/quant_model/voice_commands.c
+++ b/samples/quant_model/voice_commands.c
@@ -43,21 +43,16 @@
 #endif
 }
 
-const iree_hal_executable_library_header_t **library_query(
-    iree_hal_executable_library_version_t max_version, void *reserved) {
+iree_hal_executable_library_query_fn_t library_query(void) {
 #if !defined(BUILD_EMITC)
-  return voice_commands_bytecode_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &voice_commands_bytecode_module_static_linked_llvm_library_query;
 #else
-  return voice_commands_c_module_static_linked_llvm_library_query(
-      max_version,
-      /*reserved=*/reserved);
+  return &voice_commands_c_module_static_linked_llvm_library_query;
 #endif
 }
 
 iree_status_t load_input_data(const MlModel *model, void **buffer,
-                              iree_byte_span_t **byte_span) {
+                              iree_const_byte_span_t **byte_span) {
   iree_status_t result = alloc_input_buffer(model, buffer);
   // Populate initial value
   srand(77777777);
@@ -66,8 +61,8 @@
       ((uint8_t *)*buffer)[i] = (uint8_t)rand();
     }
   }
-  byte_span[0] = malloc(sizeof(iree_byte_span_t));
-  *byte_span[0] = iree_make_byte_span(
+  byte_span[0] = malloc(sizeof(iree_const_byte_span_t));
+  *byte_span[0] = iree_make_const_byte_span(
       buffer[0], model->input_size_bytes[0] * model->input_length[0]);
   return result;
 }
diff --git a/samples/simple_vec_mul/CMakeLists.txt b/samples/simple_vec_mul/CMakeLists.txt
index 661032a..17bbc2f 100644
--- a/samples/simple_vec_mul/CMakeLists.txt
+++ b/samples/simple_vec_mul/CMakeLists.txt
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Build the mlir bytecode modules with iree-translate. Note the last two flags
+# Build the mlir bytecode modules with iree-compile. Note the last two flags
 # are for RVV support.
 # https://github.com/llvm/llvm-project/blob/0eeab8b/llvm/lib/Target/RISCV/RISCVSubtarget.cpp#L30-L51
 #-------------------------------------------------------------------------------
diff --git a/samples/simple_vec_mul/float_vec.c b/samples/simple_vec_mul/float_vec.c
index d9c53dd..a890031 100644
--- a/samples/simple_vec_mul/float_vec.c
+++ b/samples/simple_vec_mul/float_vec.c
@@ -39,14 +39,12 @@
 #endif
 }
 
-const iree_hal_executable_library_header_t **library_query(
-    iree_hal_executable_library_version_t max_version, void *reserved) {
-  return simple_mul_dispatch_0_library_query(max_version,
-                                             /*reserved=*/reserved);
+iree_hal_executable_library_query_fn_t library_query(void) {
+  return &simple_mul_dispatch_0_library_query;
 }
 
 iree_status_t load_input_data(const MlModel *model, void **buffer,
-                              iree_byte_span_t **byte_span) {
+                              iree_const_byte_span_t **byte_span) {
   iree_status_t result = alloc_input_buffer(model, buffer);
   // Populate initial values
   // arg0 = 0, 1/4, 1/2, 3/4... 1023/4
@@ -58,8 +56,8 @@
     }
   }
   for (int i = 0; i < model->num_input; ++i) {
-    byte_span[i] = malloc(sizeof(iree_byte_span_t));
-    *byte_span[i] = iree_make_byte_span(
+    byte_span[i] = malloc(sizeof(iree_const_byte_span_t));
+    *byte_span[i] = iree_make_const_byte_span(
         buffer[i], model->input_size_bytes[i] * model->input_length[i]);
   }
   return result;
diff --git a/samples/simple_vec_mul/int_vec.c b/samples/simple_vec_mul/int_vec.c
index 01019e3..61ab705 100644
--- a/samples/simple_vec_mul/int_vec.c
+++ b/samples/simple_vec_mul/int_vec.c
@@ -40,14 +40,12 @@
 #endif
 }
 
-const iree_hal_executable_library_header_t **library_query(
-    iree_hal_executable_library_version_t max_version, void *reserved) {
-  return simple_mul_dispatch_0_library_query(max_version,
-                                             /*reserved=*/reserved);
+iree_hal_executable_library_query_fn_t library_query(void) {
+  return &simple_mul_dispatch_0_library_query;
 }
 
 iree_status_t load_input_data(const MlModel *model, void **buffer,
-                              iree_byte_span_t **byte_span) {
+                              iree_const_byte_span_t **byte_span) {
   iree_status_t result = alloc_input_buffer(model, buffer);
   // Populate initial values
   // arg0 = 0, 0, 1, 1,..., 511
@@ -59,8 +57,8 @@
     }
   }
   for (int i = 0; i < model->num_input; ++i) {
-    byte_span[i] = malloc(sizeof(iree_byte_span_t));
-    *byte_span[i] = iree_make_byte_span(
+    byte_span[i] = malloc(sizeof(iree_const_byte_span_t));
+    *byte_span[i] = iree_make_const_byte_span(
         buffer[i], model->input_size_bytes[i] * model->input_length[i]);
   }
   return result;
diff --git a/samples/util/alloc.c b/samples/util/alloc.c
index 08cf339..973b70a 100644
--- a/samples/util/alloc.c
+++ b/samples/util/alloc.c
@@ -1,14 +1,11 @@
 #include "samples/util/alloc.h"
 
-iree_status_t alloc_input_buffer(const MlModel *model,
-                                               void **buffer) {
+iree_status_t alloc_input_buffer(const MlModel *model, void **buffer) {
   iree_status_t result = iree_ok_status();
   for (int i = 0; i < model->num_input; ++i) {
     if (iree_status_is_ok(result)) {
-      buffer[i] =
-          iree_aligned_alloc(
-              sizeof(uint32_t),
-              model->input_size_bytes[i] * model->input_length[i]);
+      buffer[i] = aligned_alloc(sizeof(uint32_t), model->input_size_bytes[i] *
+                                                      model->input_length[i]);
       if (buffer[i] == NULL) {
         result = iree_make_status(IREE_STATUS_RESOURCE_EXHAUSTED);
       }
diff --git a/samples/util/model_api.h b/samples/util/model_api.h
index 1df0c9c..18f7a2a 100644
--- a/samples/util/model_api.h
+++ b/samples/util/model_api.h
@@ -30,13 +30,12 @@
 } MlModel;
 
 typedef struct {
-  void* result;
+  void *result;
   uint32_t len;
 } MlOutput;
 
 // Load the statically embedded library
-const iree_hal_executable_library_header_t **library_query(
-    iree_hal_executable_library_version_t max_version, void *reserved);
+iree_hal_executable_library_query_fn_t library_query(void);
 
 // Function to create the bytecode or C module.
 iree_status_t create_module(iree_vm_module_t **module);
@@ -45,13 +44,13 @@
 // and prepare the data. It can be loaded from a embedded image binary, a
 // randomly generated stream, or a pointer from the sensor/ISP output.
 iree_status_t load_input_data(const MlModel *model, void **buffer,
-                              iree_byte_span_t **byte_span);
+                              iree_const_byte_span_t **byte_span);
 
 // Process the ML execution output into the final data to be sent to the
 // host. The final format is model dependent, so the address and size
 // are returned via `output.`
 iree_status_t process_output(const MlModel *model,
-                              iree_hal_buffer_mapping_t *buffers,
-                              MlOutput *output);
+                             iree_hal_buffer_mapping_t *buffers,
+                             MlOutput *output);
 
 #endif  // SW_VEC_IREE_SAMPLES_UTIL_MODEL_API_H_
diff --git a/samples/util/util.c b/samples/util/util.c
index 82c02c5..16dd471 100644
--- a/samples/util/util.c
+++ b/samples/util/util.c
@@ -23,7 +23,7 @@
 
   // Prepare the input buffer, and populate the initial value.
   // The input buffer must be released by the caller.
-  iree_byte_span_t *byte_span[MAX_MODEL_INPUT_NUM] = {NULL};
+  iree_const_byte_span_t *byte_span[MAX_MODEL_INPUT_NUM] = {NULL};
   result = load_input_data(model, arg_buffers, byte_span);
 
   // Wrap buffers in shaped buffer views.
@@ -34,14 +34,14 @@
       .type =
           IREE_HAL_MEMORY_TYPE_HOST_LOCAL | IREE_HAL_MEMORY_TYPE_DEVICE_VISIBLE,
       .access = IREE_HAL_MEMORY_ACCESS_READ,
-      .usage = IREE_HAL_BUFFER_USAGE_ALL};
+      .usage = IREE_HAL_BUFFER_USAGE_DISPATCH | IREE_HAL_BUFFER_USAGE_TRANSFER};
   for (int i = 0; i < model->num_input; ++i) {
     if (iree_status_is_ok(result)) {
-      result = iree_hal_buffer_view_wrap_or_clone_heap_buffer(
+      result = iree_hal_buffer_view_allocate_buffer(
           iree_hal_device_allocator(device), model->input_shape[i],
           model->num_input_dim[i], model->hal_element_type,
           IREE_HAL_ENCODING_TYPE_DENSE_ROW_MAJOR, buffer_params, *byte_span[i],
-          iree_allocator_null(), &(arg_buffer_views[i]));
+          &(arg_buffer_views[i]));
     }
     if (byte_span[i] != NULL) {
       free(byte_span[i]);
@@ -176,7 +176,7 @@
   iree_vm_list_release(outputs);
   for (int i = 0; i < model->num_input; ++i) {
     if (arg_buffers[i] != NULL) {
-      iree_aligned_free(arg_buffers[i]);
+      free(arg_buffers[i]);
     }
   }
   iree_vm_context_release(context);