sw:vec_iree: LSC: Move utility libraries out of samples/

Update the code structure so the utility libraries are not behind
`samples/` directory.

clang-format and cpplint cleanup to comply with preupload checks.

Change-Id: I38ee55ecbb0464be4484d99f766a309c2e24000b
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ce382f2..314fda5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,6 +96,11 @@
 link_libraries(m)
 
 # Add the included directory here.
+add_subdirectory(audio_prep)
+add_subdirectory(device)
+add_subdirectory(model_util)
+add_subdirectory(risp4ml)
+
 add_subdirectory(samples)
 
 # Add pigweed support
diff --git a/README.md b/README.md
index a9542fa..d352caa 100644
--- a/README.md
+++ b/README.md
@@ -18,15 +18,15 @@
 
 ## Code structure
 
+* audio_prep: Audio preprocessing libarary
 * build_tools: Utility scripts for the project
 * cmake: CMake Macros for the project
+* device: Device HAL driver library
+* model_util: Runtime utility library for model execution
 * native_log: BSP support for the Linux userspace emulation
+* risp4ml: Vision preprocessing library (Reduced ISP for ML)
 * samples: Codegen and execution of ML models based on IREE
-  * audio_prep: Audio preprocessing libarary
-  * device: Device HAL driver library
-  * risp4ml: Vision preprocessing library (Reduced ISP for ML)
   * simple_vec_mul: Point-wise vector multiplication examples
-  * util: Runtime utility library for model execution
 
 ## Build the project
 
diff --git a/samples/audio_prep/CMakeLists.txt b/audio_prep/CMakeLists.txt
similarity index 100%
rename from samples/audio_prep/CMakeLists.txt
rename to audio_prep/CMakeLists.txt
diff --git a/samples/audio_prep/mfcc.c b/audio_prep/mfcc.c
similarity index 98%
rename from samples/audio_prep/mfcc.c
rename to audio_prep/mfcc.c
index b0f6334..22bf6b8 100644
--- a/samples/audio_prep/mfcc.c
+++ b/audio_prep/mfcc.c
@@ -16,13 +16,14 @@
 
 // Audio preprocessing: MLCC feature extraction
 
+#include "audio_prep/mfcc.h"
+
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "samples/audio_prep/mfcc.h"
-#include "samples/audio_prep/util.h"
+#include "audio_prep/util.h"
 
 #ifdef MFCC_WITH_RVV
 #include <riscv_vector.h>
diff --git a/samples/audio_prep/mfcc.h b/audio_prep/mfcc.h
similarity index 90%
rename from samples/audio_prep/mfcc.h
rename to audio_prep/mfcc.h
index 97cbab6..7329df7 100644
--- a/samples/audio_prep/mfcc.h
+++ b/audio_prep/mfcc.h
@@ -14,8 +14,10 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_AUDIO_PREP_MFCC_H_
-#define SAMPLES_AUDIO_PREP_MFCC_H_
+#ifndef AUDIO_PREP_MFCC_H_
+#define AUDIO_PREP_MFCC_H_
+
+#include <stdint.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -41,4 +43,4 @@
 }  // extern "C"
 #endif  // __cplusplus
 
-#endif  // SAMPLES_AUDIO_PREP_MFCC_H_
+#endif  // AUDIO_PREP_MFCC_H_
diff --git a/samples/audio_prep/mfcc_test.cc b/audio_prep/mfcc_test.cc
similarity index 98%
rename from samples/audio_prep/mfcc_test.cc
rename to audio_prep/mfcc_test.cc
index f39f68e..590d46a 100644
--- a/samples/audio_prep/mfcc_test.cc
+++ b/audio_prep/mfcc_test.cc
@@ -12,8 +12,9 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+#include "audio_prep/mfcc.h"
+
 #include "pw_unit_test/framework.h"
-#include "samples/audio_prep/mfcc.h"
 
 static MfccParams golden_params = {.num_frames = 3,
                                    .num_mel_bins = 10,
diff --git a/samples/audio_prep/mfcc_test.run b/audio_prep/mfcc_test.run
similarity index 100%
rename from samples/audio_prep/mfcc_test.run
rename to audio_prep/mfcc_test.run
diff --git a/samples/audio_prep/util.c b/audio_prep/util.c
similarity index 98%
rename from samples/audio_prep/util.c
rename to audio_prep/util.c
index 0b3ffad..4fa7e96 100644
--- a/samples/audio_prep/util.c
+++ b/audio_prep/util.c
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-#include <math.h>
+#include "audio_prep/util.h"
 
-#include "samples/audio_prep/util.h"
+#include <math.h>
 
 #ifndef M_SQRT2
 #define M_SQRT2 1.41421356237309504880
diff --git a/samples/audio_prep/util.h b/audio_prep/util.h
similarity index 92%
rename from samples/audio_prep/util.h
rename to audio_prep/util.h
index ade1610..57ac24e 100644
--- a/samples/audio_prep/util.h
+++ b/audio_prep/util.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_AUDIO_PREP_UTIL_H_
-#define SAMPLES_AUDIO_PREP_UTIL_H_
+#ifndef AUDIO_PREP_UTIL_H_
+#define AUDIO_PREP_UTIL_H_
 
 #ifndef M_PI
 #define M_PI 3.14159265358979323846
@@ -45,4 +45,4 @@
  *---------------------------------------------------------------------------*/
 void rfft(float* x, int m);
 
-#endif  // SAMPLES_AUDIO_PREP_UTIL_H_
+#endif  // AUDIO_PREP_UTIL_H_
diff --git a/samples/device/CMakeLists.txt b/device/CMakeLists.txt
similarity index 100%
rename from samples/device/CMakeLists.txt
rename to device/CMakeLists.txt
diff --git a/samples/device/device.h b/device/device.h
similarity index 90%
rename from samples/device/device.h
rename to device/device.h
index ada1330..cfd172d 100644
--- a/samples/device/device.h
+++ b/device/device.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_DEVICE_DEVICE_H_
-#define SAMPLES_DEVICE_DEVICE_H_
+#ifndef DEVICE_DEVICE_H_
+#define DEVICE_DEVICE_H_
 
 #include "iree/base/api.h"
 #include "iree/hal/api.h"
@@ -26,4 +26,4 @@
 iree_status_t create_sample_device(iree_allocator_t host_allocator,
                                    iree_hal_device_t** out_device);
 
-#endif  // SAMPLES_DEVICE_DEVICE_H_
+#endif  // DEVICE_DEVICE_H_
diff --git a/samples/device/device_static_loader.c b/device/device_static_loader.c
similarity index 93%
rename from samples/device/device_static_loader.c
rename to device/device_static_loader.c
index 0aabab2..22c8f36 100644
--- a/samples/device/device_static_loader.c
+++ b/device/device_static_loader.c
@@ -16,17 +16,17 @@
 
 // Static library loading in IREE.
 
-#include "iree/hal/local/loaders/static_library_loader.h"
+#include "device/device.h"
 #include "iree/hal/drivers/local_sync/sync_device.h"
+#include "iree/hal/local/loaders/static_library_loader.h"
 #include "iree/modules/hal/module.h"
-#include "samples/device/device.h"
-#include "samples/util/model_api.h"
+#include "model_util/model_api.h"
 
 // A function to create the HAL device from the different backend targets.
 // The HAL device is returned based on the implementation, and it must be
 // released by the caller.
 iree_status_t create_sample_device(iree_allocator_t host_allocator,
-                                               iree_hal_device_t** out_device) {
+                                   iree_hal_device_t** out_device) {
   iree_status_t status = iree_ok_status();
 
   // Set paramters for the device created in the next step.
diff --git a/samples/util/CMakeLists.txt b/model_util/CMakeLists.txt
similarity index 90%
rename from samples/util/CMakeLists.txt
rename to model_util/CMakeLists.txt
index 53ce441..40c7118 100644
--- a/samples/util/CMakeLists.txt
+++ b/model_util/CMakeLists.txt
@@ -7,6 +7,7 @@
     "util.c"
   DEPS
     ::alloc
+    device::device_static_loader
     iree::base
     iree::hal
     iree::hal::local
@@ -15,7 +16,6 @@
     iree::modules::hal
     iree::vm
     iree::vm::shims_emitc
-    samples::device::device_static_loader
 )
 
 iree_cc_library(
diff --git a/samples/util/alloc.c b/model_util/alloc.c
similarity index 96%
rename from samples/util/alloc.c
rename to model_util/alloc.c
index 50bc203..b7017c5 100644
--- a/samples/util/alloc.c
+++ b/model_util/alloc.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "samples/util/alloc.h"
+#include "model_util/alloc.h"
 
 iree_status_t alloc_input_buffer(const MlModel *model, void **buffer) {
   iree_status_t result = iree_ok_status();
diff --git a/samples/util/alloc.h b/model_util/alloc.h
similarity index 74%
rename from samples/util/alloc.h
rename to model_util/alloc.h
index c92948d..a85b643 100644
--- a/samples/util/alloc.h
+++ b/model_util/alloc.h
@@ -14,15 +14,14 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_UTIL_ALLOC_H_
-#define SAMPLES_UTIL_ALLOC_H_
+#ifndef MODEL_UTIL_ALLOC_H_
+#define MODEL_UTIL_ALLOC_H_
 
 #include "iree/base/api.h"
-#include "samples/util/model_api.h"
+#include "model_util/model_api.h"
 
 // Allocate the input buffer w.r.t the model config.
 // The buffer must be released by the external caller.
-iree_status_t alloc_input_buffer(const MlModel *model,
-                                               void **buffer);
+iree_status_t alloc_input_buffer(const MlModel *model, void **buffer);
 
-#endif  // SAMPLES_UTIL_ALLOC_H_
+#endif  // MODEL_UTIL_ALLOC_H_
diff --git a/samples/util/model_api.h b/model_util/model_api.h
similarity index 95%
rename from samples/util/model_api.h
rename to model_util/model_api.h
index 110662d..bba7811 100644
--- a/samples/util/model_api.h
+++ b/model_util/model_api.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_UTIL_MODEL_API_H_
-#define SAMPLES_UTIL_MODEL_API_H_
+#ifndef MODEL_UTIL_MODEL_API_H_
+#define MODEL_UTIL_MODEL_API_H_
 
 // Define ML model configuration and model-specific utility APIs.
 
@@ -69,4 +69,4 @@
                              iree_hal_buffer_mapping_t *buffers,
                              MlOutput *output);
 
-#endif  // SAMPLES_UTIL_MODEL_API_H_
+#endif  // MODEL_UTIL_MODEL_API_H_
diff --git a/samples/util/util.c b/model_util/util.c
similarity index 95%
rename from samples/util/util.c
rename to model_util/util.c
index a031dba..2deb726 100644
--- a/samples/util/util.c
+++ b/model_util/util.c
@@ -16,17 +16,17 @@
 
 // An example based on iree/samples/simple_embedding.
 
-#include "samples/util/util.h"
+#include "model_util/util.h"
 
 #include <springbok.h>
 #include <stdio.h>
 
+#include "device/device.h"
 #include "iree/base/api.h"
 #include "iree/hal/api.h"
 #include "iree/modules/hal/module.h"
 #include "iree/vm/api.h"
 #include "iree/vm/bytecode_module.h"
-#include "samples/device/device.h"
 
 extern const MlModel kModel;
 
@@ -169,9 +169,11 @@
 
     if (iree_status_is_ok(result)) {
       if (index_output > model->num_output ||
-            mapped_memories[index_output].contents.data_length / model->output_size_bytes !=
-            model->output_length[index_output]) {
-        result = iree_make_status(IREE_STATUS_UNKNOWN, "output length mismatches");
+          mapped_memories[index_output].contents.data_length /
+                  model->output_size_bytes !=
+              model->output_length[index_output]) {
+        result =
+            iree_make_status(IREE_STATUS_UNKNOWN, "output length mismatches");
       }
     }
   }
diff --git a/samples/util/util.h b/model_util/util.h
similarity index 80%
rename from samples/util/util.h
rename to model_util/util.h
index b500d02..9583507 100644
--- a/samples/util/util.h
+++ b/model_util/util.h
@@ -14,12 +14,12 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_UTIL_UTIL_H_
-#define SAMPLES_UTIL_UTIL_H_
+#ifndef MODEL_UTIL_UTIL_H_
+#define MODEL_UTIL_UTIL_H_
 
 // A top-level header collection for ML executable utility library.
 
-#include "samples/util/alloc.h"
-#include "samples/util/model_api.h"
+#include "model_util/alloc.h"
+#include "model_util/model_api.h"
 
-#endif  // SAMPLES_UTIL_UTIL_H_
+#endif  // MODEL_UTIL_UTIL_H_
diff --git a/samples/risp4ml/CMakeLists.txt b/risp4ml/CMakeLists.txt
similarity index 100%
rename from samples/risp4ml/CMakeLists.txt
rename to risp4ml/CMakeLists.txt
diff --git a/samples/risp4ml/common/CMakeLists.txt b/risp4ml/common/CMakeLists.txt
similarity index 100%
rename from samples/risp4ml/common/CMakeLists.txt
rename to risp4ml/common/CMakeLists.txt
diff --git a/samples/risp4ml/common/constants.h b/risp4ml/common/constants.h
similarity index 93%
rename from samples/risp4ml/common/constants.h
rename to risp4ml/common/constants.h
index f3e2ebd..aedef09 100644
--- a/samples/risp4ml/common/constants.h
+++ b/risp4ml/common/constants.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_RISP4ML_COMMON_CONSTANTS_H_
-#define SAMPLES_RISP4ML_COMMON_CONSTANTS_H_
+#ifndef RISP4ML_COMMON_CONSTANTS_H_
+#define RISP4ML_COMMON_CONSTANTS_H_
 
 #include <stdint.h>
 
@@ -72,4 +72,4 @@
 // or to make sure the BayerType corresponds to the loaded image
 static const BayerPattern kBayerType = kRggb;
 
-#endif  // SAMPLES_RISP4ML_COMMON_CONSTANTS_H_
+#endif  // RISP4ML_COMMON_CONSTANTS_H_
diff --git a/samples/risp4ml/common/image.c b/risp4ml/common/image.c
similarity index 97%
rename from samples/risp4ml/common/image.c
rename to risp4ml/common/image.c
index 0e32223..de4480d 100644
--- a/samples/risp4ml/common/image.c
+++ b/risp4ml/common/image.c
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-#include <stdlib.h>
+#include "risp4ml/common/image.h"
 
-#include "samples/risp4ml/common/image.h"
+#include <stdlib.h>
 
 Image* image_new(uint16_t num_channels, uint16_t height, uint16_t width) {
   Image* image = (Image*)malloc(sizeof(Image));
diff --git a/samples/risp4ml/common/image.h b/risp4ml/common/image.h
similarity index 91%
rename from samples/risp4ml/common/image.h
rename to risp4ml/common/image.h
index d899158..dea74ad 100644
--- a/samples/risp4ml/common/image.h
+++ b/risp4ml/common/image.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_RISP4ML_COMMON_IMAGE_H_
-#define SAMPLES_RISP4ML_COMMON_IMAGE_H_
+#ifndef RISP4ML_COMMON_IMAGE_H_
+#define RISP4ML_COMMON_IMAGE_H_
 
 #include <stdint.h>
 
@@ -56,4 +56,4 @@
 }  // extern "C"
 #endif  // __cplusplus
 
-#endif  // SAMPLES_RISP4ML_COMMON_IMAGE_H_
+#endif  // RISP4ML_COMMON_IMAGE_H_
diff --git a/samples/risp4ml/common/image_test.cc b/risp4ml/common/image_test.cc
similarity index 93%
rename from samples/risp4ml/common/image_test.cc
rename to risp4ml/common/image_test.cc
index bf78a54..af72a75 100644
--- a/samples/risp4ml/common/image_test.cc
+++ b/risp4ml/common/image_test.cc
@@ -12,9 +12,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+#include "risp4ml/common/image.h"
+
 #include "pw_unit_test/framework.h"
-#include "samples/risp4ml/common/image.h"
-#include "samples/risp4ml/common/test_utils.h"
+#include "risp4ml/common/test_utils.h"
 
 class ImageTest : public ::testing::Test {
  protected:
diff --git a/samples/risp4ml/common/image_test.run b/risp4ml/common/image_test.run
similarity index 100%
rename from samples/risp4ml/common/image_test.run
rename to risp4ml/common/image_test.run
diff --git a/samples/risp4ml/common/test_utils.h b/risp4ml/common/test_utils.h
similarity index 85%
rename from samples/risp4ml/common/test_utils.h
rename to risp4ml/common/test_utils.h
index 3865655..f0ff59a 100644
--- a/samples/risp4ml/common/test_utils.h
+++ b/risp4ml/common/test_utils.h
@@ -14,13 +14,13 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_RISP4ML_COMMON_TEST_UTILS_H_
-#define SAMPLES_RISP4ML_COMMON_TEST_UTILS_H_
+#ifndef RISP4ML_COMMON_TEST_UTILS_H_
+#define RISP4ML_COMMON_TEST_UTILS_H_
 
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "samples/risp4ml/common/image.h"
+#include "risp4ml/common/image.h"
 
 inline pixel_type_t Pattern(uint16_t c, uint16_t y, uint16_t x) {
   return (pixel_type_t)(x + y * 100 + c * 10000);
@@ -43,7 +43,9 @@
   for (uint16_t c = 0; c < image->num_channels; ++c) {
     for (uint16_t y = 0; y < image->height; ++y) {
       for (uint16_t x = 0; x < image->width; ++x) {
-        *image_pixel(image, 0, y, x) = (pixel_type_t)(rand() % range + min_val);
+        *image_pixel(image, 0, y, x) =
+            (pixel_type_t)(rand() % range +  // NOLINT(runtime/threadsafe_fn)
+                           min_val);
       }
     }
   }
@@ -60,4 +62,4 @@
   }
 }
 
-#endif  // SAMPLES_RISP4ML_COMMON_TEST_UTILS_H_
+#endif  // RISP4ML_COMMON_TEST_UTILS_H_
diff --git a/samples/risp4ml/common/utils.c b/risp4ml/common/utils.c
similarity index 97%
rename from samples/risp4ml/common/utils.c
rename to risp4ml/common/utils.c
index 7afcddf..04dd49c 100644
--- a/samples/risp4ml/common/utils.c
+++ b/risp4ml/common/utils.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "samples/risp4ml/common/utils.h"
+#include "risp4ml/common/utils.h"
 
 // int GetBayerIndex(int x, int y) {
 //   // The Bayer pattern code defines which color is top left in the quad:
diff --git a/samples/risp4ml/common/utils.h b/risp4ml/common/utils.h
similarity index 89%
rename from samples/risp4ml/common/utils.h
rename to risp4ml/common/utils.h
index 347f4d5..c687d05 100644
--- a/samples/risp4ml/common/utils.h
+++ b/risp4ml/common/utils.h
@@ -14,15 +14,15 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_RISP4ML_COMMON_UTILS_H_
-#define SAMPLES_RISP4ML_COMMON_UTILS_H_
+#ifndef RISP4ML_COMMON_UTILS_H_
+#define RISP4ML_COMMON_UTILS_H_
 
 #include <math.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "samples/risp4ml/common/constants.h"
+#include "risp4ml/common/constants.h"
 
 // Return the RAW color channel index at position (x, y) for a given Bayer
 // pattern
@@ -60,7 +60,7 @@
 
 inline float Roundf(float x) {
   int d = x < 0 ? x - 0.5 : x + 0.5;
-  return (float)d;
+  return (float)d;  // NOLINT(readability/casting)
 }
 
 // This function converts floating point value `x` to fixed point with the
@@ -79,11 +79,11 @@
 
   // Clamp to the allowed range.
   if (output_as_float < min_value) {
-    return (int)min_value;
+    return (int)min_value;  // NOLINT(readability/casting)
   } else if (output_as_float > max_value) {
-    return (int)max_value;
+    return (int)max_value;  // NOLINT(readability/casting)
   }
-  return (int)output_as_float;
+  return (int)output_as_float;  // NOLINT(readability/casting)
 }
 
 // Helper function for fixed point rounding of values.
@@ -99,4 +99,4 @@
   return val0 + Round((val1 - val0) * weight, weight_precision);
 }
 
-#endif  // SAMPLES_RISP4ML_COMMON_UTILS_H_
+#endif  // RISP4ML_COMMON_UTILS_H_
diff --git a/samples/risp4ml/isp_stages/CMakeLists.txt b/risp4ml/isp_stages/CMakeLists.txt
similarity index 81%
rename from samples/risp4ml/isp_stages/CMakeLists.txt
rename to risp4ml/isp_stages/CMakeLists.txt
index 960fbc9..0c94055 100644
--- a/samples/risp4ml/isp_stages/CMakeLists.txt
+++ b/risp4ml/isp_stages/CMakeLists.txt
@@ -32,8 +32,8 @@
   SRCS
     ${BLC_SRC}
   DEPS
-    samples::risp4ml::common::image
-    samples::risp4ml::common::utils
+    risp4ml::common::image
+    risp4ml::common::utils
 )
 
 iree_cc_library(
@@ -44,8 +44,8 @@
   SRCS
     ${DEMOSAIC_SRC}
   DEPS
-    samples::risp4ml::common::image
-    samples::risp4ml::common::utils
+    risp4ml::common::image
+    risp4ml::common::utils
 )
 
 iree_cc_library(
@@ -56,8 +56,8 @@
   SRCS
     ${DG_SRC}
   DEPS
-    samples::risp4ml::common::image
-    samples::risp4ml::common::utils
+    risp4ml::common::image
+    risp4ml::common::utils
 )
 
 iree_cc_library(
@@ -68,8 +68,8 @@
   SRCS
     ${DOWNSCALE_SRC}
   DEPS
-    samples::risp4ml::common::image
-    samples::risp4ml::common::utils
+    risp4ml::common::image
+    risp4ml::common::utils
 )
 
 iree_cc_library(
@@ -80,8 +80,8 @@
   SRCS
     ${GAMMA_SRC}
   DEPS
-    samples::risp4ml::common::image
-    samples::risp4ml::common::utils
+    risp4ml::common::image
+    risp4ml::common::utils
 )
 
 iree_cc_library(
@@ -92,8 +92,8 @@
   SRCS
     ${WBG_SRC}
   DEPS
-    samples::risp4ml::common::image
-    samples::risp4ml::common::utils
+    risp4ml::common::image
+    risp4ml::common::utils
 )
 
 springbok_test(
@@ -103,7 +103,7 @@
     "blc_test.cc"
   DEPS
     ::blc
-    samples::risp4ml::common::test_utils
+    risp4ml::common::test_utils
     pw_unit_test
     pw_unit_test.main
     pw_assert_basic
@@ -118,7 +118,7 @@
     "dg_test.cc"
   DEPS
     ::dg
-    samples::risp4ml::common::test_utils
+    risp4ml::common::test_utils
     pw_unit_test
     pw_unit_test.main
     pw_assert_basic
diff --git a/samples/risp4ml/isp_stages/blc.c b/risp4ml/isp_stages/blc.c
similarity index 92%
rename from samples/risp4ml/isp_stages/blc.c
rename to risp4ml/isp_stages/blc.c
index 5c5775a..db8a434 100644
--- a/samples/risp4ml/isp_stages/blc.c
+++ b/risp4ml/isp_stages/blc.c
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-#include "samples/risp4ml/common/utils.h"
-#include "samples/risp4ml/isp_stages/blc.h"
+#include "risp4ml/isp_stages/blc.h"
+
+#include "risp4ml/common/utils.h"
 
 static BlcParams blc_params = {.enable = true,
                                .offsets = {2048, 2048, 2048, 2048}};
diff --git a/samples/risp4ml/isp_stages/blc.h b/risp4ml/isp_stages/blc.h
similarity index 83%
rename from samples/risp4ml/isp_stages/blc.h
rename to risp4ml/isp_stages/blc.h
index f77ae6a..006f6c5 100644
--- a/samples/risp4ml/isp_stages/blc.h
+++ b/risp4ml/isp_stages/blc.h
@@ -14,10 +14,11 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_RISP4ML_ISP_STAGES_BLC_H_
-#define SAMPLES_RISP4ML_ISP_STAGES_BLC_H_
+#ifndef RISP4ML_ISP_STAGES_BLC_H_
+#define RISP4ML_ISP_STAGES_BLC_H_
 
-#include "samples/risp4ml/common/image.h"
+#include "risp4ml/common/constants.h"
+#include "risp4ml/common/image.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -36,4 +37,4 @@
 }  // extern "C"
 #endif  // __cplusplus
 
-#endif  // SAMPLES_RISP4ML_ISP_STAGES_BLC_H_
+#endif  // RISP4ML_ISP_STAGES_BLC_H_
diff --git a/samples/risp4ml/isp_stages/blc_rvv.c b/risp4ml/isp_stages/blc_rvv.c
similarity index 93%
rename from samples/risp4ml/isp_stages/blc_rvv.c
rename to risp4ml/isp_stages/blc_rvv.c
index 21c53fe..2cb3092 100644
--- a/samples/risp4ml/isp_stages/blc_rvv.c
+++ b/risp4ml/isp_stages/blc_rvv.c
@@ -16,8 +16,8 @@
 
 #include <riscv_vector.h>
 
-#include "samples/risp4ml/common/utils.h"
-#include "samples/risp4ml/isp_stages/blc.h"
+#include "risp4ml/common/utils.h"
+#include "risp4ml/isp_stages/blc.h"
 
 static BlcParams blc_params = {.enable = true,
                                .offsets = {2048, 2048, 2048, 2048}};
diff --git a/samples/risp4ml/isp_stages/blc_test.cc b/risp4ml/isp_stages/blc_test.cc
similarity index 95%
rename from samples/risp4ml/isp_stages/blc_test.cc
rename to risp4ml/isp_stages/blc_test.cc
index 8c39605..f958ed3 100644
--- a/samples/risp4ml/isp_stages/blc_test.cc
+++ b/risp4ml/isp_stages/blc_test.cc
@@ -12,10 +12,11 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+#include "risp4ml/isp_stages/blc.h"
+
 #include "pw_unit_test/framework.h"
-#include "samples/risp4ml/common/constants.h"
-#include "samples/risp4ml/common/test_utils.h"
-#include "samples/risp4ml/isp_stages/blc.h"
+#include "risp4ml/common/constants.h"
+#include "risp4ml/common/test_utils.h"
 
 static constexpr int kFrameSize = 16;
 static constexpr int kNumPatterns = 4;
diff --git a/samples/risp4ml/isp_stages/blc_test.run b/risp4ml/isp_stages/blc_test.run
similarity index 100%
rename from samples/risp4ml/isp_stages/blc_test.run
rename to risp4ml/isp_stages/blc_test.run
diff --git a/samples/risp4ml/isp_stages/demosaic.c b/risp4ml/isp_stages/demosaic.c
similarity index 97%
rename from samples/risp4ml/isp_stages/demosaic.c
rename to risp4ml/isp_stages/demosaic.c
index 4cbd8c9..0691580 100644
--- a/samples/risp4ml/isp_stages/demosaic.c
+++ b/risp4ml/isp_stages/demosaic.c
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-#include "samples/risp4ml/common/utils.h"
-#include "samples/risp4ml/isp_stages/demosaic.h"
+#include "risp4ml/isp_stages/demosaic.h"
+
+#include "risp4ml/common/utils.h"
 
 static DemosaicParams demosaic_params = {.enable = true};
 
diff --git a/samples/risp4ml/isp_stages/demosaic.h b/risp4ml/isp_stages/demosaic.h
similarity index 82%
rename from samples/risp4ml/isp_stages/demosaic.h
rename to risp4ml/isp_stages/demosaic.h
index 3de0491..8102b52 100644
--- a/samples/risp4ml/isp_stages/demosaic.h
+++ b/risp4ml/isp_stages/demosaic.h
@@ -14,10 +14,10 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_RISP4ML_ISP_STAGES_DEMOSAIC_H_
-#define SAMPLES_RISP4ML_ISP_STAGES_DEMOSAIC_H_
+#ifndef RISP4ML_ISP_STAGES_DEMOSAIC_H_
+#define RISP4ML_ISP_STAGES_DEMOSAIC_H_
 
-#include "samples/risp4ml/common/image.h"
+#include "risp4ml/common/image.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -35,4 +35,4 @@
 }  // extern "C"
 #endif  // __cplusplus
 
-#endif  // SAMPLES_RISP4ML_ISP_STAGES_DEMOSAIC_H_
+#endif  // RISP4ML_ISP_STAGES_DEMOSAIC_H_
diff --git a/samples/risp4ml/isp_stages/demosaic_rvv.c b/risp4ml/isp_stages/demosaic_rvv.c
similarity index 98%
rename from samples/risp4ml/isp_stages/demosaic_rvv.c
rename to risp4ml/isp_stages/demosaic_rvv.c
index 0feab1a..4709a93 100644
--- a/samples/risp4ml/isp_stages/demosaic_rvv.c
+++ b/risp4ml/isp_stages/demosaic_rvv.c
@@ -16,8 +16,8 @@
 
 #include <riscv_vector.h>
 
-#include "samples/risp4ml/common/utils.h"
-#include "samples/risp4ml/isp_stages/demosaic.h"
+#include "risp4ml/common/utils.h"
+#include "risp4ml/isp_stages/demosaic.h"
 
 static DemosaicParams demosaic_params = {.enable = true};
 
diff --git a/samples/risp4ml/isp_stages/dg.c b/risp4ml/isp_stages/dg.c
similarity index 94%
rename from samples/risp4ml/isp_stages/dg.c
rename to risp4ml/isp_stages/dg.c
index dcbf889..4b64f93 100644
--- a/samples/risp4ml/isp_stages/dg.c
+++ b/risp4ml/isp_stages/dg.c
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-#include "samples/risp4ml/common/utils.h"
-#include "samples/risp4ml/isp_stages/dg.h"
+#include "risp4ml/isp_stages/dg.h"
+
+#include "risp4ml/common/utils.h"
 
 static const uint16_t kDgFractional = kRawPipelineFraction;
 static const uint16_t kDgUnityGain = 1 << kDgFractional;
diff --git a/samples/risp4ml/isp_stages/dg.h b/risp4ml/isp_stages/dg.h
similarity index 83%
rename from samples/risp4ml/isp_stages/dg.h
rename to risp4ml/isp_stages/dg.h
index bb87264..5972f47 100644
--- a/samples/risp4ml/isp_stages/dg.h
+++ b/risp4ml/isp_stages/dg.h
@@ -14,10 +14,11 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_RISP4ML_ISP_STAGES_DG_H_
-#define SAMPLES_RISP4ML_ISP_STAGES_DG_H_
+#ifndef RISP4ML_ISP_STAGES_DG_H_
+#define RISP4ML_ISP_STAGES_DG_H_
 
-#include "samples/risp4ml/common/image.h"
+#include "risp4ml/common/constants.h"
+#include "risp4ml/common/image.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -36,4 +37,4 @@
 }  // extern "C"
 #endif  // __cplusplus
 
-#endif  // SAMPLES_RISP4ML_ISP_STAGES_DG_H_
+#endif  // RISP4ML_ISP_STAGES_DG_H_
diff --git a/samples/risp4ml/isp_stages/dg_rvv.c b/risp4ml/isp_stages/dg_rvv.c
similarity index 94%
rename from samples/risp4ml/isp_stages/dg_rvv.c
rename to risp4ml/isp_stages/dg_rvv.c
index 8cfa816..a62dede 100644
--- a/samples/risp4ml/isp_stages/dg_rvv.c
+++ b/risp4ml/isp_stages/dg_rvv.c
@@ -15,8 +15,8 @@
  */
 #include <riscv_vector.h>
 
-#include "samples/risp4ml/common/utils.h"
-#include "samples/risp4ml/isp_stages/dg.h"
+#include "risp4ml/common/utils.h"
+#include "risp4ml/isp_stages/dg.h"
 
 static const uint16_t kDgFractional = kRawPipelineFraction;
 static const uint16_t kDgUnityGain = 1 << kDgFractional;
diff --git a/samples/risp4ml/isp_stages/dg_test.cc b/risp4ml/isp_stages/dg_test.cc
similarity index 97%
rename from samples/risp4ml/isp_stages/dg_test.cc
rename to risp4ml/isp_stages/dg_test.cc
index 1b94a30..f49cce2 100644
--- a/samples/risp4ml/isp_stages/dg_test.cc
+++ b/risp4ml/isp_stages/dg_test.cc
@@ -12,11 +12,12 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+#include "risp4ml/isp_stages/dg.h"
+
 #include "pw_unit_test/framework.h"
-#include "samples/risp4ml/common/constants.h"
-#include "samples/risp4ml/common/test_utils.h"
-#include "samples/risp4ml/common/utils.h"
-#include "samples/risp4ml/isp_stages/dg.h"
+#include "risp4ml/common/constants.h"
+#include "risp4ml/common/test_utils.h"
+#include "risp4ml/common/utils.h"
 
 static constexpr uint16_t kDgFractional = kRawPipelineFraction;
 static constexpr uint16_t kFrameSize = 16;
diff --git a/samples/risp4ml/isp_stages/dg_test.run b/risp4ml/isp_stages/dg_test.run
similarity index 100%
rename from samples/risp4ml/isp_stages/dg_test.run
rename to risp4ml/isp_stages/dg_test.run
diff --git a/samples/risp4ml/isp_stages/downscale.c b/risp4ml/isp_stages/downscale.c
similarity index 98%
rename from samples/risp4ml/isp_stages/downscale.c
rename to risp4ml/isp_stages/downscale.c
index e323cbb..b983c38 100644
--- a/samples/risp4ml/isp_stages/downscale.c
+++ b/risp4ml/isp_stages/downscale.c
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-#include "samples/risp4ml/common/utils.h"
-#include "samples/risp4ml/isp_stages/downscale.h"
+#include "risp4ml/isp_stages/downscale.h"
+
+#include "risp4ml/common/utils.h"
 
 static const uint16_t kScalePrecision = 8;
 static const uint16_t kScaleFixedOne = (1 << kScalePrecision);
diff --git a/samples/risp4ml/isp_stages/downscale.h b/risp4ml/isp_stages/downscale.h
similarity index 90%
rename from samples/risp4ml/isp_stages/downscale.h
rename to risp4ml/isp_stages/downscale.h
index 0ca46bd..b3ed3df 100644
--- a/samples/risp4ml/isp_stages/downscale.h
+++ b/risp4ml/isp_stages/downscale.h
@@ -14,10 +14,10 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_RISP4ML_ISP_STAGES_DOWNSCALE_H_
-#define SAMPLES_RISP4ML_ISP_STAGES_DOWNSCALE_H_
+#ifndef RISP4ML_ISP_STAGES_DOWNSCALE_H_
+#define RISP4ML_ISP_STAGES_DOWNSCALE_H_
 
-#include "samples/risp4ml/common/image.h"
+#include "risp4ml/common/image.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -52,7 +52,7 @@
   // output pixel from the first input pixel in each direction respectively
   uint32_t ver_initial_offset;
   uint32_t hor_initial_offset;
-#endif // ! ISP_WITH_RVV
+#endif  // ! ISP_WITH_RVV
 } DownscaleParams;
 
 void set_downscale_param(DownscaleParams* params);
@@ -65,4 +65,4 @@
 }  // extern "C"
 #endif  // __cplusplus
 
-#endif  // SAMPLES_RISP4ML_ISP_STAGES_DOWNSCALE_H_
+#endif  // RISP4ML_ISP_STAGES_DOWNSCALE_H_
diff --git a/samples/risp4ml/isp_stages/downscale_rvv.c b/risp4ml/isp_stages/downscale_rvv.c
similarity index 97%
rename from samples/risp4ml/isp_stages/downscale_rvv.c
rename to risp4ml/isp_stages/downscale_rvv.c
index 70c2877..9098148 100644
--- a/samples/risp4ml/isp_stages/downscale_rvv.c
+++ b/risp4ml/isp_stages/downscale_rvv.c
@@ -16,8 +16,8 @@
 
 #include <riscv_vector.h>
 
-#include "samples/risp4ml/common/utils.h"
-#include "samples/risp4ml/isp_stages/downscale.h"
+#include "risp4ml/common/utils.h"
+#include "risp4ml/isp_stages/downscale.h"
 
 static const uint16_t kScalePrecision = 10;
 static const uint32_t kScaleFixedOne = (1 << kScalePrecision);
diff --git a/samples/risp4ml/isp_stages/downscale_rvv_test.cc b/risp4ml/isp_stages/downscale_rvv_test.cc
similarity index 92%
rename from samples/risp4ml/isp_stages/downscale_rvv_test.cc
rename to risp4ml/isp_stages/downscale_rvv_test.cc
index f38e8b8..5ec0be6 100644
--- a/samples/risp4ml/isp_stages/downscale_rvv_test.cc
+++ b/risp4ml/isp_stages/downscale_rvv_test.cc
@@ -20,9 +20,9 @@
 #include <cmath>
 
 #include "pw_unit_test/framework.h"
-#include "samples/risp4ml/common/constants.h"
-#include "samples/risp4ml/common/test_utils.h"
-#include "samples/risp4ml/isp_stages/downscale.h"
+#include "risp4ml/common/constants.h"
+#include "risp4ml/common/test_utils.h"
+#include "risp4ml/isp_stages/downscale.h"
 
 static constexpr uint16_t kScalePrecision = 10;
 static constexpr uint32_t kScaleFixedOne = (1 << kScalePrecision);
@@ -75,20 +75,21 @@
 
 ImageU8* DownscaleRvvTest::imageu8_new(uint16_t num_channels, uint16_t height,
                                        uint16_t width) {
-  ImageU8* image = (ImageU8*)malloc(sizeof(ImageU8));
+  ImageU8* image = reinterpret_cast<ImageU8*>(malloc(sizeof(ImageU8)));
   if (image) {
     image->num_channels = num_channels;
     image->height = height;
     image->width = width;
     uint32_t num_pixels = width * height * num_channels;
-    image->data = (uint8_t*)malloc(num_pixels * sizeof(uint8_t));
+    image->data =
+        reinterpret_cast<uint8_t*>(malloc(num_pixels * sizeof(uint8_t)));
   }
   return image;
 }
 
 float DownscaleRvvTest::ExpectedOut(uint16_t y, uint16_t x) {
-  float x_ratio = ((float)in_->width - 1) / (out_->width - 1);
-  float y_ratio = ((float)in_->height - 1) / (out_->height - 1);
+  float x_ratio = (static_cast<float>(in_->width) - 1) / (out_->width - 1);
+  float y_ratio = (static_cast<float>(in_->height) - 1) / (out_->height - 1);
 
   uint32_t x_l = (uint32_t)(x_ratio * x);
   uint32_t x_h = (x_l == in_->width - 1) ? x_l : x_l + 1;
@@ -133,8 +134,8 @@
   for (uint16_t y = 0; y < output_height; ++y) {
     for (uint16_t x = 0; x < output_width; ++x) {
       float expected_out = ExpectedOut(y, x);
-      float diff =
-          std::abs((float)imageu8_pixel_val(out_, 0, y, x) - expected_out);
+      float diff = std::abs(
+          static_cast<float>(imageu8_pixel_val(out_, 0, y, x)) - expected_out);
       ASSERT_LE(diff, kTolerance);
     }
   }
diff --git a/samples/risp4ml/isp_stages/downscale_test.cc b/risp4ml/isp_stages/downscale_test.cc
similarity index 95%
rename from samples/risp4ml/isp_stages/downscale_test.cc
rename to risp4ml/isp_stages/downscale_test.cc
index a917044..18b2520 100644
--- a/samples/risp4ml/isp_stages/downscale_test.cc
+++ b/risp4ml/isp_stages/downscale_test.cc
@@ -12,13 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+#include "risp4ml/isp_stages/downscale.h"
+
 #include <climits>
 #include <cmath>
+#include <vector>
 
 #include "pw_unit_test/framework.h"
-#include "samples/risp4ml/common/constants.h"
-#include "samples/risp4ml/common/test_utils.h"
-#include "samples/risp4ml/isp_stages/downscale.h"
+#include "risp4ml/common/constants.h"
+#include "risp4ml/common/test_utils.h"
 
 static constexpr uint16_t kScalePrecision = 8;
 static constexpr uint16_t kScaleFixedOne = (1 << kScalePrecision);
@@ -81,13 +83,14 @@
 
 ImageU8* DownscaleTest::imageu8_new(uint16_t num_channels, uint16_t height,
                                     uint16_t width) {
-  ImageU8* image = (ImageU8*)malloc(sizeof(ImageU8));
+  ImageU8* image = reinterpret_cast<ImageU8*>(malloc(sizeof(ImageU8)));
   if (image) {
     image->num_channels = num_channels;
     image->height = height;
     image->width = width;
     uint32_t num_pixels = width * height * num_channels;
-    image->data = (uint8_t*)malloc(num_pixels * sizeof(uint8_t));
+    image->data =
+        reinterpret_cast<uint8_t*>(malloc(num_pixels * sizeof(uint8_t)));
   }
   return image;
 }
@@ -153,8 +156,8 @@
     for (uint16_t x = 0; x < output_width; ++x) {
       float expected_out = ExpectedOut(in_, y, x, hor_scale, ver_scale,
                                        hor_initial_offset, ver_initial_offset);
-      float diff =
-          std::abs((float)imageu8_pixel_val(out_, 0, y, x) - expected_out);
+      float diff = std::abs(
+          static_cast<float>(imageu8_pixel_val(out_, 0, y, x)) - expected_out);
       ASSERT_LE(diff, kTolerance);
     }
   }
diff --git a/samples/risp4ml/isp_stages/downscale_test.run b/risp4ml/isp_stages/downscale_test.run
similarity index 100%
rename from samples/risp4ml/isp_stages/downscale_test.run
rename to risp4ml/isp_stages/downscale_test.run
diff --git a/samples/risp4ml/isp_stages/gamma.c b/risp4ml/isp_stages/gamma.c
similarity index 97%
rename from samples/risp4ml/isp_stages/gamma.c
rename to risp4ml/isp_stages/gamma.c
index 396dc62..458e6a7 100644
--- a/samples/risp4ml/isp_stages/gamma.c
+++ b/risp4ml/isp_stages/gamma.c
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-#include "samples/risp4ml/common/utils.h"
-#include "samples/risp4ml/isp_stages/gamma.h"
+#include "risp4ml/isp_stages/gamma.h"
+
+#include "risp4ml/common/utils.h"
 
 static const uint16_t kRgbPipelineBpp = 16;
 static const uint32_t kRgbPipelineMaxVal = (1 << kRgbPipelineBpp) - 1;
diff --git a/samples/risp4ml/isp_stages/gamma.h b/risp4ml/isp_stages/gamma.h
similarity index 84%
rename from samples/risp4ml/isp_stages/gamma.h
rename to risp4ml/isp_stages/gamma.h
index f6da623..3326b35 100644
--- a/samples/risp4ml/isp_stages/gamma.h
+++ b/risp4ml/isp_stages/gamma.h
@@ -14,10 +14,10 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_RISP4ML_ISP_STAGES_GAMMA_H_
-#define SAMPLES_RISP4ML_ISP_STAGES_GAMMA_H_
+#ifndef RISP4ML_ISP_STAGES_GAMMA_H_
+#define RISP4ML_ISP_STAGES_GAMMA_H_
 
-#include "samples/risp4ml/common/image.h"
+#include "risp4ml/common/image.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -42,4 +42,4 @@
 }  // extern "C"
 #endif  // __cplusplus
 
-#endif  // SAMPLES_RISP4ML_ISP_STAGES_GAMMA_H_
+#endif  // RISP4ML_ISP_STAGES_GAMMA_H_
diff --git a/samples/risp4ml/isp_stages/gamma_rvv.c b/risp4ml/isp_stages/gamma_rvv.c
similarity index 99%
rename from samples/risp4ml/isp_stages/gamma_rvv.c
rename to risp4ml/isp_stages/gamma_rvv.c
index c15b92c..e04025d 100644
--- a/samples/risp4ml/isp_stages/gamma_rvv.c
+++ b/risp4ml/isp_stages/gamma_rvv.c
@@ -15,8 +15,8 @@
  */
 #include <riscv_vector.h>
 
-#include "samples/risp4ml/common/utils.h"
-#include "samples/risp4ml/isp_stages/gamma.h"
+#include "risp4ml/common/utils.h"
+#include "risp4ml/isp_stages/gamma.h"
 
 static const uint16_t kRgbPipelineBpp = 16;
 static const uint16_t kRgbPipelineMaxVal = (1 << kRgbPipelineBpp) - 1;
diff --git a/samples/risp4ml/isp_stages/gamma_rvv_test.cc b/risp4ml/isp_stages/gamma_rvv_test.cc
similarity index 93%
rename from samples/risp4ml/isp_stages/gamma_rvv_test.cc
rename to risp4ml/isp_stages/gamma_rvv_test.cc
index 061ac8f..65d77b9 100644
--- a/samples/risp4ml/isp_stages/gamma_rvv_test.cc
+++ b/risp4ml/isp_stages/gamma_rvv_test.cc
@@ -16,7 +16,7 @@
 #include <cmath>
 
 #include "pw_unit_test/framework.h"
-#include "samples/risp4ml/isp_stages/gamma.h"
+#include "risp4ml/isp_stages/gamma.h"
 
 static constexpr uint16_t kRgbPipelineBpp = 16;
 static constexpr uint16_t kPostGammaPipelineBpp = 16;
@@ -62,7 +62,7 @@
     for (int n = 0; n <= kRgbPipelineMaxVal; n += kGammaSpacing) {
       params->lut[n / kGammaSpacing] =
           (1 << kRgbPipelineBpp) *
-          sRgb_gamma((float)n / (1 << kRgbPipelineBpp));
+          sRgb_gamma(static_cast<float>(n) / (1 << kRgbPipelineBpp));
     }
     params->lut[GAMMA_NUMBER_POINTS - 1] = kRgbPipelineMaxVal;
   }
@@ -132,8 +132,9 @@
                            sRgb_gamma(static_cast<float>(x) /
                                       (1 << kRgbPipelineBpp)));
         float tolerance = ceilf(kToleranceRatio * expected_val);
-        float diff = std::abs((float)expected_val -
-                              (float)image_pixel_val(out_, c, y, x));
+        float diff =
+            std::abs(static_cast<float>(expected_val) -
+                     static_cast<float>(image_pixel_val(out_, c, y, x)));
         ASSERT_LE(diff, tolerance);
       }
     }
diff --git a/samples/risp4ml/isp_stages/gamma_test.cc b/risp4ml/isp_stages/gamma_test.cc
similarity index 95%
rename from samples/risp4ml/isp_stages/gamma_test.cc
rename to risp4ml/isp_stages/gamma_test.cc
index c80372f..f9d549c 100644
--- a/samples/risp4ml/isp_stages/gamma_test.cc
+++ b/risp4ml/isp_stages/gamma_test.cc
@@ -12,10 +12,11 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+#include "risp4ml/isp_stages/gamma.h"
+
 #include <cmath>
 
 #include "pw_unit_test/framework.h"
-#include "samples/risp4ml/isp_stages/gamma.h"
 
 static constexpr uint16_t kRgbPipelineBpp = 16;
 static constexpr uint16_t kPostGammaPipelineBpp = 16;
@@ -127,8 +128,8 @@
                            sRgb_gamma(static_cast<float>(x) /
                                       (1 << kRgbPipelineBpp)));
         float tolerance = ceilf(kToleranceRatio * expected_val);
-        float diff = std::abs((float)expected_val -
-                              (float)image_pixel_val(out_, c, y, x));
+        float diff = std::abs(static<float>(expected_val) -
+                              static<float>(image_pixel_val(out_, c, y, x)));
         ASSERT_LE(diff, tolerance);
       }
     }
diff --git a/samples/risp4ml/isp_stages/gamma_test.run b/risp4ml/isp_stages/gamma_test.run
similarity index 100%
rename from samples/risp4ml/isp_stages/gamma_test.run
rename to risp4ml/isp_stages/gamma_test.run
diff --git a/samples/risp4ml/isp_stages/wbg.c b/risp4ml/isp_stages/wbg.c
similarity index 97%
rename from samples/risp4ml/isp_stages/wbg.c
rename to risp4ml/isp_stages/wbg.c
index 4eed39b..f55a8b6 100644
--- a/samples/risp4ml/isp_stages/wbg.c
+++ b/risp4ml/isp_stages/wbg.c
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-#include "samples/risp4ml/common/utils.h"
-#include "samples/risp4ml/isp_stages/wbg.h"
+#include "risp4ml/isp_stages/wbg.h"
+
+#include "risp4ml/common/utils.h"
 
 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
 
diff --git a/samples/risp4ml/isp_stages/wbg.h b/risp4ml/isp_stages/wbg.h
similarity index 83%
rename from samples/risp4ml/isp_stages/wbg.h
rename to risp4ml/isp_stages/wbg.h
index adcbd6f..3bb4a9c 100644
--- a/samples/risp4ml/isp_stages/wbg.h
+++ b/risp4ml/isp_stages/wbg.h
@@ -14,10 +14,11 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_RISP4ML_ISP_STAGES_WBG_H_
-#define SAMPLES_RISP4ML_ISP_STAGES_WBG_H_
+#ifndef RISP4ML_ISP_STAGES_WBG_H_
+#define RISP4ML_ISP_STAGES_WBG_H_
 
-#include "samples/risp4ml/common/image.h"
+#include "risp4ml/common/constants.h"
+#include "risp4ml/common/image.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -37,4 +38,4 @@
 }  // extern "C"
 #endif  // __cplusplus
 
-#endif  // SAMPLES_RISP4ML_ISP_STAGES_WBG_H_
+#endif  // RISP4ML_ISP_STAGES_WBG_H_
diff --git a/samples/risp4ml/isp_stages/wbg_rvv.c b/risp4ml/isp_stages/wbg_rvv.c
similarity index 97%
rename from samples/risp4ml/isp_stages/wbg_rvv.c
rename to risp4ml/isp_stages/wbg_rvv.c
index 6928a0c..1bc1187 100644
--- a/samples/risp4ml/isp_stages/wbg_rvv.c
+++ b/risp4ml/isp_stages/wbg_rvv.c
@@ -16,8 +16,8 @@
 
 #include <riscv_vector.h>
 
-#include "samples/risp4ml/common/utils.h"
-#include "samples/risp4ml/isp_stages/wbg.h"
+#include "risp4ml/common/utils.h"
+#include "risp4ml/isp_stages/wbg.h"
 
 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
 
diff --git a/samples/risp4ml/isp_stages/wbg_test.cc b/risp4ml/isp_stages/wbg_test.cc
similarity index 95%
rename from samples/risp4ml/isp_stages/wbg_test.cc
rename to risp4ml/isp_stages/wbg_test.cc
index e0d126f..c353ef4 100644
--- a/samples/risp4ml/isp_stages/wbg_test.cc
+++ b/risp4ml/isp_stages/wbg_test.cc
@@ -12,10 +12,11 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+#include "risp4ml/isp_stages/wbg.h"
+
 #include "pw_unit_test/framework.h"
-#include "samples/risp4ml/common/constants.h"
-#include "samples/risp4ml/common/test_utils.h"
-#include "samples/risp4ml/isp_stages/wbg.h"
+#include "risp4ml/common/constants.h"
+#include "risp4ml/common/test_utils.h"
 
 static constexpr uint16_t kWbgFractional = kRawPipelineFraction;
 static constexpr uint16_t kFrameWidth = 4;
diff --git a/samples/risp4ml/isp_stages/wbg_test.run b/risp4ml/isp_stages/wbg_test.run
similarity index 100%
rename from samples/risp4ml/isp_stages/wbg_test.run
rename to risp4ml/isp_stages/wbg_test.run
diff --git a/risp4ml/pipeline/CMakeLists.txt b/risp4ml/pipeline/CMakeLists.txt
new file mode 100644
index 0000000..947b3f9
--- /dev/null
+++ b/risp4ml/pipeline/CMakeLists.txt
@@ -0,0 +1,16 @@
+iree_cc_library(
+  NAME
+    pipeline
+  HDRS
+    "pipeline.h"
+  SRCS
+    "pipeline.c"
+  DEPS
+    risp4ml::common::image
+    risp4ml::isp_stages::blc
+    risp4ml::isp_stages::demosaic
+    risp4ml::isp_stages::dg
+    risp4ml::isp_stages::downscale
+    risp4ml::isp_stages::gamma
+    risp4ml::isp_stages::wbg
+)
diff --git a/samples/risp4ml/pipeline/pipeline.c b/risp4ml/pipeline/pipeline.c
similarity index 81%
rename from samples/risp4ml/pipeline/pipeline.c
rename to risp4ml/pipeline/pipeline.c
index e445b52..4b29e64 100644
--- a/samples/risp4ml/pipeline/pipeline.c
+++ b/risp4ml/pipeline/pipeline.c
@@ -14,14 +14,15 @@
  * limitations under the License.
  */
 
-#include "samples/risp4ml/common/utils.h"
-#include "samples/risp4ml/isp_stages/blc.h"
-#include "samples/risp4ml/isp_stages/demosaic.h"
-#include "samples/risp4ml/isp_stages/dg.h"
-#include "samples/risp4ml/isp_stages/downscale.h"
-#include "samples/risp4ml/isp_stages/gamma.h"
-#include "samples/risp4ml/isp_stages/wbg.h"
-#include "samples/risp4ml/pipeline/pipeline.h"
+#include "risp4ml/pipeline/pipeline.h"
+
+#include "risp4ml/common/utils.h"
+#include "risp4ml/isp_stages/blc.h"
+#include "risp4ml/isp_stages/demosaic.h"
+#include "risp4ml/isp_stages/dg.h"
+#include "risp4ml/isp_stages/downscale.h"
+#include "risp4ml/isp_stages/gamma.h"
+#include "risp4ml/isp_stages/wbg.h"
 
 void isp_pipeline(ImageU8 *input, ImageU8 *output) {
   Image *img_bayer =
diff --git a/samples/risp4ml/pipeline/pipeline.h b/risp4ml/pipeline/pipeline.h
similarity index 78%
rename from samples/risp4ml/pipeline/pipeline.h
rename to risp4ml/pipeline/pipeline.h
index a9fbfeb..5d29d2d 100644
--- a/samples/risp4ml/pipeline/pipeline.h
+++ b/risp4ml/pipeline/pipeline.h
@@ -14,11 +14,11 @@
  * limitations under the License.
  */
 
-#ifndef SAMPLES_RISP4ML_PIPELINE_PIPELINE_H_
-#define SAMPLES_RISP4ML_PIPELINE_PIPELINE_H_
+#ifndef RISP4ML_PIPELINE_PIPELINE_H_
+#define RISP4ML_PIPELINE_PIPELINE_H_
 
-#include "samples/risp4ml/common/image.h"
+#include "risp4ml/common/image.h"
 
 void isp_pipeline(ImageU8* input, ImageU8* output);
 
-#endif  // SAMPLES_RISP4ML_PIPELINE_PIPELINE_H_
+#endif  // RISP4ML_PIPELINE_PIPELINE_H_
diff --git a/samples/risp4ml/test_data/faces_480x640_uint8_numpy_bayer.bin b/risp4ml/test_data/faces_480x640_uint8_numpy_bayer.bin
similarity index 100%
rename from samples/risp4ml/test_data/faces_480x640_uint8_numpy_bayer.bin
rename to risp4ml/test_data/faces_480x640_uint8_numpy_bayer.bin
Binary files differ
diff --git a/samples/risp4ml/pipeline/CMakeLists.txt b/samples/risp4ml/pipeline/CMakeLists.txt
deleted file mode 100644
index e6447c6..0000000
--- a/samples/risp4ml/pipeline/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-iree_cc_library(
-  NAME
-    pipeline
-  HDRS
-    "pipeline.h"
-  SRCS
-    "pipeline.c"
-  DEPS
-    samples::risp4ml::common::image
-    samples::risp4ml::isp_stages::blc
-    samples::risp4ml::isp_stages::demosaic
-    samples::risp4ml::isp_stages::dg
-    samples::risp4ml::isp_stages::downscale
-    samples::risp4ml::isp_stages::gamma
-    samples::risp4ml::isp_stages::wbg
-)
diff --git a/samples/simple_vec_mul/CMakeLists.txt b/samples/simple_vec_mul/CMakeLists.txt
index 341b6bd..c521d7f 100644
--- a/samples/simple_vec_mul/CMakeLists.txt
+++ b/samples/simple_vec_mul/CMakeLists.txt
@@ -53,7 +53,7 @@
     ::simple_float_mul_bytecode_module_static
     ::simple_float_mul_bytecode_module_static_c
     iree::vm::bytecode_module
-    samples::util::util
+    model_util::util
   LINKOPTS
     "LINKER:--defsym=__stack_size__=20k"
 )
@@ -66,7 +66,7 @@
   DEPS
     ::simple_float_mul_c_module_static_c
     ::simple_float_mul_c_module_static_emitc
-    samples::util::util
+    model_util::util
   LINKOPTS
     "LINKER:--defsym=__stack_size__=20k"
   COPTS
@@ -82,7 +82,7 @@
     ::simple_int_mul_bytecode_module_static
     ::simple_int_mul_bytecode_module_static_c
     iree::vm::bytecode_module
-    samples::util::util
+    model_util::util
   LINKOPTS
     "LINKER:--defsym=__stack_size__=20k"
 )
@@ -95,7 +95,7 @@
   DEPS
     ::simple_int_mul_c_module_static_c
     ::simple_int_mul_c_module_static_emitc
-    samples::util::util
+    model_util::util
   LINKOPTS
     "LINKER:--defsym=__stack_size__=20k"
   COPTS
diff --git a/samples/simple_vec_mul/float_vec.c b/samples/simple_vec_mul/float_vec.c
index 77e3a13..a99aa47 100644
--- a/samples/simple_vec_mul/float_vec.c
+++ b/samples/simple_vec_mul/float_vec.c
@@ -18,7 +18,7 @@
 
 #include "iree/base/api.h"
 #include "iree/hal/api.h"
-#include "samples/util/util.h"
+#include "model_util/util.h"
 
 // Compiled module embedded here to avoid file IO:
 #if !defined(BUILD_EMITC)
diff --git a/samples/simple_vec_mul/int_vec.c b/samples/simple_vec_mul/int_vec.c
index 1a316f8..0053c52 100644
--- a/samples/simple_vec_mul/int_vec.c
+++ b/samples/simple_vec_mul/int_vec.c
@@ -18,7 +18,7 @@
 
 #include "iree/base/api.h"
 #include "iree/hal/api.h"
-#include "samples/util/util.h"
+#include "model_util/util.h"
 
 // Compiled module embedded here to avoid file IO:
 #if !defined(BUILD_EMITC)