[Format] Revise the format of whole source codes
authorDongju Chae <dongju.chae@samsung.com>
Fri, 6 Aug 2021 06:54:11 +0000 (15:54 +0900)
committer채동주/On-Device Lab(SR)/Staff Engineer/삼성전자 <dongju.chae@samsung.com>
Mon, 9 Aug 2021 04:46:00 +0000 (13:46 +0900)
This patch revises the format of whole source codes using
column limit 100.

Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
72 files changed:
include/common/npubinfmt.h
include/common/typedef.h
include/host/libnpuhost.h
plugins/nnstreamer/tensor_filter_srnpu.cc
plugins/nnstreamer/tensor_filter_srnpu.h
plugins/npumgr/dummy/npumgr.cc
plugins/npumgr/dummy/npumgr_api.cc
plugins/npumgr/dummy/npumgr_triv2.cc
plugins/npumgr/dummy/npumgr_triv2.h
src/core/comm/CommPlugin.h
src/core/comm/plugin-comm-ip.cc
src/core/ne-buffer.cc
src/core/ne-data.cc
src/core/ne-handler.cc
src/core/ne-handler.h
src/core/ne-host-input-service.cc
src/core/ne-hw-input-service.cc
src/core/ne-hwmem.cc
src/core/ne-hwmem.h
src/core/ne-inputservice.h
src/core/ne-mem.h
src/core/ne-model.cc
src/core/ne-model.h
src/core/ne-profiler.cc
src/core/ne-profiler.h
src/core/ne-request.h
src/core/ne-scheduler.cc
src/core/ne-segment-table.cc
src/core/ne-segment-table.h
src/core/ne-thread-pool.cc
src/core/ne-thread-pool.h
src/core/npu/NPUdrvAPI.cc
src/core/npu/NPUdrvAPI.h
src/core/npu/NPUdrvAPI_emul.cc
src/core/npu/NPUdrvAPI_triv2.cc
src/core/utils/ne-conf.cc
src/core/utils/ne-utils.cc
src/core/utils/ne-utils.h
src/host/ne-host.cc
tests/apptests/dummy_triv2_async.cc
tests/apptests/dummy_triv2_sync.cc
tests/apptests/tvn_triv2.cc
tests/apptests/tvn_triv2_aging.cc
tests/apptests/tvn_triv2_bulk.cc
tests/apptests/tvn_triv2_dmabuf.cc
tests/apptests/tvn_triv2_interleave.cc
tests/apptests/tvn_triv2_preempt.cc
tests/apptests/tvn_triv2_profile.cc
tests/apptests/tvn_triv2_profile_example.cc
tests/apptests/tvn_triv2_recurring.cc
tests/apptests/tvn_triv2_sigkill.cc
tests/apptests/tvn_triv2_xml.cc
tests/plugins/nnstreamer/nnstreamer_test.cc
tests/plugins/npumgr/npumgr_test.cc
tests/unittests/ne_core_buffer_test.cc
tests/unittests/ne_core_comm_test.cc
tests/unittests/ne_core_data_test.cc
tests/unittests/ne_core_handler_test.cc
tests/unittests/ne_core_mem_test.cc
tests/unittests/ne_core_model_test.cc
tests/unittests/ne_core_utils_test.cc
tests/unittests/ne_libnpuhost_test.cc
tests/utils/ne_test_utils.cc
tests/utils/ne_test_utils.h
tests/utils/ne_test_utils_common.cc
tests/utils/ne_test_utils_common.h
tests/utils/ne_test_utils_gtest.cc
utils/model_inspect/model_inspect.cc
utils/trinity_cuse/trinity-cuse-triv2.cc
utils/trinity_cuse/trinity-cuse.cc
utils/trinity_cuse/trinity-cuse.h
utils/trinity_smi/trinity-smi.cc

index a597e01..6a2eb97 100644 (file)
@@ -50,8 +50,7 @@ NPUBIN_META_EXTENDED_SIZE (uint64_t magiccode) {
 static inline uint64_t
 NPUBIN_META_TOTAL_SIZE (uint64_t magiccode) {
   uint64_t size_extended = NPUBIN_META_EXTENDED_SIZE (magiccode);
-  assert (size_extended <=
-          UINT8_MAX * NPUBIN_META_SIZE); /** sanity check for svace */
+  assert (size_extended <= UINT8_MAX * NPUBIN_META_SIZE); /** sanity check for svace */
   return size_extended + NPUBIN_META_SIZE;
 }
 
@@ -66,8 +65,7 @@ NPUBIN_META_TOTAL_SIZE (uint64_t magiccode) {
 #define NPUBIN_MAGICCODE (0x53524E5055000000ULL) /* ASCII hex for 'SRNPU' */
 #define NPUBIN_VERSION_MAX (3)
 #define NPUBIN_VERSION(magiccode) ((magiccode) &0xFFULL)
-#define CHECK_NPUBIN(magiccode) \
-  (((magiccode) & ~0xFFFFFFULL) == NPUBIN_MAGICCODE)
+#define CHECK_NPUBIN(magiccode) (((magiccode) & ~0xFFFFFFULL) == NPUBIN_MAGICCODE)
 
 /* npubinfmt npu_version macros */
 #define NPU_VERSION_MAJOR(npu_version) (((npu_version) &0x000000FFULL))
@@ -340,8 +338,7 @@ typedef struct {
 /* Compile-time assert. From http://www.pixelbeat.org/programming/gcc/static_assert.html */
 #define ASSERT_CONCAT_(a, b) a##b
 #define ASSERT_CONCAT(a, b) ASSERT_CONCAT_ (a, b)
-#define ct_assert(e) \
-  enum { ASSERT_CONCAT (assert_line_, __LINE__) = 1 / (!!(e)) }
+#define ct_assert(e) enum { ASSERT_CONCAT (assert_line_, __LINE__) = 1 / (!!(e)) }
 
 ct_assert (sizeof (npubin_meta) == NPUBIN_META_SIZE);
 
index a87c826..e6fdfc2 100644 (file)
@@ -61,7 +61,7 @@ typedef enum {
   /**< alias for backward-compatibility */
   DATA_LAYOUT_TRIV2, /**< customized layout for TRIV2 (based on NHWC) */
   DATA_LAYOUT_MODEL, /**< use the same data layout specified in model metadata */
-  DATA_LAYOUT_RAW, /**< any raw data. npu-engine does not care about its layout */
+  DATA_LAYOUT_RAW,   /**< any raw data. npu-engine does not care about its layout */
 } data_layout;
 
 /**
@@ -127,9 +127,8 @@ typedef struct {
  *        Each generic buffer can have different buffer types.
  */
 typedef struct {
-  uint32_t num_buffers; /**< The number of tensors in this "buffer" */
-  generic_buffer
-      bufs[NPU_TENSOR_CARDINALITY_MAX]; /**< Buffer struct for each tensor */
+  uint32_t num_buffers;                            /**< The number of tensors in this "buffer" */
+  generic_buffer bufs[NPU_TENSOR_CARDINALITY_MAX]; /**< Buffer struct for each tensor */
 } generic_buffers;
 
 /**
@@ -163,8 +162,7 @@ typedef struct {
  * @detail The callback function has the responsibility to free the given
  *         output buffer (output) when its type is BUFFER_MAPPED.
   */
-typedef void (*npuOutputNotify) (output_buffers *output, int req_id,
-                                 void *data);
+typedef void (*npuOutputNotify) (output_buffers *output, int req_id, void *data);
 
 /**
  * @brief deprecated mode.
@@ -208,9 +206,8 @@ typedef enum {
  *       third-party hardware.
  */
 typedef enum {
-  NPU_INTERRUPT =
-      0, /**< interrupt: moderate latency but save CPU usage (default) */
-  NPU_POLLING = 1, /**< polling: consume CPU usage but achieve low latency */
+  NPU_INTERRUPT = 0, /**< interrupt: moderate latency but save CPU usage (default) */
+  NPU_POLLING = 1,   /**< polling: consume CPU usage but achieve low latency */
 } npu_notimode;
 
 /**
@@ -228,11 +225,7 @@ typedef struct {
 /**
  * @brief Describes the supported NPU Scheduler (in kernel modules)
  */
-typedef enum {
-  NPU_SCHEDULER_UNKNOWN = 0,
-  NPU_SCHEDULER_SR,
-  NPU_SCHEDULER_VD
-} npu_scheduler;
+typedef enum { NPU_SCHEDULER_UNKNOWN = 0, NPU_SCHEDULER_SR, NPU_SCHEDULER_VD } npu_scheduler;
 
 /** @brief optional parameter for npu scheduler */
 typedef void *npu_scheduler_param;
@@ -247,12 +240,9 @@ static const uint32_t default_tops = 2;
  * @brief Description of npu device status
  */
 typedef enum {
-  NPU_ERROR =
-      0, /**< The NPU is not available for now (check the log file for details) */
-  NPU_READY =
-      1, /**< The NPU is available but the request can be delayed due to others */
-  NPU_IDLE =
-      2, /**< The NPU is available and there's no active request currently */
+  NPU_ERROR = 0, /**< The NPU is not available for now (check the log file for details) */
+  NPU_READY = 1, /**< The NPU is available but the request can be delayed due to others */
+  NPU_IDLE = 2,  /**< The NPU is available and there's no active request currently */
 } npu_status;
 
 /**
@@ -260,24 +250,20 @@ typedef enum {
  * @note this mode will decide which input service performs the inference of a model.
  */
 typedef enum {
-  NPUINPUT_STOP = 0, /**< Stop Processing */
-  NPUINPUT_INTERNAL_CAM =
-      1, /**< Let ADSP preprocess image stream from MIPI and send it to
+  NPUINPUT_STOP = 0,         /**< Stop Processing */
+  NPUINPUT_INTERNAL_CAM = 1, /**< Let ADSP preprocess image stream from MIPI and send it to
                                    NPU-core to be processed with the given model.
                                    (not supported yet) */
-  NPUINPUT_I2S_MIC =
-      2, /**< ASR mode with on-chip internal I2S. modelid is ignored.
+  NPUINPUT_I2S_MIC = 2,      /**< ASR mode with on-chip internal I2S. modelid is ignored.
                                    (not supported yet) */
-  NPUINPUT_HOST = 3, /**< Process input frames transmitted from Host.
+  NPUINPUT_HOST = 3,         /**< Process input frames transmitted from Host.
                                    TRIA, TRIV, and TRIV2 may use this. */
-  NPUINPUT_HW_RECURRING =
-      4, /**< Process input frames transmitted from third-party HW.
+  NPUINPUT_HW_RECURRING = 4, /**< Process input frames transmitted from third-party HW.
                                    TRIV2 may use this for high-priority models. */
 } npu_input_opmode;
 
-#define IS_DEVICE                             \
-  (val, devname) (((val) &DEVICETYPE_MASK) == \
-                  DEVICETYPE_##devname) /** E.g., IS_DEVICE(dev, ASR) */
+#define IS_DEVICE \
+  (val, devname) (((val) &DEVICETYPE_MASK) == DEVICETYPE_##devname) /** E.g., IS_DEVICE(dev, ASR) */
 
 /**
  * @brief Various device types to be supported for running models
@@ -410,7 +396,7 @@ typedef struct {
 typedef enum {
   PROFILE_LEVEL_EXT_META = 0, /**< Depends on extended metadata */
   PROFILE_LEVEL_VISA,         /**< vISA-level profiling */
-  PROFILE_LEVEL_LAYER, /**< Layer-level profiling (requires the extended meta) */
+  PROFILE_LEVEL_LAYER,        /**< Layer-level profiling (requires the extended meta) */
   PROFILE_LEVEL_MAX
 } profile_level_type;
 
index 95a0e03..d3b79a5 100644 (file)
@@ -152,8 +152,7 @@ getNPUmodel_metasize (npubin_meta *meta) {
  *         embedded in devices, you do not need to call register and
  *         register calls for ASR are ignored.
  */
-int registerNPUmodel (npudev_h dev, generic_buffer *modelfile,
-                      uint32_t *model_id);
+int registerNPUmodel (npudev_h dev, generic_buffer *modelfile, uint32_t *model_id);
 
 /**
  * @brief Remove the NN model from NPU
@@ -180,8 +179,8 @@ int unregisterNPUmodel_all (npudev_h dev);
  * @param[out] size tensor size
  * @return 0 if no error. otherwise a negative error value
  */
-int getNPUmodel_tensorSize (npudev_h dev, uint32_t model_id, bool input,
-                            uint32_t index, uint32_t *size);
+int getNPUmodel_tensorSize (npudev_h dev, uint32_t model_id, bool input, uint32_t index,
+                            uint32_t *size);
 
 /**
  * @brief [OPTIONAL] Set the data layout for input/output tensors
@@ -192,8 +191,8 @@ int getNPUmodel_tensorSize (npudev_h dev, uint32_t model_id, bool input,
  * @return @c 0 if no error. otherwise a negative error value
  * @note if this function is not called, default layout/type will be used.
  */
-int setNPU_dataInfo (npudev_h dev, uint32_t model_id,
-                     tensors_data_info *info_in, tensors_data_info *info_out);
+int setNPU_dataInfo (npudev_h dev, uint32_t model_id, tensors_data_info *info_in,
+                     tensors_data_info *info_out);
 
 /**
  * @brief [OPTIONAL] Set the inference constraint for next NPU inferences
@@ -203,8 +202,7 @@ int setNPU_dataInfo (npudev_h dev, uint32_t model_id,
  * @return @c 0 if no error. otherwise a negative error value
  * @note If this function is not called, default values are used.
  */
-int setNPU_constraint (npudev_h dev, uint32_t model_id,
-                       npu_constraint constraint);
+int setNPU_constraint (npudev_h dev, uint32_t model_id, npu_constraint constraint);
 
 /**
  * @brief Execute inference.
@@ -219,9 +217,8 @@ int setNPU_constraint (npudev_h dev, uint32_t model_id,
  * @note This API allows for users to use pre-allocated (dmabuf) input/output buffers
  *       to avoid unnecessary memcpy. Make sure that they have 'BUFFER_DMABUF' types.
  */
-int runNPU_model (npudev_h dev, uint32_t model_id, npu_infer_mode mode,
-                  const input_buffers *input, output_buffers *output,
-                  npuOutputNotify cb, void *data);
+int runNPU_model (npudev_h dev, uint32_t model_id, npu_infer_mode mode, const input_buffers *input,
+                  output_buffers *output, npuOutputNotify cb, void *data);
 
 /**
  * @brief Execute inference. Blocking call (wait until output is available).
@@ -253,9 +250,8 @@ int runNPU_sync (npudev_h dev, uint32_t model_id, const input_buffers *input,
  *       Please use runNPU_model().
  * @detail There is a memcpy for the output buffer.
  */
-int runNPU_async (npudev_h dev, uint32_t model_id, const input_buffers *input,
-                  npuOutputNotify cb, uint64_t *sequence, void *data,
-                  npu_async_mode mode);
+int runNPU_async (npudev_h dev, uint32_t model_id, const input_buffers *input, npuOutputNotify cb,
+                  uint64_t *sequence, void *data, npu_async_mode mode);
 
 /**
  * @brief get the current memory status for the given device
@@ -273,8 +269,7 @@ int getNPU_memoryStatus (npudev_h dev, size_t *alloc_total, size_t *free_total);
  * @param[out] num_requests the number of running requests (or pending)
  * @return 0 if no error, otherwise a negative errno.
  */
-int getNPU_deviceStatus (npudev_h dev, npu_status *status,
-                         uint32_t *num_requests);
+int getNPU_deviceStatus (npudev_h dev, npu_status *status, uint32_t *num_requests);
 
 /**
  * [IMPORTANT] Descriptions for buffer allocation APIs.
@@ -426,8 +421,7 @@ int getNPU_profile (npudev_h dev, int req_id, npu_profile *profile);
  * @note This is one-shot API. Don't call multiple times for the same infernece.
  * @note Internal data of npu_profile is valid until putNPU_profile is called.
  */
-int getNPU_profile_opt (npudev_h dev, int req_id, const npu_profile_opt opt,
-                        npu_profile *profile);
+int getNPU_profile_opt (npudev_h dev, int req_id, const npu_profile_opt opt, npu_profile *profile);
 
 /**
  * @brief [Optional] Set model data of the request to be profiled
@@ -488,12 +482,9 @@ void putNPU_statReqs (npu_stat_reqs *stat);
  */
 int writeNPU_log (npu_loglevel level, const char *tag, const char *format, ...);
 
-#define writeNPU_logInfo(tag, format, ...) \
-  writeNPU_log (NPU_LOG_INFO, tag, format, ##__VA_ARGS__)
-#define writeNPU_logWarn(tag, format, ...) \
-  writeNPU_log (NPU_LOG_WARN, tag, format, ##__VA_ARGS__)
-#define writeNPU_logError(tag, format, ...) \
-  writeNPU_log (NPU_LOG_ERROR, tag, format, ##__VA_ARGS__)
+#define writeNPU_logInfo(tag, format, ...) writeNPU_log (NPU_LOG_INFO, tag, format, ##__VA_ARGS__)
+#define writeNPU_logWarn(tag, format, ...) writeNPU_log (NPU_LOG_WARN, tag, format, ##__VA_ARGS__)
+#define writeNPU_logError(tag, format, ...) writeNPU_log (NPU_LOG_ERROR, tag, format, ##__VA_ARGS__)
 
 /** NPU Request/Submit Interface (decoupled version for runNPU_* APIs) */
 
@@ -540,9 +531,8 @@ int getNPU_requestModel (npudev_h dev, int req_id, uint32_t *model_id);
  *       internally (e.g., NHWC <-> TRIV2).
  * @note it's not necessary if you're going to use submitNPU_requestKernel()
  */
-int setNPU_requestData (npudev_h dev, int req_id, input_buffers *input,
-                        tensors_data_info *in_info, output_buffers *output,
-                        tensors_data_info *out_info);
+int setNPU_requestData (npudev_h dev, int req_id, input_buffers *input, tensors_data_info *in_info,
+                        output_buffers *output, tensors_data_info *out_info);
 
 /**
  * @brief Set output callback of the request
@@ -553,8 +543,7 @@ int setNPU_requestData (npudev_h dev, int req_id, input_buffers *input,
  * @return 0 if no error. Otherwise a negative errno
  * @note it's not necessary if you're going to use submitNPU_requestKernel()
  */
-int setNPU_requestCallback (npudev_h dev, int req_id, npuOutputNotify cb,
-                            void *data);
+int setNPU_requestCallback (npudev_h dev, int req_id, npuOutputNotify cb, void *data);
 
 /**
  * @brief Set the request's inference mode
@@ -574,8 +563,7 @@ int setNPU_requestMode (npudev_h dev, int req_id, npu_infer_mode mode);
  * @return 0 if no error. Otherwise a negative errno
  * @note if this is not called, the default values are used (see typedef.h).
  */
-int setNPU_requestConstraint (npudev_h dev, int req_id,
-                              npu_constraint constraint);
+int setNPU_requestConstraint (npudev_h dev, int req_id, npu_constraint constraint);
 
 /**
  * @brief [OPTIONAL] Set the request's scheduler
index d2b54f1..11f4eb0 100644 (file)
@@ -167,8 +167,7 @@ convert_data_type (const tensor_type &type) {
 }
 
 void
-TensorFilterSRNPU::set_data_info (tensors_data_info *in_info,
-                                  tensors_data_info *out_info) {
+TensorFilterSRNPU::set_data_info (tensors_data_info *in_info, tensors_data_info *out_info) {
   in_info->num_info = model_meta_->input_seg_num;
 
   for (uint32_t idx = 0; idx < in_info->num_info; ++idx) {
@@ -185,8 +184,7 @@ TensorFilterSRNPU::set_data_info (tensors_data_info *in_info,
 }
 
 void
-TensorFilterSRNPU::feed_input_data (const GstTensorMemory *input,
-                                    input_buffers *input_buf) {
+TensorFilterSRNPU::feed_input_data (const GstTensorMemory *input, input_buffers *input_buf) {
   input_buf->num_buffers = model_meta_->input_seg_num;
 
   for (uint32_t idx = 0; idx < input_buf->num_buffers; ++idx) {
@@ -197,8 +195,7 @@ TensorFilterSRNPU::feed_input_data (const GstTensorMemory *input,
 }
 
 void
-TensorFilterSRNPU::extract_output_data (const output_buffers *output_buf,
-                                        GstTensorMemory *output) {
+TensorFilterSRNPU::extract_output_data (const output_buffers *output_buf, GstTensorMemory *output) {
   /* internal logic error */
   assert (output_buf->num_buffers == model_meta_->output_seg_num);
 
@@ -209,15 +206,13 @@ TensorFilterSRNPU::extract_output_data (const output_buffers *output_buf,
 }
 
 void
-TensorFilterSRNPU::invoke (const GstTensorMemory *input,
-                           GstTensorMemory *output) {
+TensorFilterSRNPU::invoke (const GstTensorMemory *input, GstTensorMemory *output) {
   int req_id;
   int status;
 
   status = createNPU_request (dev_, model_id_, &req_id);
   if (status != 0) {
-    ml_loge ("Unable to create NPU request with model id (%u): %d", model_id_,
-             status);
+    ml_loge ("Unable to create NPU request with model id (%u): %d", model_id_, status);
     return;
   }
 
@@ -231,8 +226,7 @@ TensorFilterSRNPU::invoke (const GstTensorMemory *input,
   /* feed input data to npu-engine */
   feed_input_data (input, &input_buf);
 
-  status = setNPU_requestData (dev_, req_id, &input_buf, &in_info, &output_buf,
-                               &out_info);
+  status = setNPU_requestData (dev_, req_id, &input_buf, &in_info, &output_buf, &out_info);
   if (status != 0) {
     ml_loge ("Unable to create NPU request for model %u", model_id_);
     return;
@@ -277,15 +271,13 @@ TensorFilterSRNPU::getModelInfo (model_info_ops ops, GstTensorsInfo &in_info,
 }
 
 int
-TensorFilterSRNPU::eventHandler (event_ops ops,
-                                 GstTensorFilterFrameworkEventData &data) {
+TensorFilterSRNPU::eventHandler (event_ops ops, GstTensorFilterFrameworkEventData &data) {
   return -ENOENT;
 }
 
 void
 TensorFilterSRNPU::init_filter_srnpu () {
-  registered =
-      tensor_filter_subplugin::register_subplugin<TensorFilterSRNPU> ();
+  registered = tensor_filter_subplugin::register_subplugin<TensorFilterSRNPU> ();
 }
 
 void
index ecb8932..71a5f2f 100644 (file)
@@ -51,8 +51,7 @@ class TensorFilterSRNPU : public tensor_filter_subplugin {
   void configure_instance (const GstTensorFilterProperties *prop);
   void invoke (const GstTensorMemory *input, GstTensorMemory *output);
   void getFrameworkInfo (GstTensorFilterFrameworkInfo &info);
-  int getModelInfo (model_info_ops ops, GstTensorsInfo &in_info,
-                    GstTensorsInfo &out_info);
+  int getModelInfo (model_info_ops ops, GstTensorsInfo &in_info, GstTensorsInfo &out_info);
   int eventHandler (event_ops ops, GstTensorFilterFrameworkEventData &data);
 
   /* static methods */
@@ -62,8 +61,7 @@ class TensorFilterSRNPU : public tensor_filter_subplugin {
  private:
   void set_data_info (tensors_data_info *in_info, tensors_data_info *out_info);
   void feed_input_data (const GstTensorMemory *input, input_buffers *input_buf);
-  void extract_output_data (const output_buffers *output_buf,
-                            GstTensorMemory *output);
+  void extract_output_data (const output_buffers *output_buf, GstTensorMemory *output);
 
   static TensorFilterSRNPU *registered;
   static const char *name;
index 298e6ff..7b4ad07 100644 (file)
@@ -181,8 +181,7 @@ append_device (gpointer data, gpointer user_data) {
   npumgr_devices_id *devices = (npumgr_devices_id *) user_data;
   NpumgrDevice *device = pdata->device;
 
-  NPUMGR_DEVICE_GET_CLASS (device)->device_get_capabilities (
-      device, &pdata->caps, &pdata->ptype);
+  NPUMGR_DEVICE_GET_CLASS (device)->device_get_capabilities (device, &pdata->caps, &pdata->ptype);
 
   devices->types[devices->n_devices] = pdata->ptype;
   devices->id[devices->n_devices] = pdata->id;
@@ -225,8 +224,7 @@ find_context (npumgr_context handle) {
   NpumgrContext *context;
 
   G_LOCK (mutex);
-  context = (NpumgrContext *) g_hash_table_lookup (ctx_table,
-                                                   GSIZE_TO_POINTER (handle));
+  context = (NpumgrContext *) g_hash_table_lookup (ctx_table, GSIZE_TO_POINTER (handle));
   G_UNLOCK (mutex);
 
   return context;
@@ -236,9 +234,8 @@ find_context (npumgr_context handle) {
  * @brief Method callback
  */
 static void
-handle_method_call (GDBusConnection *connection, const gchar *sender,
-                    const gchar *object_path, const gchar *interface_name,
-                    const gchar *method_name, GVariant *parameters,
+handle_method_call (GDBusConnection *connection, const gchar *sender, const gchar *object_path,
+                    const gchar *interface_name, const gchar *method_name, GVariant *parameters,
                     GDBusMethodInvocation *invocation, gpointer user_data) {
   if (g_strcmp0 (method_name, "DeviceGetAvailableList") == 0) {
     GVariantBuilder builder, builder_arr;
@@ -252,34 +249,29 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
     g_variant_builder_init (&builder_arr, G_VARIANT_TYPE ("ai"));
     for (int i = 0; i < devices.n_devices; i++)
       g_variant_builder_add (&builder_arr, "i", ((int *) devices.types)[i]);
-    g_variant_builder_add_value (&builder,
-                                 g_variant_builder_end (&builder_arr));
+    g_variant_builder_add_value (&builder, g_variant_builder_end (&builder_arr));
 
     g_variant_builder_init (&builder_arr, G_VARIANT_TYPE ("au"));
     for (int i = 0; i < devices.n_devices; i++)
       g_variant_builder_add (&builder_arr, "u", ((int *) devices.id)[i]);
-    g_variant_builder_add_value (&builder,
-                                 g_variant_builder_end (&builder_arr));
+    g_variant_builder_add_value (&builder, g_variant_builder_end (&builder_arr));
 
-    g_dbus_method_invocation_return_value (invocation,
-                                           g_variant_builder_end (&builder));
+    g_dbus_method_invocation_return_value (invocation, g_variant_builder_end (&builder));
   } else if (g_strcmp0 (method_name, "ContextCreate") == 0) {
     int device_id = -1;
     int priority = -1;
 
     g_variant_get (parameters, "(ii)", &device_id, &priority);
     if (device_id < 0 || priority < 0) {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
       return;
     }
 
-    plugin_pdata *pdata =
-        (plugin_pdata *) g_slist_nth_data (registered_plugins, device_id);
+    plugin_pdata *pdata = (plugin_pdata *) g_slist_nth_data (registered_plugins, device_id);
     if (pdata == NULL) {
-      g_dbus_method_invocation_return_error (
-          invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Invalid device id");
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
+                                             "Invalid device id");
       return;
     }
 
@@ -287,8 +279,8 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
     npumgr_context handle;
     npumgr_status_e status;
 
-    status = NPUMGR_DEVICE_GET_CLASS (device)->context_create (
-        device, device_id, priority, &handle);
+    status =
+        NPUMGR_DEVICE_GET_CLASS (device)->context_create (device, device_id, priority, &handle);
     if (status == NPUMGR_STATUS_SUCCESS) {
       NpumgrContext *ctx;
 
@@ -297,8 +289,7 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
       ctx->device = device;
 
       if (insert_context (handle, ctx)) {
-        g_dbus_method_invocation_return_value (invocation,
-                                               g_variant_new ("(t)", handle));
+        g_dbus_method_invocation_return_value (invocation, g_variant_new ("(t)", handle));
       } else {
         g_dbus_method_invocation_return_error (
             invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
@@ -307,9 +298,8 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
         g_free (ctx);
       }
     } else {
-      g_dbus_method_invocation_return_error (
-          invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
-          "Unable to add context: internal errors");
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
+                                             "Unable to add context: internal errors");
     }
   } else if (g_strcmp0 (method_name, "ContextDestroy") == 0) {
     npumgr_context handle = 0;
@@ -319,12 +309,10 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
       if (remove_context (handle))
         g_dbus_method_invocation_return_value (invocation, NULL);
       else
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                               "Unable to find the context");
+        g_dbus_method_invocation_return_error (
+            invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the context");
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   } else if (g_strcmp0 (method_name, "NetworkCreate") == 0) {
@@ -336,17 +324,15 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
     GVariant *in_tensor_names_var;
     GVariant *out_tensor_names_var;
 
-    g_variant_get (parameters, "(tiatiiviiv)", &ctx_handle, &num_files,
-                   &input_files_iter, &in_buffer_type, &in_tensor_cnt,
-                   &in_tensor_names_var, &out_buffer_type, &out_tensor_cnt,
-                   &out_tensor_names_var);
+    g_variant_get (parameters, "(tiatiiviiv)", &ctx_handle, &num_files, &input_files_iter,
+                   &in_buffer_type, &in_tensor_cnt, &in_tensor_names_var, &out_buffer_type,
+                   &out_tensor_cnt, &out_tensor_names_var);
 
     if (ctx_handle > 0 && num_files > 0 && in_tensor_cnt < NPUMGR_MAX_DIMS &&
         out_tensor_cnt < NPUMGR_MAX_DIMS) {
       NpumgrContext *context = find_context (ctx_handle);
       if (context == NULL) {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_FAILED,
+        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
                                                "Unable to find context");
         return;
       }
@@ -363,16 +349,14 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
       g_variant_iter_free (input_files_iter);
 
       gchar **in_tensor_names = g_variant_dup_strv (in_tensor_names_var, NULL);
-      gchar **out_tensor_names =
-          g_variant_dup_strv (out_tensor_names_var, NULL);
+      gchar **out_tensor_names = g_variant_dup_strv (out_tensor_names_var, NULL);
 
       npumgr_network nw_handle;
       npumgr_status_e status;
 
       status = NPUMGR_DEVICE_GET_CLASS (device)->network_create (
-          device, ctx_handle, num_files, input_files_vec.data (),
-          in_buffer_type, in_tensor_cnt, in_tensor_names, out_buffer_type,
-          out_tensor_cnt, out_tensor_names, &nw_handle);
+          device, ctx_handle, num_files, input_files_vec.data (), in_buffer_type, in_tensor_cnt,
+          in_tensor_names, out_buffer_type, out_tensor_cnt, out_tensor_names, &nw_handle);
 
       g_strfreev (in_tensor_names);
       g_strfreev (out_tensor_names);
@@ -380,16 +364,13 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
       g_variant_unref (out_tensor_names_var);
 
       if (status == NPUMGR_STATUS_SUCCESS) {
-        g_dbus_method_invocation_return_value (
-            invocation, g_variant_new ("(t)", nw_handle));
+        g_dbus_method_invocation_return_value (invocation, g_variant_new ("(t)", nw_handle));
       } else {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_FAILED,
+        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
                                                "Unable to add network");
       }
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   } else if (g_strcmp0 (method_name, "NetworkSetInput") == 0) {
@@ -398,8 +379,8 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
     GVariant *variant = NULL;
     int index = -1;
 
-    g_variant_get (parameters, "(ttiv)", (guint64 *) &ctx_handle,
-                   (guint64 *) &nw_handle, &index, &variant);
+    g_variant_get (parameters, "(ttiv)", (guint64 *) &ctx_handle, (guint64 *) &nw_handle, &index,
+                   &variant);
     if (ctx_handle > 0 && nw_handle > 0 && index >= 0 && variant != NULL) {
       NpumgrContext *context = find_context (ctx_handle);
       if (context != NULL) {
@@ -410,9 +391,8 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
 
         bytes = g_variant_get_data_as_bytes (variant);
         if (g_bytes_get_size (bytes) != sizeof (buffer)) {
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_INVALID_ARGS,
-                                                 "Invalid arguments detected");
+          g_dbus_method_invocation_return_error (
+              invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid arguments detected");
           g_bytes_unref (bytes);
           return;
         }
@@ -420,22 +400,19 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
         memcpy (&buffer, g_bytes_get_data (bytes, NULL), sizeof (buffer));
         g_bytes_unref (bytes);
 
-        status = NPUMGR_DEVICE_GET_CLASS (device)->network_set_input (
-            device, ctx_handle, nw_handle, index, &buffer);
+        status = NPUMGR_DEVICE_GET_CLASS (device)->network_set_input (device, ctx_handle, nw_handle,
+                                                                      index, &buffer);
         if (status == NPUMGR_STATUS_SUCCESS)
           g_dbus_method_invocation_return_value (invocation, NULL);
         else
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                                 "Unable to set the input");
+          g_dbus_method_invocation_return_error (
+              invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to set the input");
       } else {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                               "Unable to find the context");
+        g_dbus_method_invocation_return_error (
+            invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the context");
       }
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   } else if (g_strcmp0 (method_name, "NetworkSetOutput") == 0) {
@@ -444,8 +421,8 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
     GVariant *variant = NULL;
     int index = -1;
 
-    g_variant_get (parameters, "(ttiv)", (guint64 *) &ctx_handle,
-                   (guint64 *) &nw_handle, &index, &variant);
+    g_variant_get (parameters, "(ttiv)", (guint64 *) &ctx_handle, (guint64 *) &nw_handle, &index,
+                   &variant);
     if (ctx_handle > 0 && nw_handle > 0 && index >= 0 && variant != NULL) {
       NpumgrContext *context = find_context (ctx_handle);
       if (context != NULL) {
@@ -456,9 +433,8 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
 
         bytes = g_variant_get_data_as_bytes (variant);
         if (g_bytes_get_size (bytes) != sizeof (buffer)) {
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_INVALID_ARGS,
-                                                 "Invalid arguments detected");
+          g_dbus_method_invocation_return_error (
+              invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid arguments detected");
           g_bytes_unref (bytes);
           return;
         }
@@ -466,90 +442,77 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
         memcpy (&buffer, g_bytes_get_data (bytes, NULL), sizeof (buffer));
         g_bytes_unref (bytes);
 
-        status = NPUMGR_DEVICE_GET_CLASS (device)->network_set_output (
-            device, ctx_handle, nw_handle, index, &buffer);
+        status = NPUMGR_DEVICE_GET_CLASS (device)->network_set_output (device, ctx_handle,
+                                                                       nw_handle, index, &buffer);
         if (status == NPUMGR_STATUS_SUCCESS)
           g_dbus_method_invocation_return_value (invocation, NULL);
         else
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                                 "Unable to set the output");
+          g_dbus_method_invocation_return_error (
+              invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to set the output");
       } else {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                               "Unable to find the context");
+        g_dbus_method_invocation_return_error (
+            invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the context");
       }
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   } else if (g_strcmp0 (method_name, "NetworkPrepare") == 0) {
     npumgr_context ctx_handle = 0;
     npumgr_network nw_handle = 0;
 
-    g_variant_get (parameters, "(tt)", (guint64 *) &ctx_handle,
-                   (guint64 *) &nw_handle);
+    g_variant_get (parameters, "(tt)", (guint64 *) &ctx_handle, (guint64 *) &nw_handle);
     if (ctx_handle > 0 && nw_handle > 0) {
       NpumgrContext *context = find_context (ctx_handle);
       if (context != NULL) {
         NpumgrDevice *device = context->device;
         npumgr_status_e status;
 
-        status = NPUMGR_DEVICE_GET_CLASS (device)->network_prepare (
-            device, ctx_handle, nw_handle);
+        status = NPUMGR_DEVICE_GET_CLASS (device)->network_prepare (device, ctx_handle, nw_handle);
         if (status == NPUMGR_STATUS_SUCCESS)
           g_dbus_method_invocation_return_value (invocation, NULL);
         else
-          g_dbus_method_invocation_return_error (
-              invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT,
-              "Unable to prepare network execution");
+          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+                                                 G_DBUS_ERROR_UNKNOWN_OBJECT,
+                                                 "Unable to prepare network execution");
       } else {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                               "Unable to find the context");
+        g_dbus_method_invocation_return_error (
+            invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the context");
       }
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   } else if (g_strcmp0 (method_name, "NetworkDestroy") == 0) {
     npumgr_context ctx_handle = 0;
     npumgr_network nw_handle = 0;
 
-    g_variant_get (parameters, "(tt)", (guint64 *) &ctx_handle,
-                   (guint64 *) &nw_handle);
+    g_variant_get (parameters, "(tt)", (guint64 *) &ctx_handle, (guint64 *) &nw_handle);
     if (ctx_handle > 0 && nw_handle > 0) {
       NpumgrContext *context = find_context (ctx_handle);
       if (context != NULL) {
         NpumgrDevice *device = context->device;
         npumgr_status_e status;
 
-        status = NPUMGR_DEVICE_GET_CLASS (device)->network_destroy (
-            device, ctx_handle, nw_handle);
+        status = NPUMGR_DEVICE_GET_CLASS (device)->network_destroy (device, ctx_handle, nw_handle);
         if (status == NPUMGR_STATUS_SUCCESS)
           g_dbus_method_invocation_return_value (invocation, NULL);
         else
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                                 "Unable to find the network");
+          g_dbus_method_invocation_return_error (
+              invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the network");
       } else {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                               "Unable to find the context");
+        g_dbus_method_invocation_return_error (
+            invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the context");
       }
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   } else if (g_strcmp0 (method_name, "QueryNetwork") == 0) {
     npumgr_context ctx_handle = 0;
     npumgr_network nw_handle = 0;
 
-    g_variant_get (parameters, "(tt)", (guint64 *) &ctx_handle,
-                   (guint64 *) &nw_handle);
+    g_variant_get (parameters, "(tt)", (guint64 *) &ctx_handle, (guint64 *) &nw_handle);
     if (ctx_handle > 0 && nw_handle > 0) {
       NpumgrContext *context = find_context (ctx_handle);
       if (context != NULL) {
@@ -557,24 +520,21 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
         npumgr_status_e status;
 
         npumgr_query_inout_num data;
-        status = NPUMGR_DEVICE_GET_CLASS (device)->query_network (
-            device, ctx_handle, nw_handle, &data);
+        status =
+            NPUMGR_DEVICE_GET_CLASS (device)->query_network (device, ctx_handle, nw_handle, &data);
         if (status == NPUMGR_STATUS_SUCCESS) {
           g_dbus_method_invocation_return_value (
               invocation, g_variant_new ("(uu)", data.n_input, data.n_output));
         } else {
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                                 "Unable to find the network");
+          g_dbus_method_invocation_return_error (
+              invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the network");
         }
       } else {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                               "Unable to find the context");
+        g_dbus_method_invocation_return_error (
+            invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the context");
       }
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   } else if (g_strcmp0 (method_name, "QueryInput") == 0) {
@@ -582,8 +542,7 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
     npumgr_network nw_handle = 0;
     int index = -1;
 
-    g_variant_get (parameters, "(tti)", (guint64 *) &ctx_handle,
-                   (guint64 *) &nw_handle, &index);
+    g_variant_get (parameters, "(tti)", (guint64 *) &ctx_handle, (guint64 *) &nw_handle, &index);
     if (ctx_handle > 0 && nw_handle > 0 && index >= 0) {
       NpumgrContext *context = find_context (ctx_handle);
       if (context != NULL) {
@@ -591,28 +550,23 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
         npumgr_status_e status;
 
         npumgr_query_tensor_attr data;
-        status = NPUMGR_DEVICE_GET_CLASS (device)->query_input (
-            device, ctx_handle, nw_handle, index, &data);
+        status = NPUMGR_DEVICE_GET_CLASS (device)->query_input (device, ctx_handle, nw_handle,
+                                                                index, &data);
         if (status == NPUMGR_STATUS_SUCCESS) {
           GBytes *bytes = g_bytes_new (&data, sizeof (data));
-          GVariant *variant =
-              g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), bytes, TRUE);
-          g_dbus_method_invocation_return_value (
-              invocation, g_variant_new ("(v)", variant));
+          GVariant *variant = g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), bytes, TRUE);
+          g_dbus_method_invocation_return_value (invocation, g_variant_new ("(v)", variant));
           g_bytes_unref (bytes);
         } else {
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_FAILED,
+          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
                                                  "Unable to find input attr");
         }
       } else {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                               "Unable to find the context");
+        g_dbus_method_invocation_return_error (
+            invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the context");
       }
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   } else if (g_strcmp0 (method_name, "QueryOutput") == 0) {
@@ -620,8 +574,7 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
     npumgr_network nw_handle = 0;
     int index = -1;
 
-    g_variant_get (parameters, "(tti)", (guint64 *) &ctx_handle,
-                   (guint64 *) &nw_handle, &index);
+    g_variant_get (parameters, "(tti)", (guint64 *) &ctx_handle, (guint64 *) &nw_handle, &index);
     if (ctx_handle > 0 && nw_handle > 0 && index >= 0) {
       NpumgrContext *context = find_context (ctx_handle);
       if (context != NULL) {
@@ -629,28 +582,23 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
         npumgr_status_e status;
 
         npumgr_query_tensor_attr data;
-        status = NPUMGR_DEVICE_GET_CLASS (device)->query_output (
-            device, ctx_handle, nw_handle, index, &data);
+        status = NPUMGR_DEVICE_GET_CLASS (device)->query_output (device, ctx_handle, nw_handle,
+                                                                 index, &data);
         if (status == NPUMGR_STATUS_SUCCESS) {
           GBytes *bytes = g_bytes_new (&data, sizeof (data));
-          GVariant *variant =
-              g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), bytes, TRUE);
-          g_dbus_method_invocation_return_value (
-              invocation, g_variant_new ("(v)", variant));
+          GVariant *variant = g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), bytes, TRUE);
+          g_dbus_method_invocation_return_value (invocation, g_variant_new ("(v)", variant));
           g_bytes_unref (bytes);
         } else {
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_FAILED,
+          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
                                                  "Unable to find output attr");
         }
       } else {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                               "Unable to find the context");
+        g_dbus_method_invocation_return_error (
+            invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the context");
       }
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   } else if (g_strcmp0 (method_name, "BufferCreate") == 0) {
@@ -668,9 +616,8 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
 
         GBytes *bytes = g_variant_get_data_as_bytes (variant);
         if (g_bytes_get_size (bytes) != sizeof (param)) {
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_INVALID_ARGS,
-                                                 "Invalid arguments detected");
+          g_dbus_method_invocation_return_error (
+              invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid arguments detected");
           g_bytes_unref (bytes);
           return;
         }
@@ -678,28 +625,22 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
         memcpy (&param, g_bytes_get_data (bytes, NULL), sizeof (param));
         g_bytes_unref (bytes);
 
-        status = NPUMGR_DEVICE_GET_CLASS (device)->buffer_create (
-            device, ctx_handle, &param, &buf);
+        status = NPUMGR_DEVICE_GET_CLASS (device)->buffer_create (device, ctx_handle, &param, &buf);
         if (status == NPUMGR_STATUS_SUCCESS) {
           bytes = g_bytes_new (&buf, sizeof (buf));
-          variant =
-              g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), bytes, TRUE);
-          g_dbus_method_invocation_return_value (
-              invocation, g_variant_new ("(v)", variant));
+          variant = g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), bytes, TRUE);
+          g_dbus_method_invocation_return_value (invocation, g_variant_new ("(v)", variant));
           g_bytes_unref (bytes);
         } else {
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_FAILED,
+          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
                                                  "Unable to create buffer");
         }
       } else {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                               "Unable to find the context");
+        g_dbus_method_invocation_return_error (
+            invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the context");
       }
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   } else if (g_strcmp0 (method_name, "BufferMap") == 0) {
@@ -717,9 +658,8 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
 
         GBytes *bytes = g_variant_get_data_as_bytes (variant);
         if (g_bytes_get_size (bytes) != sizeof (buf)) {
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_INVALID_ARGS,
-                                                 "Invalid arguments detected");
+          g_dbus_method_invocation_return_error (
+              invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid arguments detected");
           g_bytes_unref (bytes);
           return;
         }
@@ -728,31 +668,26 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
         g_bytes_unref (bytes);
 
         /* TODO: how to deliver this addr to client? */
-        status = NPUMGR_DEVICE_GET_CLASS (device)->buffer_map (
-            device, ctx_handle, &buf, &addr);
+        status = NPUMGR_DEVICE_GET_CLASS (device)->buffer_map (device, ctx_handle, &buf, &addr);
         if (status == NPUMGR_STATUS_SUCCESS) {
           GUnixFDList *fd_list = g_unix_fd_list_new ();
           g_unix_fd_list_append (fd_list, buf.buf_fd, NULL);
 
           bytes = g_bytes_new (&buf, sizeof (buf));
-          variant =
-              g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), bytes, TRUE);
+          variant = g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), bytes, TRUE);
           g_dbus_method_invocation_return_value_with_unix_fd_list (
               invocation, g_variant_new ("(v)", variant), fd_list);
           g_bytes_unref (bytes);
         } else {
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_FAILED,
+          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
                                                  "Unable to map buffer");
         }
       } else {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                               "Unable to find the context");
+        g_dbus_method_invocation_return_error (
+            invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the context");
       }
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   } else if (g_strcmp0 (method_name, "BufferDestroy") == 0) {
@@ -769,9 +704,8 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
 
         GBytes *bytes = g_variant_get_data_as_bytes (variant);
         if (g_bytes_get_size (bytes) != sizeof (buf)) {
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_INVALID_ARGS,
-                                                 "Invalid arguments detected");
+          g_dbus_method_invocation_return_error (
+              invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid arguments detected");
           g_bytes_unref (bytes);
           return;
         }
@@ -779,116 +713,97 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
         memcpy (&buf, g_bytes_get_data (bytes, NULL), sizeof (buf));
         g_bytes_unref (bytes);
 
-        status = NPUMGR_DEVICE_GET_CLASS (device)->buffer_destroy (
-            device, ctx_handle, &buf);
+        status = NPUMGR_DEVICE_GET_CLASS (device)->buffer_destroy (device, ctx_handle, &buf);
         if (status == NPUMGR_STATUS_SUCCESS) {
           g_dbus_method_invocation_return_value (invocation, NULL);
         } else {
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_FAILED,
+          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
                                                  "Unable to destroy buffer");
         }
       } else {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                               "Unable to find the context");
+        g_dbus_method_invocation_return_error (
+            invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the context");
       }
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   } else if (g_strcmp0 (method_name, "ExecuteTrigger") == 0) {
     npumgr_context ctx_handle = 0;
     npumgr_network nw_handle = 0;
 
-    g_variant_get (parameters, "(tt)", (guint64 *) &ctx_handle,
-                   (guint64 *) &nw_handle);
+    g_variant_get (parameters, "(tt)", (guint64 *) &ctx_handle, (guint64 *) &nw_handle);
     if (ctx_handle > 0 && nw_handle > 0) {
       NpumgrContext *context = find_context (ctx_handle);
       if (context != NULL) {
         NpumgrDevice *device = context->device;
         npumgr_status_e status;
 
-        status = NPUMGR_DEVICE_GET_CLASS (device)->execute_trigger (
-            device, ctx_handle, nw_handle);
+        status = NPUMGR_DEVICE_GET_CLASS (device)->execute_trigger (device, ctx_handle, nw_handle);
         if (status == NPUMGR_STATUS_SUCCESS) {
           g_dbus_method_invocation_return_value (invocation, NULL);
         } else {
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_FAILED,
+          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
                                                  "Unable to execute network");
         }
       } else {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                               "Unable to find the context");
+        g_dbus_method_invocation_return_error (
+            invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the context");
       }
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   } else if (g_strcmp0 (method_name, "ExecuteWait") == 0) {
     npumgr_context ctx_handle = 0;
     npumgr_network nw_handle = 0;
 
-    g_variant_get (parameters, "(tt)", (guint64 *) &ctx_handle,
-                   (guint64 *) &nw_handle);
+    g_variant_get (parameters, "(tt)", (guint64 *) &ctx_handle, (guint64 *) &nw_handle);
     if (ctx_handle > 0 && nw_handle > 0) {
       NpumgrContext *context = find_context (ctx_handle);
       if (context != NULL) {
         NpumgrDevice *device = context->device;
         npumgr_status_e status;
 
-        status = NPUMGR_DEVICE_GET_CLASS (device)->execute_wait (
-            device, ctx_handle, nw_handle);
+        status = NPUMGR_DEVICE_GET_CLASS (device)->execute_wait (device, ctx_handle, nw_handle);
         if (status == NPUMGR_STATUS_SUCCESS) {
           g_dbus_method_invocation_return_value (invocation, NULL);
         } else {
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_FAILED,
+          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
                                                  "Unable to finish execution");
         }
       } else {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                               "Unable to find the context");
+        g_dbus_method_invocation_return_error (
+            invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the context");
       }
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   } else if (g_strcmp0 (method_name, "ExecuteRun") == 0) {
     npumgr_context ctx_handle = 0;
     npumgr_network nw_handle = 0;
 
-    g_variant_get (parameters, "(tt)", (guint64 *) &ctx_handle,
-                   (guint64 *) &nw_handle);
+    g_variant_get (parameters, "(tt)", (guint64 *) &ctx_handle, (guint64 *) &nw_handle);
     if (ctx_handle > 0 && nw_handle > 0) {
       NpumgrContext *context = find_context (ctx_handle);
       if (context != NULL) {
         NpumgrDevice *device = context->device;
         npumgr_status_e status;
 
-        status = NPUMGR_DEVICE_GET_CLASS (device)->execute_run (
-            device, ctx_handle, nw_handle);
+        status = NPUMGR_DEVICE_GET_CLASS (device)->execute_run (device, ctx_handle, nw_handle);
         if (status == NPUMGR_STATUS_SUCCESS) {
           g_dbus_method_invocation_return_value (invocation, NULL);
         } else {
-          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                                 G_DBUS_ERROR_FAILED,
+          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
                                                  "Unable to execute network");
         }
       } else {
-        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                               G_DBUS_ERROR_UNKNOWN_OBJECT,
-                                               "Unable to find the context");
+        g_dbus_method_invocation_return_error (
+            invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_OBJECT, "Unable to find the context");
       }
     } else {
-      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                             G_DBUS_ERROR_INVALID_ARGS,
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                              "Invalid arguments detected");
     }
   }
@@ -898,9 +813,8 @@ handle_method_call (GDBusConnection *connection, const gchar *sender,
  * @brief Set property callback
  */
 static GVariant *
-handle_get_property (GDBusConnection *connection, const gchar *sender,
-                     const gchar *object_path, const gchar *interface_name,
-                     const gchar *property_name, GError **error,
+handle_get_property (GDBusConnection *connection, const gchar *sender, const gchar *object_path,
+                     const gchar *interface_name, const gchar *property_name, GError **error,
                      gpointer user_data) {
   /* NYI */
   return NULL;
@@ -910,9 +824,8 @@ handle_get_property (GDBusConnection *connection, const gchar *sender,
  * @brief Set property callback
  */
 static gboolean
-handle_set_property (GDBusConnection *connection, const gchar *sender,
-                     const gchar *object_path, const gchar *interface_name,
-                     const gchar *property_name, GVariant *value,
+handle_set_property (GDBusConnection *connection, const gchar *sender, const gchar *object_path,
+                     const gchar *interface_name, const gchar *property_name, GVariant *value,
                      GError **error, gpointer user_data) {
   /* NYI */
   return FALSE;
@@ -921,20 +834,19 @@ handle_set_property (GDBusConnection *connection, const gchar *sender,
 /**
  * @brief VTable of GDBus Interface
  */
-static const GDBusInterfaceVTable interface_vtable = {
-    handle_method_call, handle_get_property, handle_set_property};
+static const GDBusInterfaceVTable interface_vtable = {handle_method_call, handle_get_property,
+                                                      handle_set_property};
 
 /**
  * @brief Callback on the bus connect has been obtained
  */
 static void
-on_bus_acquired (GDBusConnection *connection, const gchar *name,
-                 gpointer user_data) {
+on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) {
   guint reg_id;
 
-  reg_id = g_dbus_connection_register_object (
-      connection, "/sr/odl/NPUManager/APIObject",
-      introspection_data->interfaces[0], &interface_vtable, NULL, NULL, NULL);
+  reg_id = g_dbus_connection_register_object (connection, "/sr/odl/NPUManager/APIObject",
+                                              introspection_data->interfaces[0], &interface_vtable,
+                                              NULL, NULL, NULL);
   if (reg_id == 0)
     loge ("Failed to register object");
 }
@@ -943,15 +855,13 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name,
  * @brief Callback on the name is acquired
  */
 static void
-on_name_acquired (GDBusConnection *connection, const gchar *name,
-                  gpointer user_data) {}
+on_name_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) {}
 
 /**
  * @brief Callback on the name is lost or connection has been closed
  */
 static void
-on_name_lost (GDBusConnection *connection, const gchar *name,
-              gpointer user_data) {
+on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data) {
   loge ("Unable to acquire name %s", name);
   exit (EXIT_FAILURE);
 }
@@ -1040,11 +950,10 @@ start_npumgr (void) {
 
   init_plugins ();
 
-  ctx_table =
-      g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, ctx_destroy);
-  owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM, "sr.odl.NPUManager.API",
-                             G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired,
-                             on_name_acquired, on_name_lost, NULL, NULL);
+  ctx_table = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, ctx_destroy);
+  owner_id =
+      g_bus_own_name (G_BUS_TYPE_SYSTEM, "sr.odl.NPUManager.API", G_BUS_NAME_OWNER_FLAGS_NONE,
+                      on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
 
   loop = g_main_loop_new (NULL, FALSE);
   g_main_loop_run (loop);
index 28dce58..91949b3 100644 (file)
@@ -67,22 +67,19 @@ npumgr_device_get_available_list (npumgr_devices_id *pdev) {
   g_return_val_if_fail (pdev != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "DeviceGetAvailableList");
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "DeviceGetAvailableList");
   g_dbus_message_set_body (method_call, NULL);
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   if (method_reply == NULL) {
     status = NPUMGR_STATUS_ERR_FAIL;
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -95,8 +92,8 @@ npumgr_device_get_available_list (npumgr_devices_id *pdev) {
     GVariantIter *iter_id;
     uint32_t idx;
 
-    g_variant_get (g_dbus_message_get_body (method_reply), "(uaiau)",
-                   &pdev->n_devices, &iter_type, &iter_id);
+    g_variant_get (g_dbus_message_get_body (method_reply), "(uaiau)", &pdev->n_devices, &iter_type,
+                   &iter_id);
 
     if (pdev->n_devices > NPUMGR_MAX_DEVICES) {
       g_critical ("Too many devices: %u", pdev->n_devices);
@@ -105,13 +102,11 @@ npumgr_device_get_available_list (npumgr_devices_id *pdev) {
     }
 
     idx = 0;
-    while (idx < NPUMGR_MAX_DEVICES &&
-           g_variant_iter_loop (iter_type, "i", &pdev->types[idx++]))
+    while (idx < NPUMGR_MAX_DEVICES && g_variant_iter_loop (iter_type, "i", &pdev->types[idx++]))
       ;
 
     idx = 0;
-    while (idx < NPUMGR_MAX_DEVICES &&
-           g_variant_iter_loop (iter_id, "u", &pdev->id[idx++]))
+    while (idx < NPUMGR_MAX_DEVICES && g_variant_iter_loop (iter_id, "u", &pdev->id[idx++]))
       ;
 
   out_iter:
@@ -138,23 +133,19 @@ npumgr_context_create (int device_id, int priority, npumgr_context *out_ctx) {
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "ContextCreate");
-  g_dbus_message_set_body (method_call,
-                           g_variant_new ("(ii)", device_id, priority));
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "ContextCreate");
+  g_dbus_message_set_body (method_call, g_variant_new ("(ii)", device_id, priority));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   if (method_reply == NULL) {
     status = NPUMGR_STATUS_ERR_FAIL;
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -183,22 +174,19 @@ npumgr_context_destroy (npumgr_context ctx) {
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "ContextDestroy");
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "ContextDestroy");
   g_dbus_message_set_body (method_call, g_variant_new ("(t)", ctx));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   if (method_reply == NULL) {
     status = NPUMGR_STATUS_ERR_FAIL;
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -217,12 +205,10 @@ out:
  * @brief This API helps in network creation.
  */
 npumgr_status_e
-npumgr_network_create (npumgr_context ctx, int num_files,
-                       npumgr_network_defn *input_files,
+npumgr_network_create (npumgr_context ctx, int num_files, npumgr_network_defn *input_files,
                        npumgr_buffer_t in_buffer_type, int in_tensor_cnt,
-                       const char *const *in_tensor_names,
-                       npumgr_buffer_t out_buffer_type, int out_tensor_cnt,
-                       const char *const *out_tensor_names,
+                       const char *const *in_tensor_names, npumgr_buffer_t out_buffer_type,
+                       int out_tensor_cnt, const char *const *out_tensor_names,
                        npumgr_network *out_nw_handle) {
   GDBusMessage *method_call;
   GDBusMessage *method_reply;
@@ -231,9 +217,8 @@ npumgr_network_create (npumgr_context ctx, int num_files,
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "NetworkCreate");
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "NetworkCreate");
 
   GVariantBuilder builder, builder_arr;
   GUnixFDList *fd_list;
@@ -255,25 +240,21 @@ npumgr_network_create (npumgr_context ctx, int num_files,
   g_variant_builder_add_value (&builder, g_variant_builder_end (&builder_arr));
   g_variant_builder_add (&builder, "i", in_buffer_type);
   g_variant_builder_add (&builder, "i", in_tensor_cnt);
-  g_variant_builder_add (&builder, "v",
-                         g_variant_new_strv (in_tensor_names, in_tensor_cnt));
+  g_variant_builder_add (&builder, "v", g_variant_new_strv (in_tensor_names, in_tensor_cnt));
   g_variant_builder_add (&builder, "i", out_buffer_type);
   g_variant_builder_add (&builder, "i", out_tensor_cnt);
-  g_variant_builder_add (&builder, "v",
-                         g_variant_new_strv (out_tensor_names, out_tensor_cnt));
+  g_variant_builder_add (&builder, "v", g_variant_new_strv (out_tensor_names, out_tensor_cnt));
 
   g_dbus_message_set_body (method_call, g_variant_builder_end (&builder));
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   if (method_reply == NULL) {
     status = NPUMGR_STATUS_ERR_FAIL;
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -294,9 +275,8 @@ out:
  * @brief This API helps in attaching a valid input buffer to the inputs of network.
  */
 npumgr_status_e
-npumgr_network_set_attribute (npumgr_context ctx, npumgr_network nw_handle,
-                              uint32_t wcet_ns, uint32_t deadline_ns,
-                              uint32_t period_ns, uint32_t yield_ns) {
+npumgr_network_set_attribute (npumgr_context ctx, npumgr_network nw_handle, uint32_t wcet_ns,
+                              uint32_t deadline_ns, uint32_t period_ns, uint32_t yield_ns) {
   /* NYI */
   return NPUMGR_STATUS_SUCCESS;
 }
@@ -305,8 +285,8 @@ npumgr_network_set_attribute (npumgr_context ctx, npumgr_network nw_handle,
  * @brief This API helps in attaching a valid input buffer to the inputs of network.
  */
 npumgr_status_e
-npumgr_network_set_input (npumgr_context ctx, npumgr_network nw_handle,
-                          int index, npumgr_buffer *input_buffer) {
+npumgr_network_set_input (npumgr_context ctx, npumgr_network nw_handle, int index,
+                          npumgr_buffer *input_buffer) {
   GDBusMessage *method_call;
   GDBusMessage *method_reply;
   npumgr_status_e status = NPUMGR_STATUS_SUCCESS;
@@ -316,26 +296,22 @@ npumgr_network_set_input (npumgr_context ctx, npumgr_network nw_handle,
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "NetworkSetInput");
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "NetworkSetInput");
 
   bytes = g_bytes_new (input_buffer, sizeof (*input_buffer));
   variant = g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), bytes, TRUE);
-  g_dbus_message_set_body (
-      method_call, g_variant_new ("(ttiv)", ctx, nw_handle, index, variant));
+  g_dbus_message_set_body (method_call, g_variant_new ("(ttiv)", ctx, nw_handle, index, variant));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   if (method_reply == NULL) {
     status = NPUMGR_STATUS_ERR_FAIL;
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -354,8 +330,8 @@ out:
  * @brief This API helps in attaching a valid output buffer to the outputs of network.
  */
 npumgr_status_e
-npumgr_network_set_output (npumgr_context ctx, npumgr_network nw_handle,
-                           int index, npumgr_buffer *output_buffer) {
+npumgr_network_set_output (npumgr_context ctx, npumgr_network nw_handle, int index,
+                           npumgr_buffer *output_buffer) {
   GDBusMessage *method_call;
   GDBusMessage *method_reply;
   npumgr_status_e status = NPUMGR_STATUS_SUCCESS;
@@ -365,26 +341,22 @@ npumgr_network_set_output (npumgr_context ctx, npumgr_network nw_handle,
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "NetworkSetOutput");
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "NetworkSetOutput");
 
   bytes = g_bytes_new (output_buffer, sizeof (*output_buffer));
   variant = g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), bytes, TRUE);
-  g_dbus_message_set_body (
-      method_call, g_variant_new ("(ttiv)", ctx, nw_handle, index, variant));
+  g_dbus_message_set_body (method_call, g_variant_new ("(ttiv)", ctx, nw_handle, index, variant));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   if (method_reply == NULL) {
     status = NPUMGR_STATUS_ERR_FAIL;
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -411,22 +383,19 @@ npumgr_network_prepare (npumgr_context ctx, npumgr_network nw_handle) {
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "NetworkPrepare");
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "NetworkPrepare");
   g_dbus_message_set_body (method_call, g_variant_new ("(tt)", ctx, nw_handle));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   if (method_reply == NULL) {
     status = NPUMGR_STATUS_ERR_FAIL;
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -453,22 +422,19 @@ npumgr_network_destroy (npumgr_context ctx, npumgr_network nw_handle) {
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "NetworkDestroy");
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "NetworkDestroy");
   g_dbus_message_set_body (method_call, g_variant_new ("(tt)", ctx, nw_handle));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   if (method_reply == NULL) {
     status = NPUMGR_STATUS_ERR_FAIL;
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -487,8 +453,7 @@ out:
  * @brief This API helps in buffer creation.
  */
 npumgr_status_e
-npumgr_buffer_create (npumgr_context ctx,
-                      npumgr_query_tensor_attr *create_param,
+npumgr_buffer_create (npumgr_context ctx, npumgr_query_tensor_attr *create_param,
                       npumgr_buffer *buf) {
   GDBusMessage *method_call;
   GDBusMessage *method_reply;
@@ -499,17 +464,15 @@ npumgr_buffer_create (npumgr_context ctx,
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "BufferCreate");
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "BufferCreate");
 
   bytes = g_bytes_new (create_param, sizeof (*create_param));
   variant = g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), bytes, TRUE);
   g_dbus_message_set_body (method_call, g_variant_new ("(tv)", ctx, variant));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   g_bytes_unref (bytes);
 
@@ -518,8 +481,7 @@ npumgr_buffer_create (npumgr_context ctx,
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -561,17 +523,15 @@ npumgr_buffer_destroy (npumgr_context ctx, npumgr_buffer *buf) {
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "BufferDestroy");
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "BufferDestroy");
 
   bytes = g_bytes_new (buf, sizeof (*buf));
   variant = g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), bytes, TRUE);
   g_dbus_message_set_body (method_call, g_variant_new ("(tv)", ctx, variant));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   g_bytes_unref (bytes);
 
@@ -580,8 +540,7 @@ npumgr_buffer_destroy (npumgr_context ctx, npumgr_buffer *buf) {
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -600,8 +559,7 @@ out:
  * @brief This API helps in mapping the buffer to get the CPU accessible address for read or write.
  */
 npumgr_status_e
-npumgr_buffer_map (npumgr_context ctx, npumgr_buffer *buf,
-                   uint8_t **mapped_addr) {
+npumgr_buffer_map (npumgr_context ctx, npumgr_buffer *buf, uint8_t **mapped_addr) {
   GDBusMessage *method_call;
   GDBusMessage *method_reply;
   npumgr_status_e status = NPUMGR_STATUS_SUCCESS;
@@ -612,17 +570,15 @@ npumgr_buffer_map (npumgr_context ctx, npumgr_buffer *buf,
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "BufferMap");
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "BufferMap");
 
   bytes = g_bytes_new (buf, sizeof (*buf));
   variant = g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), bytes, TRUE);
   g_dbus_message_set_body (method_call, g_variant_new ("(tv)", ctx, variant));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   g_bytes_unref (bytes);
 
@@ -631,8 +587,7 @@ npumgr_buffer_map (npumgr_context ctx, npumgr_buffer *buf,
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -653,9 +608,8 @@ npumgr_buffer_map (npumgr_context ctx, npumgr_buffer *buf,
   fd_list = g_dbus_message_get_unix_fd_list (method_reply);
   buf->buf_fd = g_unix_fd_list_get (fd_list, 0, NULL);
 
-  *mapped_addr =
-      (uint8_t *) mmap (NULL, ALIGNED_SIZE (buf->buf_size),
-                        PROT_READ | PROT_WRITE, MAP_SHARED, buf->buf_fd, 0);
+  *mapped_addr = (uint8_t *) mmap (NULL, ALIGNED_SIZE (buf->buf_size), PROT_READ | PROT_WRITE,
+                                   MAP_SHARED, buf->buf_fd, 0);
   if (*mapped_addr == MAP_FAILED)
     status = NPUMGR_STATUS_ERR_FAIL;
 
@@ -682,8 +636,7 @@ npumgr_buffer_unmap (npumgr_context ctx, npumgr_buffer *buf) {
  * @brief This API helps in querying the network for no. of inputs and outputs.
  */
 npumgr_status_e
-npumgr_query_network (npumgr_context ctx, npumgr_network nw_handle,
-                      npumgr_query_inout_num *data) {
+npumgr_query_network (npumgr_context ctx, npumgr_network nw_handle, npumgr_query_inout_num *data) {
   GDBusMessage *method_call;
   GDBusMessage *method_reply;
   npumgr_status_e status = NPUMGR_STATUS_SUCCESS;
@@ -691,22 +644,19 @@ npumgr_query_network (npumgr_context ctx, npumgr_network nw_handle,
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "QueryNetwork");
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "QueryNetwork");
   g_dbus_message_set_body (method_call, g_variant_new ("(tt)", ctx, nw_handle));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   if (method_reply == NULL) {
     status = NPUMGR_STATUS_ERR_FAIL;
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -714,8 +664,7 @@ npumgr_query_network (npumgr_context ctx, npumgr_network nw_handle,
     goto out;
   }
 
-  g_variant_get (g_dbus_message_get_body (method_reply), "(uu)", &data->n_input,
-                 &data->n_output);
+  g_variant_get (g_dbus_message_get_body (method_reply), "(uu)", &data->n_input, &data->n_output);
 
 out:
   g_object_unref (method_call);
@@ -739,23 +688,19 @@ npumgr_query_input (npumgr_context ctx, npumgr_network nw_handle, int index,
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "QueryInput");
-  g_dbus_message_set_body (method_call,
-                           g_variant_new ("(tti)", ctx, nw_handle, index));
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "QueryInput");
+  g_dbus_message_set_body (method_call, g_variant_new ("(tti)", ctx, nw_handle, index));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   if (method_reply == NULL) {
     status = NPUMGR_STATUS_ERR_FAIL;
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -798,23 +743,19 @@ npumgr_query_output (npumgr_context ctx, npumgr_network nw_handle, int index,
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "QueryOutput");
-  g_dbus_message_set_body (method_call,
-                           g_variant_new ("(tti)", ctx, nw_handle, index));
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "QueryOutput");
+  g_dbus_message_set_body (method_call, g_variant_new ("(tti)", ctx, nw_handle, index));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   if (method_reply == NULL) {
     status = NPUMGR_STATUS_ERR_FAIL;
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -855,22 +796,19 @@ npumgr_execute_trigger (npumgr_context ctx, npumgr_network nw_handle) {
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "ExecuteTrigger");
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "ExecuteTrigger");
   g_dbus_message_set_body (method_call, g_variant_new ("(tt)", ctx, nw_handle));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   if (method_reply == NULL) {
     status = NPUMGR_STATUS_ERR_FAIL;
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -897,22 +835,19 @@ npumgr_execute_wait (npumgr_context ctx, npumgr_network nw_handle) {
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "ExecuteWait");
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "ExecuteWait");
   g_dbus_message_set_body (method_call, g_variant_new ("(tt)", ctx, nw_handle));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   if (method_reply == NULL) {
     status = NPUMGR_STATUS_ERR_FAIL;
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -939,22 +874,19 @@ npumgr_execute_run (npumgr_context ctx, npumgr_network nw_handle) {
 
   g_return_val_if_fail (wait_until_connected (), NPUMGR_STATUS_ERR_TIMEOUT);
 
-  method_call = g_dbus_message_new_method_call (
-      _name_owner, "/sr/odl/NPUManager/APIObject", "sr.odl.NPUManager.API",
-      "ExecuteRun");
+  method_call = g_dbus_message_new_method_call (_name_owner, "/sr/odl/NPUManager/APIObject",
+                                                "sr.odl.NPUManager.API", "ExecuteRun");
   g_dbus_message_set_body (method_call, g_variant_new ("(tt)", ctx, nw_handle));
 
   method_reply = g_dbus_connection_send_message_with_reply_sync (
-      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL,
-      &error);
+      _connection, method_call, G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &error);
 
   if (method_reply == NULL) {
     status = NPUMGR_STATUS_ERR_FAIL;
     goto out;
   }
 
-  if (g_dbus_message_get_message_type (method_reply) ==
-      G_DBUS_MESSAGE_TYPE_ERROR) {
+  if (g_dbus_message_get_message_type (method_reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
     g_dbus_message_to_gerror (method_reply, &error);
     g_critical ("error: %s\n", error->message);
     g_error_free (error);
@@ -973,8 +905,8 @@ out:
  * @brief Callback on connetion success
  */
 static void
-on_name_appeared (GDBusConnection *connection, const gchar *name,
-                  const gchar *name_owner, gpointer user_data) {
+on_name_appeared (GDBusConnection *connection, const gchar *name, const gchar *name_owner,
+                  gpointer user_data) {
   g_mutex_lock (&_mutex);
   _connection = connection;
   _name_owner = name_owner;
@@ -986,8 +918,7 @@ on_name_appeared (GDBusConnection *connection, const gchar *name,
  * @brief Callback on connetion failures
  */
 static void
-on_name_vanished (GDBusConnection *connection, const gchar *name,
-                  gpointer user_data) {
+on_name_vanished (GDBusConnection *connection, const gchar *name, gpointer user_data) {
   g_mutex_lock (&_mutex);
   _thread = NULL;
   g_mutex_unlock (&_mutex);
@@ -1001,9 +932,9 @@ static gpointer
 npumgr_thread (gpointer data) {
   guint watcher_id;
 
-  watcher_id = g_bus_watch_name (
-      G_BUS_TYPE_SYSTEM, "sr.odl.NPUManager.API", G_BUS_NAME_WATCHER_FLAGS_NONE,
-      on_name_appeared, on_name_vanished, NULL, NULL);
+  watcher_id =
+      g_bus_watch_name (G_BUS_TYPE_SYSTEM, "sr.odl.NPUManager.API", G_BUS_NAME_WATCHER_FLAGS_NONE,
+                        on_name_appeared, on_name_vanished, NULL, NULL);
 
   _loop = g_main_loop_new (NULL, FALSE);
 
index c6cb0cf..f173919 100644 (file)
@@ -98,8 +98,7 @@ convert_layout (const npumgr_tensor_fmt_t &fmt) {
 }
 
 static data_type
-convert_type (const npumgr_tensor_data_t &data,
-              const npumgr_tensor_qnt_t &qnt) {
+convert_type (const npumgr_tensor_data_t &data, const npumgr_tensor_qnt_t &qnt) {
   data_type type;
 
   /* unknown, relying on the model */
@@ -202,8 +201,7 @@ class NpumgrNetworkTriv2 {
     if (lseek (model_file_.fd, 0, SEEK_SET) < 0)
       return FALSE;
 
-    if (read (model_file_.fd, (void *) meta_, NPUBIN_META_SIZE) !=
-        NPUBIN_META_SIZE)
+    if (read (model_file_.fd, (void *) meta_, NPUBIN_META_SIZE) != NPUBIN_META_SIZE)
       return FALSE;
 
     if (meta_->size <= NPUBIN_META_SIZE)
@@ -244,11 +242,8 @@ class NpumgrNetworkTriv2 {
   /** @brief get network handle */
   npumgr_network getHandle () { return handle_; }
 
-  guint getInTensorDim (guint i, guint j) {
-    return meta_->input_seg_dims[i][j];
-  }
-  guint getInTensorSize (guint i, npumgr_tensor_fmt_t fmt,
-                         npumgr_tensor_data_t type) {
+  guint getInTensorDim (guint i, guint j) { return meta_->input_seg_dims[i][j]; }
+  guint getInTensorSize (guint i, npumgr_tensor_fmt_t fmt, npumgr_tensor_data_t type) {
     guint size;
 
     if (fmt == NPUMGR_TENSOR_FMT_NHWC || fmt == NPUMGR_TENSOR_FMT_NCHW) {
@@ -266,11 +261,8 @@ class NpumgrNetworkTriv2 {
   int32_t getInTensorQuantZero (guint i) { return meta_->input_seg_quant_z[i]; }
   float getInTensorQuantScale (guint i) { return meta_->input_seg_quant_s[i]; }
 
-  guint getOutTensorDim (gint i, gint j) {
-    return meta_->output_seg_dims[i][j];
-  }
-  guint getOutTensorSize (guint i, npumgr_tensor_fmt_t fmt,
-                          npumgr_tensor_data_t type) {
+  guint getOutTensorDim (gint i, gint j) { return meta_->output_seg_dims[i][j]; }
+  guint getOutTensorSize (guint i, npumgr_tensor_fmt_t fmt, npumgr_tensor_data_t type) {
     guint size;
 
     if (fmt == NPUMGR_TENSOR_FMT_NHWC || fmt == NPUMGR_TENSOR_FMT_NCHW) {
@@ -285,9 +277,7 @@ class NpumgrNetworkTriv2 {
     }
     return size;
   }
-  int32_t getOutTensorQuantZero (gint i) {
-    return meta_->output_seg_quant_z[i];
-  }
+  int32_t getOutTensorQuantZero (gint i) { return meta_->output_seg_quant_z[i]; }
   float getOutTensorQuantScale (gint i) { return meta_->output_seg_quant_s[i]; }
 
   gboolean setInput (gint index, NpumgrBufferTriv2 *buffer) {
@@ -295,11 +285,9 @@ class NpumgrNetworkTriv2 {
       return FALSE;
 
     in_info_.info[index].layout = convert_layout (buffer->getDataFmt ());
-    in_info_.info[index].type =
-        convert_type (buffer->getDataType (), buffer->getQuantType ());
+    in_info_.info[index].type = convert_type (buffer->getDataType (), buffer->getQuantType ());
 
-    memcpy (&in_buffers_.bufs[index], buffer->getGenericBuffer (),
-            sizeof (generic_buffer));
+    memcpy (&in_buffers_.bufs[index], buffer->getGenericBuffer (), sizeof (generic_buffer));
     return TRUE;
   }
 
@@ -308,32 +296,27 @@ class NpumgrNetworkTriv2 {
       return FALSE;
 
     out_info_.info[index].layout = convert_layout (buffer->getDataFmt ());
-    out_info_.info[index].type =
-        convert_type (buffer->getDataType (), buffer->getQuantType ());
+    out_info_.info[index].type = convert_type (buffer->getDataType (), buffer->getQuantType ());
 
-    memcpy (&out_buffers_.bufs[index], buffer->getGenericBuffer (),
-            sizeof (generic_buffer));
+    memcpy (&out_buffers_.bufs[index], buffer->getGenericBuffer (), sizeof (generic_buffer));
     return TRUE;
   }
 
   void setAsync (gboolean async) { async_ = async; }
   gboolean isAsync () const { return async_; }
 
-  gboolean prepare () {
-    return (setNPU_dataInfo (dev_, model_id_, &in_info_, &out_info_) == 0);
-  }
+  gboolean prepare () { return (setNPU_dataInfo (dev_, model_id_, &in_info_, &out_info_) == 0); }
 
   gboolean execute () {
     int req_id;
 
     if (isAsync ()) {
       async_priv_.done = FALSE;
-      req_id =
-          runNPU_model (dev_, model_id_, NPU_INFER_NON_BLOCKING, &in_buffers_,
-                        &out_buffers_, async_cb, &async_priv_);
+      req_id = runNPU_model (dev_, model_id_, NPU_INFER_NON_BLOCKING, &in_buffers_, &out_buffers_,
+                             async_cb, &async_priv_);
     } else {
-      req_id = runNPU_model (dev_, model_id_, NPU_INFER_BLOCKING, &in_buffers_,
-                             &out_buffers_, NULL, NULL);
+      req_id = runNPU_model (dev_, model_id_, NPU_INFER_BLOCKING, &in_buffers_, &out_buffers_, NULL,
+                             NULL);
     }
 
     return (req_id > 0);
@@ -347,8 +330,7 @@ class NpumgrNetworkTriv2 {
 
     g_mutex_lock (&async_priv_.mutex);
     while (async_priv_.done != TRUE) {
-      if (!g_cond_wait_until (&async_priv_.cond, &async_priv_.mutex,
-                              end_time)) {
+      if (!g_cond_wait_until (&async_priv_.cond, &async_priv_.mutex, end_time)) {
         result = FALSE;
         break;
       }
@@ -404,13 +386,10 @@ buf_destroy (gpointer data) {
  */
 class NpumgrContextTriv2 {
  public:
-  NpumgrContextTriv2 (npudev_h dev, int priority)
-      : dev_ (dev), priority_ (priority) {
+  NpumgrContextTriv2 (npudev_h dev, int priority) : dev_ (dev), priority_ (priority) {
     handle_ = g_atomic_int_add (&g_ctx_handle, 1);
-    nw_table_ =
-        g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, nw_destroy);
-    buf_table_ = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
-                                        buf_destroy);
+    nw_table_ = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, nw_destroy);
+    buf_table_ = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, buf_destroy);
   }
 
   ~NpumgrContextTriv2 () {
@@ -427,8 +406,7 @@ class NpumgrContextTriv2 {
     return g_hash_table_remove (nw_table_, GSIZE_TO_POINTER (handle));
   }
   NpumgrNetworkTriv2 *findNetwork (npumgr_network handle) {
-    return (NpumgrNetworkTriv2 *) g_hash_table_lookup (
-        nw_table_, GSIZE_TO_POINTER (handle));
+    return (NpumgrNetworkTriv2 *) g_hash_table_lookup (nw_table_, GSIZE_TO_POINTER (handle));
   }
 
   gboolean executeNetwork (npumgr_network handle, gboolean async = FALSE) {
@@ -451,8 +429,7 @@ class NpumgrContextTriv2 {
   }
 
   NpumgrBufferTriv2 *findBuffer (npumgr_buffer_h handle) {
-    return (NpumgrBufferTriv2 *) g_hash_table_lookup (
-        buf_table_, GSIZE_TO_POINTER (handle));
+    return (NpumgrBufferTriv2 *) g_hash_table_lookup (buf_table_, GSIZE_TO_POINTER (handle));
   }
 
   gboolean allocBuffer (npumgr_query_tensor_attr *param, npumgr_buffer *buf) {
@@ -469,8 +446,7 @@ class NpumgrContextTriv2 {
     nbuf->setDataType (param->type);
     nbuf->setQuantType (param->quant_type);
 
-    if (!g_hash_table_insert (buf_table_, GSIZE_TO_POINTER (nbuf->getHandle ()),
-                              nbuf)) {
+    if (!g_hash_table_insert (buf_table_, GSIZE_TO_POINTER (nbuf->getHandle ()), nbuf)) {
       cleanNPU_genericBuffer (dev_, &gbuf);
       delete nbuf;
       return FALSE;
@@ -536,92 +512,70 @@ struct _NpumgrDeviceTriv2Private {
 };
 
 #define NPUMGR_DEVICE(obj) &((obj)->parent)
-#define NPUMGR_DEVICE_TRIV2_GET_PRIVATE(obj)                  \
-  ((NpumgrDeviceTriv2Private *) g_type_instance_get_private ( \
-      (GTypeInstance *) obj, NPUMGR_TYPE_DEVICE_TRIV2))
+#define NPUMGR_DEVICE_TRIV2_GET_PRIVATE(obj)                                        \
+  ((NpumgrDeviceTriv2Private *) g_type_instance_get_private ((GTypeInstance *) obj, \
+                                                             NPUMGR_TYPE_DEVICE_TRIV2))
 
-G_DEFINE_TYPE_WITH_PRIVATE (NpumgrDeviceTriv2, npumgr_device_triv2,
-                            NPUMGR_TYPE_DEVICE);
+G_DEFINE_TYPE_WITH_PRIVATE (NpumgrDeviceTriv2, npumgr_device_triv2, NPUMGR_TYPE_DEVICE);
 
 /* GObject */
 static void triv2_finalize (GObject *object);
 /* NpumgrDevice */
-static npumgr_status_e triv2_device_get_capabilities (
-    NpumgrDevice *device, guint *caps, npumgr_device_type_t *ptype);
-static npumgr_status_e triv2_context_create (NpumgrDevice *device,
-                                             int device_id, int priority,
+static npumgr_status_e triv2_device_get_capabilities (NpumgrDevice *device, guint *caps,
+                                                      npumgr_device_type_t *ptype);
+static npumgr_status_e triv2_context_create (NpumgrDevice *device, int device_id, int priority,
                                              npumgr_context *out_ctx);
-static npumgr_status_e triv2_context_destroy (NpumgrDevice *device,
-                                              npumgr_context ctx);
-static npumgr_status_e triv2_network_create (
-    NpumgrDevice *device, npumgr_context ctx, int num_files,
-    npumgr_network_defn *input_files, npumgr_buffer_t in_buffer_type,
-    int in_tensor_cnt, char **input_tensor_names,
-    npumgr_buffer_t out_buffer_type, int out_tensor_cnt,
-    char **output_tensor_names, npumgr_network *out_nw_handle);
-static npumgr_status_e triv2_network_set_input (NpumgrDevice *device,
-                                                npumgr_context ctx,
-                                                npumgr_network nw_handle,
-                                                int index,
+static npumgr_status_e triv2_context_destroy (NpumgrDevice *device, npumgr_context ctx);
+static npumgr_status_e triv2_network_create (NpumgrDevice *device, npumgr_context ctx,
+                                             int num_files, npumgr_network_defn *input_files,
+                                             npumgr_buffer_t in_buffer_type, int in_tensor_cnt,
+                                             char **input_tensor_names,
+                                             npumgr_buffer_t out_buffer_type, int out_tensor_cnt,
+                                             char **output_tensor_names,
+                                             npumgr_network *out_nw_handle);
+static npumgr_status_e triv2_network_set_input (NpumgrDevice *device, npumgr_context ctx,
+                                                npumgr_network nw_handle, int index,
                                                 npumgr_buffer *input_buffer);
-static npumgr_status_e triv2_network_set_output (NpumgrDevice *device,
-                                                 npumgr_context ctx,
-                                                 npumgr_network nw_handle,
-                                                 int index,
+static npumgr_status_e triv2_network_set_output (NpumgrDevice *device, npumgr_context ctx,
+                                                 npumgr_network nw_handle, int index,
                                                  npumgr_buffer *output_buffer);
-static npumgr_status_e triv2_network_prepare (NpumgrDevice *device,
-                                              npumgr_context ctx,
+static npumgr_status_e triv2_network_prepare (NpumgrDevice *device, npumgr_context ctx,
                                               npumgr_network nw_handle);
-static npumgr_status_e triv2_network_destroy (NpumgrDevice *device,
-                                              npumgr_context ctx,
+static npumgr_status_e triv2_network_destroy (NpumgrDevice *device, npumgr_context ctx,
                                               npumgr_network nw_handle);
-static npumgr_status_e triv2_buffer_create (
-    NpumgrDevice *device, npumgr_context ctx,
-    npumgr_query_tensor_attr *create_param, npumgr_buffer *buf);
-static npumgr_status_e triv2_buffer_destroy (NpumgrDevice *device,
-                                             npumgr_context ctx,
+static npumgr_status_e triv2_buffer_create (NpumgrDevice *device, npumgr_context ctx,
+                                            npumgr_query_tensor_attr *create_param,
+                                            npumgr_buffer *buf);
+static npumgr_status_e triv2_buffer_destroy (NpumgrDevice *device, npumgr_context ctx,
                                              npumgr_buffer *buf);
-static npumgr_status_e triv2_buffer_map (NpumgrDevice *device,
-                                         npumgr_context ctx, npumgr_buffer *buf,
-                                         uint8_t **mapped_addr);
-static npumgr_status_e triv2_buffer_unmap (NpumgrDevice *device,
-                                           npumgr_context ctx,
+static npumgr_status_e triv2_buffer_map (NpumgrDevice *device, npumgr_context ctx,
+                                         npumgr_buffer *buf, uint8_t **mapped_addr);
+static npumgr_status_e triv2_buffer_unmap (NpumgrDevice *device, npumgr_context ctx,
                                            npumgr_buffer *buf);
 
-static npumgr_status_e triv2_query_network (NpumgrDevice *device,
-                                            npumgr_context ctx,
-                                            npumgr_network nw_handle,
-                                            npumgr_query_inout_num *data);
-static npumgr_status_e triv2_query_input (NpumgrDevice *device,
-                                          npumgr_context ctx,
+static npumgr_status_e triv2_query_network (NpumgrDevice *device, npumgr_context ctx,
+                                            npumgr_network nw_handle, npumgr_query_inout_num *data);
+static npumgr_status_e triv2_query_input (NpumgrDevice *device, npumgr_context ctx,
                                           npumgr_network nw_handle, int index,
                                           npumgr_query_tensor_attr *data);
-static npumgr_status_e triv2_query_output (NpumgrDevice *device,
-                                           npumgr_context ctx,
+static npumgr_status_e triv2_query_output (NpumgrDevice *device, npumgr_context ctx,
                                            npumgr_network nw_handle, int index,
                                            npumgr_query_tensor_attr *data);
-static npumgr_status_e triv2_execute_trigger (NpumgrDevice *device,
-                                              npumgr_context ctx,
+static npumgr_status_e triv2_execute_trigger (NpumgrDevice *device, npumgr_context ctx,
                                               npumgr_network nw_handle);
-static npumgr_status_e triv2_execute_wait (NpumgrDevice *device,
-                                           npumgr_context ctx,
+static npumgr_status_e triv2_execute_wait (NpumgrDevice *device, npumgr_context ctx,
                                            npumgr_network nw_handle);
-static npumgr_status_e triv2_execute_run (NpumgrDevice *device,
-                                          npumgr_context ctx,
+static npumgr_status_e triv2_execute_run (NpumgrDevice *device, npumgr_context ctx,
                                           npumgr_network nw_handle);
 
-static npumgr_status_e triv2_execute_realtime (NpumgrDevice *device,
-                                               npumgr_context ctx,
-                                               npumgr_network nw_handle,
-                                               uint32_t task_handle,
+static npumgr_status_e triv2_execute_realtime (NpumgrDevice *device, npumgr_context ctx,
+                                               npumgr_network nw_handle, uint32_t task_handle,
                                                uint32_t subtask_id);
-static npumgr_status_e triv2_execute_wait_realtime (NpumgrDevice *device,
-                                                    npumgr_context ctx,
-                                                    npumgr_network nw_handle,
-                                                    uint32_t *golden_val,
+static npumgr_status_e triv2_execute_wait_realtime (NpumgrDevice *device, npumgr_context ctx,
+                                                    npumgr_network nw_handle, uint32_t *golden_val,
                                                     uint32_t **golden_addr);
-static npumgr_status_e triv2_execute_completed_realtime (
-    NpumgrDevice *device, npumgr_context ctx, npumgr_network nw_handle);
+static npumgr_status_e triv2_execute_completed_realtime (NpumgrDevice *device, npumgr_context ctx,
+                                                         npumgr_network nw_handle);
 
 extern NpumgrDevice *
 npumgr_device_triv2_new (void) {
@@ -659,8 +613,7 @@ npumgr_device_triv2_class_init (NpumgrDeviceTriv2Class *klass) {
   npumgr_device_class->execute_run = triv2_execute_run;
   npumgr_device_class->execute_realtime = triv2_execute_realtime;
   npumgr_device_class->execute_wait_realtime = triv2_execute_wait_realtime;
-  npumgr_device_class->execute_completed_realtime =
-      triv2_execute_completed_realtime;
+  npumgr_device_class->execute_completed_realtime = triv2_execute_completed_realtime;
 
   /* NYI */
 }
@@ -672,8 +625,7 @@ npumgr_device_triv2_init (NpumgrDeviceTriv2 *self) {
 
   memset (priv, '\x00', sizeof (*priv));
   g_mutex_init (&priv->mutex);
-  priv->ctx_table =
-      g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, ctx_destroy);
+  priv->ctx_table = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, ctx_destroy);
 
   /** TODO: How npumgr supports multiple TRIV2 devices? */
   status = getNPUdeviceByTypeAny (&priv->dev, NPUCOND_TRIV2_CONN_SOCIP, 2);
@@ -697,8 +649,7 @@ triv2_finalize (GObject *object) {
 
 /* Filling the virtual function table of TRIV2 */
 static npumgr_status_e
-triv2_device_get_capabilities (NpumgrDevice *device, guint *caps,
-                               npumgr_device_type_t *ptype) {
+triv2_device_get_capabilities (NpumgrDevice *device, guint *caps, npumgr_device_type_t *ptype) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (caps != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ptype != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
@@ -706,12 +657,10 @@ triv2_device_get_capabilities (NpumgrDevice *device, guint *caps,
   NpumgrDeviceTriv2 *self = NPUMGR_DEVICE_TRIV2 (device);
   NpumgrDeviceTriv2Private *priv = NPUMGR_DEVICE_TRIV2_GET_PRIVATE (self);
 
-  g_return_val_if_fail (priv->dev != NULL,
-                        NPUMGR_STATUS_ERR_DEVICE_UNAVAILABLE);
+  g_return_val_if_fail (priv->dev != NULL, NPUMGR_STATUS_ERR_DEVICE_UNAVAILABLE);
 
-  *caps = NPUMGR_DEVICE_CAPABILITY_MMAP |
-          NPUMGR_DEVICE_CAPABILITY_MULTICONTEXT | NPUMGR_DEVICE_CAPABILITY_MMU |
-          NPUMGR_DEVICE_CAPABILITY_REALTIME;
+  *caps = NPUMGR_DEVICE_CAPABILITY_MMAP | NPUMGR_DEVICE_CAPABILITY_MULTICONTEXT |
+          NPUMGR_DEVICE_CAPABILITY_MMU | NPUMGR_DEVICE_CAPABILITY_REALTIME;
   *ptype = NPUMGR_DEVICE_TYPE_NPU;
 
   return NPUMGR_STATUS_SUCCESS;
@@ -723,8 +672,7 @@ insert_context (NpumgrDeviceTriv2Private *priv, npumgr_context handle,
   gboolean result;
 
   g_mutex_lock (&priv->mutex);
-  result =
-      g_hash_table_insert (priv->ctx_table, GSIZE_TO_POINTER (handle), context);
+  result = g_hash_table_insert (priv->ctx_table, GSIZE_TO_POINTER (handle), context);
   g_mutex_unlock (&priv->mutex);
 
   return result;
@@ -746,8 +694,7 @@ find_context (NpumgrDeviceTriv2Private *priv, npumgr_context handle) {
   NpumgrContextTriv2 *context;
 
   g_mutex_lock (&priv->mutex);
-  context = (NpumgrContextTriv2 *) g_hash_table_lookup (
-      priv->ctx_table, GSIZE_TO_POINTER (handle));
+  context = (NpumgrContextTriv2 *) g_hash_table_lookup (priv->ctx_table, GSIZE_TO_POINTER (handle));
   g_mutex_unlock (&priv->mutex);
 
   return context;
@@ -762,8 +709,7 @@ triv2_context_create (NpumgrDevice *device, int device_id, int priority,
   NpumgrDeviceTriv2 *self = NPUMGR_DEVICE_TRIV2 (device);
   NpumgrDeviceTriv2Private *priv = NPUMGR_DEVICE_TRIV2_GET_PRIVATE (self);
 
-  g_return_val_if_fail (priv->dev != NULL,
-                        NPUMGR_STATUS_ERR_DEVICE_UNAVAILABLE);
+  g_return_val_if_fail (priv->dev != NULL, NPUMGR_STATUS_ERR_DEVICE_UNAVAILABLE);
 
   NpumgrContextTriv2 *context = new NpumgrContextTriv2 (priv->dev, priority);
   *ctx_handle = context->getHandle ();
@@ -790,21 +736,17 @@ triv2_context_destroy (NpumgrDevice *device, npumgr_context ctx_handle) {
 
 static npumgr_status_e
 triv2_network_create (NpumgrDevice *device, npumgr_context ctx, int num_files,
-                      npumgr_network_defn *input_files,
-                      npumgr_buffer_t in_buffer_type, int in_tensor_cnt,
-                      char **input_tensor_names,
-                      npumgr_buffer_t out_buffer_type, int out_tensor_cnt,
-                      char **output_tensor_names, npumgr_network *out_nw) {
+                      npumgr_network_defn *input_files, npumgr_buffer_t in_buffer_type,
+                      int in_tensor_cnt, char **input_tensor_names, npumgr_buffer_t out_buffer_type,
+                      int out_tensor_cnt, char **output_tensor_names, npumgr_network *out_nw) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ctx != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (num_files == 1, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (input_files != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (in_tensor_cnt != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
-  g_return_val_if_fail (input_tensor_names != NULL,
-                        NPUMGR_STATUS_ERR_PARAM_INVALID);
+  g_return_val_if_fail (input_tensor_names != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (out_tensor_cnt != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
-  g_return_val_if_fail (output_tensor_names != NULL,
-                        NPUMGR_STATUS_ERR_PARAM_INVALID);
+  g_return_val_if_fail (output_tensor_names != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (out_nw != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
 
   NpumgrDeviceTriv2 *self = NPUMGR_DEVICE_TRIV2 (device);
@@ -813,8 +755,7 @@ triv2_network_create (NpumgrDevice *device, npumgr_context ctx, int num_files,
 
   g_return_val_if_fail (context != NULL, NPUMGR_STATUS_ERR_CTX_INVALID);
 
-  NpumgrNetworkTriv2 *network =
-      new NpumgrNetworkTriv2 (context->getDevice (), input_files[0]);
+  NpumgrNetworkTriv2 *network = new NpumgrNetworkTriv2 (context->getDevice (), input_files[0]);
   if (!network->loadModel ())
     goto err;
   if (network->getInTensorCnt () != in_tensor_cnt)
@@ -838,9 +779,8 @@ err:
 }
 
 static npumgr_status_e
-triv2_network_set_input (NpumgrDevice *device, npumgr_context ctx_handle,
-                         npumgr_network nw_handle, int index,
-                         npumgr_buffer *buf) {
+triv2_network_set_input (NpumgrDevice *device, npumgr_context ctx_handle, npumgr_network nw_handle,
+                         int index, npumgr_buffer *buf) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ctx_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (nw_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
@@ -854,8 +794,7 @@ triv2_network_set_input (NpumgrDevice *device, npumgr_context ctx_handle,
 
   NpumgrNetworkTriv2 *network = context->findNetwork (nw_handle);
   g_return_val_if_fail (network != NULL, NPUMGR_STATUS_ERR_MODEL_INVALID);
-  g_return_val_if_fail (network->getInTensorCnt () > index,
-                        NPUMGR_STATUS_ERR_PARAM_INVALID);
+  g_return_val_if_fail (network->getInTensorCnt () > index, NPUMGR_STATUS_ERR_PARAM_INVALID);
 
   NpumgrBufferTriv2 *buffer = context->findBuffer (buf->buf_handle);
   g_return_val_if_fail (buffer != NULL, NPUMGR_STATUS_ERR_FAIL);
@@ -867,9 +806,8 @@ triv2_network_set_input (NpumgrDevice *device, npumgr_context ctx_handle,
 }
 
 static npumgr_status_e
-triv2_network_set_output (NpumgrDevice *device, npumgr_context ctx_handle,
-                          npumgr_network nw_handle, int index,
-                          npumgr_buffer *buf) {
+triv2_network_set_output (NpumgrDevice *device, npumgr_context ctx_handle, npumgr_network nw_handle,
+                          int index, npumgr_buffer *buf) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ctx_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (nw_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
@@ -883,8 +821,7 @@ triv2_network_set_output (NpumgrDevice *device, npumgr_context ctx_handle,
 
   NpumgrNetworkTriv2 *network = context->findNetwork (nw_handle);
   g_return_val_if_fail (network != NULL, NPUMGR_STATUS_ERR_MODEL_INVALID);
-  g_return_val_if_fail (network->getOutTensorCnt () > index,
-                        NPUMGR_STATUS_ERR_PARAM_INVALID);
+  g_return_val_if_fail (network->getOutTensorCnt () > index, NPUMGR_STATUS_ERR_PARAM_INVALID);
 
   NpumgrBufferTriv2 *buffer = context->findBuffer (buf->buf_handle);
   g_return_val_if_fail (buffer != NULL, NPUMGR_STATUS_ERR_FAIL);
@@ -896,8 +833,7 @@ triv2_network_set_output (NpumgrDevice *device, npumgr_context ctx_handle,
 }
 
 static npumgr_status_e
-triv2_network_prepare (NpumgrDevice *device, npumgr_context ctx_handle,
-                       npumgr_network nw_handle) {
+triv2_network_prepare (NpumgrDevice *device, npumgr_context ctx_handle, npumgr_network nw_handle) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ctx_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (nw_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
@@ -918,8 +854,7 @@ triv2_network_prepare (NpumgrDevice *device, npumgr_context ctx_handle,
 }
 
 static npumgr_status_e
-triv2_network_destroy (NpumgrDevice *device, npumgr_context ctx_handle,
-                       npumgr_network nw_handle) {
+triv2_network_destroy (NpumgrDevice *device, npumgr_context ctx_handle, npumgr_network nw_handle) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ctx_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (nw_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
@@ -938,8 +873,7 @@ triv2_network_destroy (NpumgrDevice *device, npumgr_context ctx_handle,
 
 static npumgr_status_e
 triv2_buffer_create (NpumgrDevice *device, npumgr_context ctx_handle,
-                     npumgr_query_tensor_attr *create_param,
-                     npumgr_buffer *buf) {
+                     npumgr_query_tensor_attr *create_param, npumgr_buffer *buf) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ctx_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (create_param != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
@@ -958,8 +892,7 @@ triv2_buffer_create (NpumgrDevice *device, npumgr_context ctx_handle,
 }
 
 static npumgr_status_e
-triv2_buffer_destroy (NpumgrDevice *device, npumgr_context ctx_handle,
-                      npumgr_buffer *buf) {
+triv2_buffer_destroy (NpumgrDevice *device, npumgr_context ctx_handle, npumgr_buffer *buf) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ctx_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (buf != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
@@ -977,8 +910,8 @@ triv2_buffer_destroy (NpumgrDevice *device, npumgr_context ctx_handle,
 }
 
 static npumgr_status_e
-triv2_buffer_map (NpumgrDevice *device, npumgr_context ctx_handle,
-                  npumgr_buffer *buf, uint8_t **mapped_addr) {
+triv2_buffer_map (NpumgrDevice *device, npumgr_context ctx_handle, npumgr_buffer *buf,
+                  uint8_t **mapped_addr) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ctx_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (buf != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
@@ -997,15 +930,13 @@ triv2_buffer_map (NpumgrDevice *device, npumgr_context ctx_handle,
 }
 
 static npumgr_status_e
-triv2_buffer_unmap (NpumgrDevice *device, npumgr_context ctx,
-                    npumgr_buffer *buf) {
+triv2_buffer_unmap (NpumgrDevice *device, npumgr_context ctx, npumgr_buffer *buf) {
   /* NYI */
   return NPUMGR_STATUS_SUCCESS;
 }
 
 static npumgr_status_e
-triv2_query_network (NpumgrDevice *device, npumgr_context ctx_handle,
-                     npumgr_network nw_handle,
+triv2_query_network (NpumgrDevice *device, npumgr_context ctx_handle, npumgr_network nw_handle,
                      npumgr_query_inout_num *inout_num) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ctx_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
@@ -1028,9 +959,8 @@ triv2_query_network (NpumgrDevice *device, npumgr_context ctx_handle,
 }
 
 static npumgr_status_e
-triv2_query_input (NpumgrDevice *device, npumgr_context ctx_handle,
-                   npumgr_network nw_handle, int index,
-                   npumgr_query_tensor_attr *attr) {
+triv2_query_input (NpumgrDevice *device, npumgr_context ctx_handle, npumgr_network nw_handle,
+                   int index, npumgr_query_tensor_attr *attr) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ctx_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (nw_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
@@ -1049,8 +979,7 @@ triv2_query_input (NpumgrDevice *device, npumgr_context ctx_handle,
   attr->n_dims = MAX_RANK;
   for (guint rank = 0; rank < MAX_RANK; rank++)
     attr->dims[rank] = network->getInTensorDim (index, rank);
-  g_snprintf (attr->name, NPUMGR_MAX_NAME_LEN, "%s",
-              network->getInTensorName (index));
+  g_snprintf (attr->name, NPUMGR_MAX_NAME_LEN, "%s", network->getInTensorName (index));
 
   /* FIXME: their exact meaning and usage? */
   for (guint rank = 0; rank < MAX_RANK; rank++) attr->strides[rank] = 1;
@@ -1068,9 +997,8 @@ triv2_query_input (NpumgrDevice *device, npumgr_context ctx_handle,
 }
 
 static npumgr_status_e
-triv2_query_output (NpumgrDevice *device, npumgr_context ctx_handle,
-                    npumgr_network nw_handle, int index,
-                    npumgr_query_tensor_attr *attr) {
+triv2_query_output (NpumgrDevice *device, npumgr_context ctx_handle, npumgr_network nw_handle,
+                    int index, npumgr_query_tensor_attr *attr) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ctx_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (nw_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
@@ -1089,8 +1017,7 @@ triv2_query_output (NpumgrDevice *device, npumgr_context ctx_handle,
   attr->n_dims = MAX_RANK;
   for (guint rank = 0; rank < MAX_RANK; rank++)
     attr->dims[rank] = network->getOutTensorDim (index, rank);
-  g_snprintf (attr->name, NPUMGR_MAX_NAME_LEN, "%s",
-              network->getOutTensorName (index));
+  g_snprintf (attr->name, NPUMGR_MAX_NAME_LEN, "%s", network->getOutTensorName (index));
 
   /* FIXME: their exact meaning and usage? */
   for (guint rank = 0; rank < MAX_RANK; rank++) attr->strides[rank] = 1;
@@ -1108,8 +1035,7 @@ triv2_query_output (NpumgrDevice *device, npumgr_context ctx_handle,
 }
 
 static npumgr_status_e
-triv2_execute_trigger (NpumgrDevice *device, npumgr_context ctx_handle,
-                       npumgr_network nw_handle) {
+triv2_execute_trigger (NpumgrDevice *device, npumgr_context ctx_handle, npumgr_network nw_handle) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ctx_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (nw_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
@@ -1127,8 +1053,7 @@ triv2_execute_trigger (NpumgrDevice *device, npumgr_context ctx_handle,
 }
 
 static npumgr_status_e
-triv2_execute_wait (NpumgrDevice *device, npumgr_context ctx_handle,
-                    npumgr_network nw_handle) {
+triv2_execute_wait (NpumgrDevice *device, npumgr_context ctx_handle, npumgr_network nw_handle) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ctx_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (nw_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
@@ -1146,8 +1071,7 @@ triv2_execute_wait (NpumgrDevice *device, npumgr_context ctx_handle,
 }
 
 static npumgr_status_e
-triv2_execute_run (NpumgrDevice *device, npumgr_context ctx_handle,
-                   npumgr_network nw_handle) {
+triv2_execute_run (NpumgrDevice *device, npumgr_context ctx_handle, npumgr_network nw_handle) {
   g_return_val_if_fail (device != NULL, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (ctx_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
   g_return_val_if_fail (nw_handle != 0, NPUMGR_STATUS_ERR_PARAM_INVALID);
@@ -1165,9 +1089,8 @@ triv2_execute_run (NpumgrDevice *device, npumgr_context ctx_handle,
 }
 
 static npumgr_status_e
-triv2_execute_realtime (NpumgrDevice *device, npumgr_context ctx_handle,
-                        npumgr_network nw_handle, uint32_t task_handle,
-                        uint32_t subtask_id) {
+triv2_execute_realtime (NpumgrDevice *device, npumgr_context ctx_handle, npumgr_network nw_handle,
+                        uint32_t task_handle, uint32_t subtask_id) {
   /* NYI */
   return NPUMGR_STATUS_SUCCESS;
 }
@@ -1181,8 +1104,7 @@ triv2_execute_wait_realtime (NpumgrDevice *device, npumgr_context ctx_handle,
 }
 
 static npumgr_status_e
-triv2_execute_completed_realtime (NpumgrDevice *device,
-                                  npumgr_context ctx_handle,
+triv2_execute_completed_realtime (NpumgrDevice *device, npumgr_context ctx_handle,
                                   npumgr_network nw_handle) {
   /* NYI */
   return NPUMGR_STATUS_SUCCESS;
index c8a3467..700c240 100644 (file)
@@ -20,9 +20,8 @@
 G_BEGIN_DECLS
 
 #define NPUMGR_TYPE_DEVICE_TRIV2 (npumgr_device_triv2_get_type ())
-#define NPUMGR_DEVICE_TRIV2(obj)                                \
-  (G_TYPE_CHECK_INSTANCE_CAST ((obj), NPUMGR_TYPE_DEVICE_TRIV2, \
-                               NpumgrDeviceTriv2))
+#define NPUMGR_DEVICE_TRIV2(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), NPUMGR_TYPE_DEVICE_TRIV2, NpumgrDeviceTriv2))
 
 typedef struct _NpumgrDeviceTriv2 NpumgrDeviceTriv2;
 typedef struct _NpumgrDeviceTriv2Class NpumgrDeviceTriv2Class;
index f72ef7c..a175813 100644 (file)
@@ -27,8 +27,8 @@ class CommPlugin {
 
   /** host -> npu-engine */
   virtual int extractGenericBuffer (const generic_buffer *buf, void *data,
-                                    dataManipFunc func = nullptr,
-                                    size_t offset = 0, size_t size = 0) = 0;
+                                    dataManipFunc func = nullptr, size_t offset = 0,
+                                    size_t size = 0) = 0;
   /** npu-engine -> host */
   virtual int insertGenericBuffer (void *data, generic_buffer *buf,
                                    dataManipFunc func = nullptr) = 0;
index 94646da..580fc40 100644 (file)
@@ -46,9 +46,8 @@ class CommPluginIP : public CommPlugin {
    * @param[in] size the size of generic buffer to be copied
    * @return 0 if no error. otherwise a negative errno
    */
-  int extractGenericBuffer (const generic_buffer *buf, void *data,
-                            dataManipFunc func = nullptr, size_t offset = 0,
-                            size_t size = 0) {
+  int extractGenericBuffer (const generic_buffer *buf, void *data, dataManipFunc func = nullptr,
+                            size_t offset = 0, size_t size = 0) {
     size_t count = 0;
 
     if (buf == nullptr || data == nullptr)
@@ -111,8 +110,7 @@ class CommPluginIP : public CommPlugin {
    * @param[in] func data manipulation function
    * @return 0 if no error. otherwise a negative errno
    */
-  int insertGenericBuffer (void *data, generic_buffer *buf,
-                           dataManipFunc func = nullptr) {
+  int insertGenericBuffer (void *data, generic_buffer *buf, dataManipFunc func = nullptr) {
     if (buf == nullptr || data == nullptr)
       return -EINVAL;
     if (buf->size == 0)
index fa727cd..08570e4 100644 (file)
@@ -17,8 +17,7 @@
 #define TAG _N72
 
 /** @brief constructor of buffer class */
-Buffer::Buffer (const HWmemImpl* impl)
-    : HWmem (impl), num_input_ (0), num_output_ (0) {}
+Buffer::Buffer (const HWmemImpl* impl) : HWmem (impl), num_input_ (0), num_output_ (0) {}
 
 /** @brief destructor of buffer class */
 Buffer::~Buffer () {
@@ -60,9 +59,8 @@ Buffer::createTensors (const Metadata* meta) {
       }
     }
     for (uint32_t i = 0; i < meta->getOutputNum (); i++) {
-      status =
-          setOutputTensor (i, meta->getOutputOffset (i),
-                           meta->getOutputTensorSize (i, DATA_LAYOUT_SRNPU));
+      status = setOutputTensor (i, meta->getOutputOffset (i),
+                                meta->getOutputTensorSize (i, DATA_LAYOUT_SRNPU));
       if (status != 0) {
         logerr (TAG, "failed to set output tensor: index (%d)\n", i);
         return status;
index 1082fcb..fd29435 100644 (file)
@@ -317,8 +317,7 @@ DataConverter::perform () {
 
               if (quantizer)
                 quantizer->memcpy (static_cast<char *> (dst_) + dst_offset,
-                                   static_cast<char *> (src_) + src_offset,
-                                   slice_size);
+                                   static_cast<char *> (src_) + src_offset, slice_size);
               else
                 memcpy (static_cast<char *> (dst_) + dst_offset,
                         static_cast<char *> (src_) + src_offset, slice_size);
@@ -326,8 +325,7 @@ DataConverter::perform () {
           }
         }
       }
-    } else if (src_layout_ == DATA_LAYOUT_NCHW &&
-               dst_layout_ == DATA_LAYOUT_TRIV2) {
+    } else if (src_layout_ == DATA_LAYOUT_NCHW && dst_layout_ == DATA_LAYOUT_TRIV2) {
       /* special handling: NHWC == NCHW */
       if (depth == 1)
         goto try_quantize;
@@ -340,16 +338,14 @@ DataConverter::perform () {
           for (uint32_t h = 0; h < height; h++) {
             for (uint32_t w = 0; w < width; w++) {
               src_offset = w + width * (h + height * (d + n * depth));
-              dst_offset = (d % MPA_L) +
-                           MPA_L * (w + width * (h + (n + d / MPA_L) * height));
+              dst_offset = (d % MPA_L) + MPA_L * (w + width * (h + (n + d / MPA_L) * height));
 
               src_offset *= src_data_size;
               dst_offset *= dst_data_size;
 
               if (quantizer)
                 quantizer->memcpy (static_cast<char *> (dst_) + dst_offset,
-                                   static_cast<char *> (src_) + src_offset,
-                                   slice_size);
+                                   static_cast<char *> (src_) + src_offset, slice_size);
               else
                 memcpy (static_cast<char *> (dst_) + dst_offset,
                         static_cast<char *> (src_) + src_offset, slice_size);
@@ -357,8 +353,7 @@ DataConverter::perform () {
           }
         }
       }
-    } else if (src_layout_ == DATA_LAYOUT_TRIV2 &&
-               dst_layout_ == DATA_LAYOUT_NHWC) {
+    } else if (src_layout_ == DATA_LAYOUT_TRIV2 && dst_layout_ == DATA_LAYOUT_NHWC) {
       /* special handling: depth == granularity */
       if (depth == granularity)
         goto try_quantize;
@@ -378,8 +373,7 @@ DataConverter::perform () {
 
               if (quantizer)
                 quantizer->memcpy (static_cast<char *> (dst_) + dst_offset,
-                                   static_cast<char *> (src_) + src_offset,
-                                   slice_size);
+                                   static_cast<char *> (src_) + src_offset, slice_size);
               else
                 memcpy (static_cast<char *> (dst_) + dst_offset,
                         static_cast<char *> (src_) + src_offset, slice_size);
@@ -387,8 +381,7 @@ DataConverter::perform () {
           }
         }
       }
-    } else if (src_layout_ == DATA_LAYOUT_TRIV2 &&
-               dst_layout_ == DATA_LAYOUT_NCHW) {
+    } else if (src_layout_ == DATA_LAYOUT_TRIV2 && dst_layout_ == DATA_LAYOUT_NCHW) {
       /* TRIV2 --> NCHW */
       slice_size = src_data_size;
       for (uint32_t n = 0; n < batch; n++) {
@@ -396,16 +389,14 @@ DataConverter::perform () {
           for (uint32_t h = 0; h < height; h++) {
             for (uint32_t w = 0; w < width; w++) {
               dst_offset = w + width * (h + height * (d + n * depth));
-              src_offset = (d % MPA_L) +
-                           MPA_L * (w + width * (h + (n + d / MPA_L) * height));
+              src_offset = (d % MPA_L) + MPA_L * (w + width * (h + (n + d / MPA_L) * height));
 
               src_offset *= src_data_size;
               dst_offset *= dst_data_size;
 
               if (quantizer)
                 quantizer->memcpy (static_cast<char *> (dst_) + dst_offset,
-                                   static_cast<char *> (src_) + src_offset,
-                                   slice_size);
+                                   static_cast<char *> (src_) + src_offset, slice_size);
               else
                 memcpy (static_cast<char *> (dst_) + dst_offset,
                         static_cast<char *> (src_) + src_offset, slice_size);
index 03a732b..44fd615 100644 (file)
@@ -124,8 +124,7 @@ HostHandler::unregisterModels () {
  * @return 0 if no error. otherwise a negative error value
  */
 int
-HostHandler::getTensorSize (uint32_t modelid, bool input, uint32_t index,
-                            uint32_t *size) {
+HostHandler::getTensorSize (uint32_t modelid, bool input, uint32_t index, uint32_t *size) {
   Model *model = models_.find (modelid);
   if (model == nullptr)
     return -ENOENT;
@@ -141,8 +140,7 @@ HostHandler::getTensorSize (uint32_t modelid, bool input, uint32_t index,
  * @return 0 if no error, otherwise a negative errno.
  */
 int
-HostHandler::getProfile (int req_id, const npu_profile_opt &opt,
-                         npu_profile *profile) {
+HostHandler::getProfile (int req_id, const npu_profile_opt &opt, npu_profile *profile) {
   if (req_id < 0 || profile == nullptr) {
     logerr (TAG, "Invalid parameter provided\n");
     return -EINVAL;
@@ -257,8 +255,7 @@ HostHandler::getDspmSize (uint32_t *dspm) {
  * @note if this function is not called, default layout/type will be used.
  */
 int
-HostHandler::setDataInfo (uint32_t modelid, tensors_data_info *in,
-                          tensors_data_info *out) {
+HostHandler::setDataInfo (uint32_t modelid, tensors_data_info *in, tensors_data_info *out) {
   Model *model = models_.find (modelid);
   if (model == nullptr)
     return -ENOENT;
@@ -368,9 +365,8 @@ HostHandler::getRequestModel (int req_id, uint32_t *model_id) {
  * @return 0 if no error. Otherwise a negative errno
  */
 int
-HostHandler::setRequestData (int req_id, input_buffers *input,
-                             tensors_data_info *in_info, output_buffers *output,
-                             tensors_data_info *out_info) {
+HostHandler::setRequestData (int req_id, input_buffers *input, tensors_data_info *in_info,
+                             output_buffers *output, tensors_data_info *out_info) {
   return device_->setRequestData (req_id, input, in_info, output, out_info);
 }
 
@@ -453,9 +449,8 @@ HostHandler::submitRequestKernel (int req_id) {
  * @return @c positive id if no error. otherwise a negative error value
  */
 int
-HostHandler::runModel (uint32_t modelid, npu_infer_mode mode,
-                       const input_buffers *input, output_buffers *output,
-                       npuOutputNotify cb, void *data) {
+HostHandler::runModel (uint32_t modelid, npu_infer_mode mode, const input_buffers *input,
+                       output_buffers *output, npuOutputNotify cb, void *data) {
   Model *model = nullptr;
   int req_id;
 
@@ -474,9 +469,8 @@ HostHandler::runModel (uint32_t modelid, npu_infer_mode mode,
   switch (mode) {
     case NPU_INFER_BLOCKING: {
       callbackSync sync;
-      req_id =
-          device_->run (NPUINPUT_HOST, model, input, output,
-                        callbackSync::callback, static_cast<void *> (&sync));
+      req_id = device_->run (NPUINPUT_HOST, model, input, output, callbackSync::callback,
+                             static_cast<void *> (&sync));
       if (req_id > 0)
         sync.wait ();
     } break;
@@ -590,8 +584,7 @@ HostHandler::deallocGenericBuffer (generic_buffer *buffer) {
       /** always true cuz nothing to do */
       break;
     case BUFFER_MAPPED:
-      return device_->deallocMemory (buffer->dmabuf, buffer->size,
-                                     buffer->addr);
+      return device_->deallocMemory (buffer->dmabuf, buffer->size, buffer->addr);
     default:
       return -EINVAL;
   }
@@ -826,12 +819,10 @@ Device::deallocMemory (int dmabuf_fd, size_t size, void *addr) {
  * @return the segment table instance
  */
 SegmentTable *
-TrinityVision2::prepareSegmentTable (const Model *model,
-                                     const input_buffers *input,
+TrinityVision2::prepareSegmentTable (const Model *model, const input_buffers *input,
                                      const output_buffers *output) {
   const Metadata *meta = model->getMetadata ();
-  if (meta == nullptr ||
-      (input != nullptr && meta->getInputNum () != input->num_buffers)) {
+  if (meta == nullptr || (input != nullptr && meta->getInputNum () != input->num_buffers)) {
     logerr (TAG, "Invalid metadata info provided\n");
     return nullptr;
   }
@@ -876,8 +867,8 @@ TrinityVision2::checkDspmSize (const Model *model) {
   }
 
   if (npu_dspm_size < model_dspm_size) {
-    logerr (TAG, "The minimum DSPM size of model is %u KiB (NPU: %u KiB)\n",
-            model_dspm_size / 1024, npu_dspm_size / 1024);
+    logerr (TAG, "The minimum DSPM size of model is %u KiB (NPU: %u KiB)\n", model_dspm_size / 1024,
+            npu_dspm_size / 1024);
     return -ENOMEM;
   }
 
@@ -918,8 +909,8 @@ TrinityVision2::setModel (const generic_buffer *model_buf, Model **model_ptr) {
         goto delete_exit;
       }
 
-      status = comm_.extractGenericBuffer (model_buf, model->getData (),
-                                           nullptr, 0, NPUBIN_META_SIZE);
+      status =
+          comm_.extractGenericBuffer (model_buf, model->getData (), nullptr, 0, NPUBIN_META_SIZE);
       if (status != 0) {
         logerr (TAG, "Failed to extract generic buffer: %d\n", status);
         goto delete_exit;
@@ -952,10 +943,9 @@ TrinityVision2::setModel (const generic_buffer *model_buf, Model **model_ptr) {
       goto delete_exit;
     }
 
-    status =
-        comm_.extractGenericBuffer (model_buf, hwmem_prog->getData (), nullptr,
-                                    model->getMetadata ()->getMetaSize (),
-                                    model->getMetadata ()->getProgramSize ());
+    status = comm_.extractGenericBuffer (model_buf, hwmem_prog->getData (), nullptr,
+                                         model->getMetadata ()->getMetaSize (),
+                                         model->getMetadata ()->getProgramSize ());
     if (status != 0) {
       logerr (TAG, "Failed to extract generic buffer: %d\n", status);
       goto delete_exit;
@@ -986,9 +976,8 @@ TrinityVision2::setModel (const generic_buffer *model_buf, Model **model_ptr) {
       config.metadata_ext_dbuf_fd = hwmem_extended->getDmabuf ();
       config.metadata_ext_size = extended_size;
 
-      status =
-          comm_.extractGenericBuffer (model_buf, hwmem_extended->getData (),
-                                      nullptr, NPUBIN_META_SIZE, extended_size);
+      status = comm_.extractGenericBuffer (model_buf, hwmem_extended->getData (), nullptr,
+                                           NPUBIN_META_SIZE, extended_size);
       if (status != 0) {
         logerr (TAG, "Failed to extract generic buffer: %d\n", status);
         goto delete_exit;
@@ -1000,8 +989,7 @@ TrinityVision2::setModel (const generic_buffer *model_buf, Model **model_ptr) {
 
     config.num_visa_insts = model->getNumInsts ();
 
-    status =
-        api_->registerModel (&config, model->getMetadata ()->getNPUVersion ());
+    status = api_->registerModel (&config, model->getMetadata ()->getNPUVersion ());
     if (status != 0)
       goto delete_exit;
 
@@ -1023,8 +1011,7 @@ TrinityVision2::setModel (const generic_buffer *model_buf, Model **model_ptr) {
 
     status = comm_.extractGenericBuffer (
         model_buf, hwmem_weight->getData (), nullptr,
-        model->getMetadata ()->getMetaSize () +
-            model->getMetadata ()->getProgramSize (),
+        model->getMetadata ()->getMetaSize () + model->getMetadata ()->getProgramSize (),
         model->getMetadata ()->getWeightSize ());
     if (status != 0) {
       logerr (TAG, "Failed to extract generic buffer: %d\n", status);
@@ -1072,27 +1059,23 @@ TrinityVision2::unsetModel (Model *model) {
  * @return 0 if no error. otherwise a negative error value
  */
 int
-TrinityVision2::getTensorSize (const Model *model, bool input, uint32_t index,
-                               uint32_t *size) {
+TrinityVision2::getTensorSize (const Model *model, bool input, uint32_t index, uint32_t *size) {
   const Metadata *meta = model->getMetadata ();
   if (meta == nullptr)
     return -EINVAL;
 
   if (input)
-    *size =
-        meta->getInputTensorSize (index, meta->getInputSegmentLayout (index));
+    *size = meta->getInputTensorSize (index, meta->getInputSegmentLayout (index));
   else
-    *size =
-        meta->getOutputTensorSize (index, meta->getOutputSegmentLayout (index));
+    *size = meta->getOutputTensorSize (index, meta->getOutputSegmentLayout (index));
 
   return 0;
 }
 
 /** @brief implementation of TRIV2's run() */
 int
-TrinityVision2::run (npu_input_opmode opmode, const Model *model,
-                     const input_buffers *input, output_buffers *output,
-                     npuOutputNotify cb, void *cb_data) {
+TrinityVision2::run (npu_input_opmode opmode, const Model *model, const input_buffers *input,
+                     output_buffers *output, npuOutputNotify cb, void *cb_data) {
   if (!initialized ()) {
     logerr (TAG, "Uninitialized device; should use libnpuhost APIs\n");
     return -EPERM;
@@ -1119,11 +1102,9 @@ TrinityVision2::run (npu_input_opmode opmode, const Model *model,
     if (!segt->getInputSegment (idx)->isExternal ()) {
       uint32_t seg_offset = segt->getInputSegmentOffset (idx);
       auto func = std::bind (TrinityVision2::manipulateData, model, idx, true,
-                             std::placeholders::_1, std::placeholders::_2,
-                             std::placeholders::_3);
+                             std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
       status = comm_.extractGenericBuffer (
-          &input->bufs[idx],
-          segt->getInputSegment (idx)->getData () + seg_offset, func);
+          &input->bufs[idx], segt->getInputSegment (idx)->getData () + seg_offset, func);
       if (status != 0) {
         logerr (TAG, "Failed to feed input segment: %d\n", status);
         return status;
@@ -1141,8 +1122,7 @@ TrinityVision2::run (npu_input_opmode opmode, const Model *model,
   req->setModel (model);
   req->setInferData (segt);
   req->setOutputBuffers (output);
-  req->setCallback (
-      std::bind (&TrinityVision2::callback, this, req, cb, cb_data));
+  req->setCallback (std::bind (&TrinityVision2::callback, this, req, cb, cb_data));
 
   int req_id = req->getID ();
   status = scheduler_->submitRequest (req);
@@ -1182,8 +1162,7 @@ TrinityVision2::callback (Request *req, npuOutputNotify cb, void *cb_data) {
     if (output->bufs[idx].type == BUFFER_DMABUF) {
       /* it's external memory. can't do */
       continue;
-    } else if (output->bufs[idx].addr == nullptr ||
-               output->bufs[idx].size == 0) {
+    } else if (output->bufs[idx].addr == nullptr || output->bufs[idx].size == 0) {
       output->bufs[idx].type = BUFFER_MAPPED;
       output->bufs[idx].size = output_tensor_size;
       /** user needs to free this */
@@ -1194,9 +1173,8 @@ TrinityVision2::callback (Request *req, npuOutputNotify cb, void *cb_data) {
       }
     }
 
-    auto func = std::bind (TrinityVision2::manipulateData, model, idx, false,
-                           std::placeholders::_1, std::placeholders::_2,
-                           std::placeholders::_3);
+    auto func = std::bind (TrinityVision2::manipulateData, model, idx, false, std::placeholders::_1,
+                           std::placeholders::_2, std::placeholders::_3);
     void *dst;
 #ifdef __FPGA__
     /* this is fpga workaround codes for syncing output data */
@@ -1205,8 +1183,7 @@ TrinityVision2::callback (Request *req, npuOutputNotify cb, void *cb_data) {
       logerr (TAG, "Unable to allocate FPGA temp buffer\n");
       break;
     }
-    api_->fpga_memcpy (output_segment->getDmabuf (),
-                       segt->getOutputSegmentOffset (idx), dst,
+    api_->fpga_memcpy (output_segment->getDmabuf (), segt->getOutputSegmentOffset (idx), dst,
                        output_segment->getSize ());
 #else
     dst = output_segment->getData () + segt->getOutputSegmentOffset (idx);
@@ -1289,10 +1266,8 @@ TrinityVision2::getRequestModel (int req_id, uint32_t *model_id) {
 }
 
 int
-TrinityVision2::setRequestData (int req_id, input_buffers *input,
-                                tensors_data_info *in_info,
-                                output_buffers *output,
-                                tensors_data_info *out_info) {
+TrinityVision2::setRequestData (int req_id, input_buffers *input, tensors_data_info *in_info,
+                                output_buffers *output, tensors_data_info *out_info) {
   Request *req = scheduler_->findRequest (req_id);
   if (req == nullptr) {
     logerr (TAG, "Unable to find the request with ID (%d)\n", req_id);
@@ -1329,11 +1304,9 @@ TrinityVision2::setRequestData (int req_id, input_buffers *input,
     if (!segt->getInputSegment (idx)->isExternal ()) {
       uint32_t seg_offset = segt->getInputSegmentOffset (idx);
       auto func = std::bind (TrinityVision2::manipulateData, model, idx, true,
-                             std::placeholders::_1, std::placeholders::_2,
-                             std::placeholders::_3);
+                             std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
       int status = comm_.extractGenericBuffer (
-          &input->bufs[idx],
-          segt->getInputSegment (idx)->getData () + seg_offset, func);
+          &input->bufs[idx], segt->getInputSegment (idx)->getData () + seg_offset, func);
       if (status != 0) {
         logerr (TAG, "Failed to feed input segment: %d\n", status);
         return status;
@@ -1348,8 +1321,7 @@ TrinityVision2::setRequestData (int req_id, input_buffers *input,
 }
 
 int
-TrinityVision2::setRequestCallback (int req_id, npuOutputNotify cb,
-                                    void *data) {
+TrinityVision2::setRequestCallback (int req_id, npuOutputNotify cb, void *data) {
   Request *req = scheduler_->findRequest (req_id);
   if (req == nullptr) {
     logerr (TAG, "Unable to find the request with ID (%d)\n", req_id);
@@ -1446,8 +1418,7 @@ TrinityVision2::submitRequest (int req_id) {
     case NPU_INFER_NON_BLOCKING:
       if (req->getCallback () == nullptr) {
         logwarn (TAG, "inferencing without output callback...\n");
-        req->setCallback (
-            std::bind (&TrinityVision2::callback, this, req, nullptr, nullptr));
+        req->setCallback (std::bind (&TrinityVision2::callback, this, req, nullptr, nullptr));
       }
       status = scheduler_->submitRequest (req);
       break;
@@ -1523,8 +1494,8 @@ TrinityVision2::submitRequestKernel (int req_id) {
  *            Addr(x,y,z) = Addr(0,0,0) + (z % 64) + (64 * x) + ymod * y + zmod * (z / 64)
  */
 size_t
-TrinityVision2::manipulateData (const Model *model, uint32_t idx, bool is_input,
-                                void *dst, void *src, size_t size) {
+TrinityVision2::manipulateData (const Model *model, uint32_t idx, bool is_input, void *dst,
+                                void *src, size_t size) {
   const Metadata *meta = model->getMetadata ();
   DataConverter converter (is_input);
 
@@ -1558,8 +1529,8 @@ TrinityVision2::manipulateData (const Model *model, uint32_t idx, bool is_input,
 #else
 
 size_t
-TrinityVision2::manipulateData (const Model *model, uint32_t idx, bool is_input,
-                                void *dst, void *src, size_t size) {
+TrinityVision2::manipulateData (const Model *model, uint32_t idx, bool is_input, void *dst,
+                                void *src, size_t size) {
   memcpy (dst, src, size);
   return size;
 }
index 39c8f7e..1042759 100644 (file)
@@ -36,8 +36,7 @@ class HostHandler {
   int unregisterModel (uint32_t modelid);
   int unregisterModels ();
 
-  int getTensorSize (uint32_t modelid, bool input, uint32_t index,
-                     uint32_t *size);
+  int getTensorSize (uint32_t modelid, bool input, uint32_t index, uint32_t *size);
 
   int getProfile (int req_id, const npu_profile_opt &opt, npu_profile *profile);
   int setProfileModel (int req_id, uint32_t model_id);
@@ -45,8 +44,7 @@ class HostHandler {
   int getTops (uint32_t *tops);
   int getDspmSize (uint32_t *dspm);
 
-  int setDataInfo (uint32_t modelid, tensors_data_info *in,
-                   tensors_data_info *out);
+  int setDataInfo (uint32_t modelid, tensors_data_info *in, tensors_data_info *out);
   int setConstraint (uint32_t modelid, npuConstraint constraint);
 
   Model *getModel (uint32_t modelid);
@@ -57,22 +55,20 @@ class HostHandler {
   int deallocGenericBuffer (generic_buffer *buffer);
   int deallocGenericBuffer (generic_buffers *buffers);
 
-  int runModel (uint32_t modelid, npu_infer_mode mode,
-                const input_buffers *input, output_buffers *output = nullptr,
-                npuOutputNotify cb = nullptr, void *data = nullptr);
+  int runModel (uint32_t modelid, npu_infer_mode mode, const input_buffers *input,
+                output_buffers *output = nullptr, npuOutputNotify cb = nullptr,
+                void *data = nullptr);
 
   int createRequest (uint32_t model_id, int *req_id);
   int removeRequest (int req_id);
   int getRequestModel (int req_id, uint32_t *model_id);
 
-  int setRequestData (int req_id, input_buffers *input,
-                      tensors_data_info *in_info, output_buffers *output,
-                      tensors_data_info *out_info);
+  int setRequestData (int req_id, input_buffers *input, tensors_data_info *in_info,
+                      output_buffers *output, tensors_data_info *out_info);
   int setRequestCallback (int req_id, npuOutputNotify cb, void *data);
   int setRequestMode (int req_id, npu_infer_mode mode);
   int setRequestConstraint (int req_id, npu_constraint constraint);
-  int setRequestScheduler (int req_id, npu_scheduler sched,
-                           npu_scheduler_param sched_param);
+  int setRequestScheduler (int req_id, npu_scheduler sched, npu_scheduler_param sched_param);
 
   int submitRequest (int req_id);
   int submitRequestKernel (int req_id);
@@ -133,34 +129,27 @@ class Device {
   int deallocMemory (int dmabuf_fd, size_t size, void *addr);
 
   /** virtual methods to implement each device's behaviors */
-  virtual int setModel (const generic_buffer *model, Model **model_ptr) {
-    return -EPERM;
-  }
+  virtual int setModel (const generic_buffer *model, Model **model_ptr) { return -EPERM; }
   virtual int unsetModel (Model *model) { return -EPERM; }
 
-  virtual int getTensorSize (const Model *model, bool input, uint32_t index,
-                             uint32_t *size) {
+  virtual int getTensorSize (const Model *model, bool input, uint32_t index, uint32_t *size) {
     return -EPERM;
   }
 
-  virtual int run (npu_input_opmode opmode, const Model *model,
-                   const input_buffers *input, output_buffers *output = nullptr,
-                   npuOutputNotify cb = nullptr, void *cb_data = nullptr) = 0;
+  virtual int run (npu_input_opmode opmode, const Model *model, const input_buffers *input,
+                   output_buffers *output = nullptr, npuOutputNotify cb = nullptr,
+                   void *cb_data = nullptr) = 0;
 
   virtual int createRequest (const Model *model, int *req_id) = 0;
   virtual int removeRequest (int req_id) = 0;
   virtual int getRequestModel (int req_id, uint32_t *model_id) = 0;
 
-  virtual int setRequestData (int req_id, input_buffers *input,
-                              tensors_data_info *in_info,
-                              output_buffers *output,
-                              tensors_data_info *out_info) = 0;
-  virtual int setRequestCallback (int req_id, npuOutputNotify cb,
-                                  void *data) = 0;
+  virtual int setRequestData (int req_id, input_buffers *input, tensors_data_info *in_info,
+                              output_buffers *output, tensors_data_info *out_info) = 0;
+  virtual int setRequestCallback (int req_id, npuOutputNotify cb, void *data) = 0;
   virtual int setRequestMode (int req_id, npu_infer_mode mode) = 0;
   virtual int setRequestConstraint (int req_id, npu_constraint constraint) = 0;
-  virtual int setRequestScheduler (int req_id, npu_scheduler sched,
-                                   npu_scheduler_param param) = 0;
+  virtual int setRequestScheduler (int req_id, npu_scheduler sched, npu_scheduler_param param) = 0;
   virtual int submitRequest (int req_id) = 0;
   virtual int submitRequestKernel (int req_id) = 0;
 
@@ -195,36 +184,31 @@ class TrinityVision2 : public Device {
   TrinityVision2 (int id) : Device (NPUCOND_TRIV2_CONN_SOCIP, id) {}
   ~TrinityVision2 () {}
 
-  static size_t manipulateData (const Model *model, uint32_t idx, bool is_input,
-                                void *dst, void *src, size_t size);
+  static size_t manipulateData (const Model *model, uint32_t idx, bool is_input, void *dst,
+                                void *src, size_t size);
 
-  SegmentTable *prepareSegmentTable (const Model *model,
-                                     const input_buffers *input,
+  SegmentTable *prepareSegmentTable (const Model *model, const input_buffers *input,
                                      const output_buffers *output = nullptr);
 
   int setModel (const generic_buffer *model, Model **model_ptr);
   int unsetModel (Model *model);
 
-  int getTensorSize (const Model *model, bool input, uint32_t index,
-                     uint32_t *size);
+  int getTensorSize (const Model *model, bool input, uint32_t index, uint32_t *size);
   int checkDspmSize (const Model *model);
 
-  int run (npu_input_opmode opmode, const Model *model,
-           const input_buffers *input, output_buffers *output = nullptr,
-           npuOutputNotify cb = nullptr, void *cb_data = nullptr);
+  int run (npu_input_opmode opmode, const Model *model, const input_buffers *input,
+           output_buffers *output = nullptr, npuOutputNotify cb = nullptr, void *cb_data = nullptr);
 
   int createRequest (const Model *model, int *req_id);
   int removeRequest (int req_id);
   int getRequestModel (int req_id, uint32_t *model_id);
 
-  int setRequestData (int req_id, input_buffers *input,
-                      tensors_data_info *in_info, output_buffers *output,
-                      tensors_data_info *out_info);
+  int setRequestData (int req_id, input_buffers *input, tensors_data_info *in_info,
+                      output_buffers *output, tensors_data_info *out_info);
   int setRequestCallback (int req_id, npuOutputNotify cb, void *data);
   int setRequestMode (int req_id, npu_infer_mode mode);
   int setRequestConstraint (int req_id, npu_constraint constraint);
-  int setRequestScheduler (int req_id, npu_scheduler sched,
-                           npu_scheduler_param sched_param);
+  int setRequestScheduler (int req_id, npu_scheduler sched, npu_scheduler_param sched_param);
   int submitRequest (int req_id);
   int submitRequestKernel (int req_id);
 
index d43a0b4..b54e144 100644 (file)
@@ -38,8 +38,7 @@ HostInputService::getInstance () {
  * @return 0 if no error, otherwise a negative errno
  */
 int
-HostInputService::submit (const DriverAPI *api, const Request *req,
-                          outputCallback callback) {
+HostInputService::submit (const DriverAPI *api, const Request *req, outputCallback callback) {
   if (api == nullptr || req == nullptr) {
     logerr (TAG, "Invalid arguments\n");
     return -EINVAL;
@@ -55,8 +54,7 @@ HostInputService::submit (const DriverAPI *api, const Request *req,
     return -EINVAL;
   }
 
-  taskFunc func =
-      std::bind (&HostInputService::invoke, this, api, req, callback);
+  taskFunc func = std::bind (&HostInputService::invoke, this, api, req, callback);
   ThreadTask *task = new ThreadTask (req->getID (), func);
   return ThreadPool::getInstance ().enqueueTask (task);
 }
@@ -101,8 +99,7 @@ invoke_segt (const DriverAPI *api, const Request *req) {
   /** FIXME: update input_config fields */
   if (req->getScheduler () == NPU_SCHEDULER_VD) {
     if (req->getSchedulerParam ()) {
-      memcpy (&input_config.task_handle, req->getSchedulerParam (),
-              sizeof (uint32_t) * 2);
+      memcpy (&input_config.task_handle, req->getSchedulerParam (), sizeof (uint32_t) * 2);
     } else {
       input_config.task_handle = 0;
       input_config.subtask_idx = 0;
@@ -138,8 +135,7 @@ invoke_segt (const DriverAPI *api, const Request *req) {
  * @return 0 if no error, otherwise a negative errno
  */
 int
-HostInputService::invoke (const DriverAPI *api, const Request *req,
-                          outputCallback callback) {
+HostInputService::invoke (const DriverAPI *api, const Request *req, outputCallback callback) {
   device_state_t state;
   const Model *model;
   HWmem *data;
index 1f202a5..8e8fcaa 100644 (file)
@@ -37,8 +37,7 @@ HwInputService::getInstance () {
  * @return 0 if no error, otherwise a negativ errno
  */
 int
-HwInputService::submit (const DriverAPI *api, const Request *req,
-                        outputCallback callback) {
+HwInputService::submit (const DriverAPI *api, const Request *req, outputCallback callback) {
   if (api == nullptr || req == nullptr) {
     logerr (TAG, "Invalid arguments\n");
     return -EINVAL;
@@ -102,8 +101,7 @@ invoke_segt (const DriverAPI *api, const Request *req) {
   /** FIXME: update input_config fields */
   if (req->getScheduler () == NPU_SCHEDULER_VD) {
     if (req->getSchedulerParam ()) {
-      memcpy (&input_config.task_handle, req->getSchedulerParam (),
-              sizeof (uint32_t) * 2);
+      memcpy (&input_config.task_handle, req->getSchedulerParam (), sizeof (uint32_t) * 2);
     } else {
       input_config.task_id = req->getID ();
     }
@@ -135,8 +133,7 @@ invoke_segt (const DriverAPI *api, const Request *req) {
  * @return req_id if no error, otherwise a negative errno
  */
 int
-HwInputService::invoke (const DriverAPI *api, const Request *req,
-                        outputCallback callback) {
+HwInputService::invoke (const DriverAPI *api, const Request *req, outputCallback callback) {
   device_state_t state;
   const Model *model;
   HWmem *data;
index b501d03..d8fde9e 100644 (file)
@@ -81,15 +81,13 @@ HWmemDevice::cleanup (HWmem *hwmem) const {
     return;
 
   if (hwmem->getBaseAddr () != nullptr) {
-    hwmem->getDriverAPI ()->munmap (hwmem->getBaseAddr (),
-                                    ALIGNED_SIZE (hwmem->getSize ()));
+    hwmem->getDriverAPI ()->munmap (hwmem->getBaseAddr (), ALIGNED_SIZE (hwmem->getSize ()));
 
     hwmem->setBaseAddr (nullptr);
   }
 
   if (hwmem->getDmabuf () >= 0) {
-    hwmem->getDriverAPI ()->dealloc (hwmem->getDmabuf (),
-                                     hwmem->isContiguous ());
+    hwmem->getDriverAPI ()->dealloc (hwmem->getDmabuf (), hwmem->isContiguous ());
 
     hwmem->setDmabuf (-1);
     hwmem->setSize (0);
@@ -112,8 +110,7 @@ HWmemDevice::alloc (HWmem *hwmem, size_t size) const {
     return -EBUSY;
   }
 
-  int dmabuf = hwmem->getDriverAPI ()->alloc (ALIGNED_SIZE (size),
-                                              hwmem->isContiguous ());
+  int dmabuf = hwmem->getDriverAPI ()->alloc (ALIGNED_SIZE (size), hwmem->isContiguous ());
   if (dmabuf < 0)
     return dmabuf;
 
index 6aa76c9..eb54b6c 100644 (file)
@@ -78,9 +78,7 @@ class HWmem {
   size_t getOffset () const { return offset_; }
   void *getBaseAddr () const { return base_addr_; }
   HWmem *getParent () const { return parent_; }
-  bool isExternal () const {
-    return nullptr != dynamic_cast<const HWmemExternal *> (impl_);
-  }
+  bool isExternal () const { return nullptr != dynamic_cast<const HWmemExternal *> (impl_); }
   bool isContiguous () const { return contiguous_; }
 
   /** set private member variables */
@@ -101,7 +99,7 @@ class HWmem {
   const HWmemImpl *impl_; /**< HWmem impl. */
   const DriverAPI *api_;  /**< driver API */
 
-  int dmabuf_; /**< dmabuf fd of hwmem (equal to base address when mapped) */
+  int dmabuf_;      /**< dmabuf fd of hwmem (equal to base address when mapped) */
   void *base_addr_; /**< base address of hwmem */
   size_t offset_;   /**< offset of hwmem (starting from base address) */
   size_t size_;     /**< size of hwmem */
index 0df702f..ba0bc5c 100644 (file)
@@ -48,14 +48,12 @@ class HostInputService : public InputService {
  public:
   static HostInputService &getInstance ();
 
-  int submit (const DriverAPI *api, const Request *request,
-              outputCallback callback = nullptr);
+  int submit (const DriverAPI *api, const Request *request, outputCallback callback = nullptr);
   int remove (const DriverAPI *api, int request_id);
 
  private:
   /** do not allow to directly call invoke () */
-  int invoke (const DriverAPI *api, const Request *request,
-              outputCallback callback = nullptr);
+  int invoke (const DriverAPI *api, const Request *request, outputCallback callback = nullptr);
   /** singleton pattern */
   static std::unique_ptr<HostInputService> instance_;
   static std::once_flag once_flag_;
@@ -66,13 +64,11 @@ class HwInputService : public InputService {
  public:
   static HwInputService &getInstance ();
 
-  int submit (const DriverAPI *api, const Request *request,
-              outputCallback callback = nullptr);
+  int submit (const DriverAPI *api, const Request *request, outputCallback callback = nullptr);
   int remove (const DriverAPI *api, int request_id);
 
  private:
-  int invoke (const DriverAPI *api, const Request *request,
-              outputCallback callback = nullptr);
+  int invoke (const DriverAPI *api, const Request *request, outputCallback callback = nullptr);
   /** singleton pattern */
   static std::unique_ptr<HwInputService> instance_;
   static std::once_flag once_flag_;
index fd1ebed..5c79017 100644 (file)
@@ -44,9 +44,7 @@ class MemAllocator {
      * Below allocates the actual memory. So, the caller don't need to call alloc().
      */
   virtual int allocMemory (size_t size, void **addr) { return -EINVAL; }
-  virtual int deallocMemory (int dmabuf, size_t size, void *addr) {
-    return -EINVAL;
-  }
+  virtual int deallocMemory (int dmabuf, size_t size, void *addr) { return -EINVAL; }
 
   /**
      * Below does not allocate actual memory as we don't know the type of generic buffer
@@ -57,8 +55,7 @@ class MemAllocator {
   virtual SegmentTable *allocSegmentTable (HWmemImpl *impl) { return nullptr; }
 
  protected:
-  const DriverAPI
-      *api_; /**< driver API that this allocator is supposed to access */
+  const DriverAPI *api_; /**< driver API that this allocator is supposed to access */
 };
 
 #endif /* __NPU_ENGINE_MEM_H__ */
index 3b260aa..8815a9b 100644 (file)
@@ -86,9 +86,8 @@ Metadata_v1 *
 Metadata_v1::createInstance (npubin_meta *meta) {
   Metadata_v1 *metadata = new Metadata_v1 (meta);
 
-  if (metadata->getSize () != metadata->getMetaSize () +
-                                  metadata->getProgramSize () +
-                                  metadata->getWeightSize ())
+  if (metadata->getSize () !=
+      metadata->getMetaSize () + metadata->getProgramSize () + metadata->getWeightSize ())
     goto sanity_violation;
 
   return metadata;
@@ -110,9 +109,8 @@ Metadata_v2::createInstance (npubin_meta *meta) {
     goto sanity_violation;
   if (metadata->getOutputNum () > MAX_TENSORS)
     goto sanity_violation;
-  if (metadata->getSize () != metadata->getMetaSize () +
-                                  metadata->getProgramSize () +
-                                  metadata->getWeightSize ())
+  if (metadata->getSize () !=
+      metadata->getMetaSize () + metadata->getProgramSize () + metadata->getWeightSize ())
     goto sanity_violation;
 
   return metadata;
@@ -131,8 +129,7 @@ Metadata_v2::getInputTensorSize (uint32_t idx, data_layout layout) const {
   uint32_t elem_size = getInputElemSize (idx);
   uint32_t tensor_size = elem_size;
 
-  for (uint32_t rank_idx = 0; rank_idx < MAX_RANK; rank_idx++)
-    tensor_size *= dims[rank_idx];
+  for (uint32_t rank_idx = 0; rank_idx < MAX_RANK; rank_idx++) tensor_size *= dims[rank_idx];
 
   uint32_t granularity = DATA_GRANULARITY;
   uint32_t shift = DATA_GRANULARITY_SHIFT;
@@ -145,8 +142,7 @@ Metadata_v2::getInputTensorSize (uint32_t idx, data_layout layout) const {
   granularity /= div;
 
   /** special handling for TRIV */
-  if (layout == DATA_LAYOUT_SRNPU && dims[3] != 3 &&
-      dims[3] % granularity != 0) {
+  if (layout == DATA_LAYOUT_SRNPU && dims[3] != 3 && dims[3] % granularity != 0) {
     uint32_t depth;
 
     depth = (dims[3] + granularity - 1) >> shift;
@@ -168,8 +164,7 @@ Metadata_v2::getOutputTensorSize (uint32_t idx, data_layout layout) const {
   uint32_t elem_size = getOutputElemSize (idx);
   uint32_t tensor_size = elem_size;
 
-  for (uint32_t rank_idx = 0; rank_idx < MAX_RANK; rank_idx++)
-    tensor_size *= dims[rank_idx];
+  for (uint32_t rank_idx = 0; rank_idx < MAX_RANK; rank_idx++) tensor_size *= dims[rank_idx];
 
   uint32_t granularity = DATA_GRANULARITY;
   uint32_t shift = DATA_GRANULARITY_SHIFT;
@@ -182,8 +177,7 @@ Metadata_v2::getOutputTensorSize (uint32_t idx, data_layout layout) const {
   granularity /= div;
 
   /** special handling for TRIV */
-  if (layout == DATA_LAYOUT_SRNPU && dims[3] != 3 &&
-      dims[3] % granularity != 0) {
+  if (layout == DATA_LAYOUT_SRNPU && dims[3] != 3 && dims[3] % granularity != 0) {
     uint32_t depth;
 
     depth = (dims[3] + granularity - 1) >> shift;
@@ -225,9 +219,8 @@ Metadata_v3::createInstance (npubin_meta *meta) {
       goto sanity_violation;
   }
 
-  if (metadata->getSize () != metadata->getMetaSize () +
-                                  metadata->getProgramSize () +
-                                  metadata->getWeightSize ())
+  if (metadata->getSize () !=
+      metadata->getMetaSize () + metadata->getProgramSize () + metadata->getWeightSize ())
     goto sanity_violation;
 
   return metadata;
@@ -249,8 +242,7 @@ Metadata_v3::getInputTensorSize (uint32_t idx, data_layout layout) const {
   uint32_t elem_size = getInputElemSize (idx);
   uint32_t tensor_size = elem_size;
 
-  for (uint32_t rank_idx = 0; rank_idx < MAX_RANK; rank_idx++)
-    tensor_size *= dims[rank_idx];
+  for (uint32_t rank_idx = 0; rank_idx < MAX_RANK; rank_idx++) tensor_size *= dims[rank_idx];
 
   if (layout == DATA_LAYOUT_NONE || layout == DATA_LAYOUT_TRIV2) {
     uint32_t granularity = DATA_GRANULARITY;
@@ -297,8 +289,7 @@ Metadata_v3::getOutputTensorSize (uint32_t idx, data_layout layout) const {
   uint32_t elem_size = getOutputElemSize (idx);
   uint32_t tensor_size = elem_size;
 
-  for (uint32_t rank_idx = 0; rank_idx < MAX_RANK; rank_idx++)
-    tensor_size *= dims[rank_idx];
+  for (uint32_t rank_idx = 0; rank_idx < MAX_RANK; rank_idx++) tensor_size *= dims[rank_idx];
 
   if (layout == DATA_LAYOUT_NONE || layout == DATA_LAYOUT_TRIV2) {
     uint32_t granularity = DATA_GRANULARITY;
@@ -389,16 +380,14 @@ Model::setDataInfo (const tensors_data_info *in, const tensors_data_info *out) {
 
   for (uint32_t idx = 0; idx < in->num_info; idx++) {
     if (meta_->getInputSegmentLayout (idx) == DATA_LAYOUT_RAW &&
-        in->info[idx].layout != DATA_LAYOUT_MODEL &&
-        in->info[idx].layout != DATA_LAYOUT_NHWC &&
+        in->info[idx].layout != DATA_LAYOUT_MODEL && in->info[idx].layout != DATA_LAYOUT_NHWC &&
         in->info[idx].layout != DATA_LAYOUT_NCHW)
       logwarn (TAG, "input[%u] is raw data. skip layout conversion\n", idx);
   }
 
   for (uint32_t idx = 0; idx < out->num_info; idx++) {
     if (meta_->getOutputSegmentLayout (idx) == DATA_LAYOUT_RAW &&
-        out->info[idx].layout != DATA_LAYOUT_MODEL &&
-        out->info[idx].layout != DATA_LAYOUT_NHWC &&
+        out->info[idx].layout != DATA_LAYOUT_MODEL && out->info[idx].layout != DATA_LAYOUT_NHWC &&
         out->info[idx].layout != DATA_LAYOUT_NCHW)
       logwarn (TAG, "output[%u] is raw data. skip layout conversion\n", idx);
   }
@@ -510,9 +499,7 @@ Model::getInputTensorSize (uint32_t idx) const {
   }
 
   if (in_.num_info <= idx) {
-    logerr (
-        TAG,
-        "Input tensor info mismatch. Do setNPU_dataInfo() first properly\n");
+    logerr (TAG, "Input tensor info mismatch. Do setNPU_dataInfo() first properly\n");
     return 0;
   }
 
@@ -533,9 +520,7 @@ Model::getOutputTensorSize (uint32_t idx) const {
   }
 
   if (out_.num_info <= idx) {
-    logerr (
-        TAG,
-        "Output tensor info mismatch. Do setNPU_dataInfo() first properly\n");
+    logerr (TAG, "Output tensor info mismatch. Do setNPU_dataInfo() first properly\n");
     return 0;
   }
 
@@ -566,9 +551,7 @@ Model::getInputDataInfo (uint32_t idx) const {
   }
 
   if (in_.num_info <= idx) {
-    logerr (
-        TAG,
-        "Input tensor info mismatch. Do setNPU_dataInfo() first properly\n");
+    logerr (TAG, "Input tensor info mismatch. Do setNPU_dataInfo() first properly\n");
     return nullptr;
   }
 
@@ -588,9 +571,7 @@ Model::getOutputDataInfo (uint32_t idx) const {
   }
 
   if (out_.num_info <= idx) {
-    logerr (
-        TAG,
-        "Output tensor info mismatch. Do setNPU_dataInfo() first properly\n");
+    logerr (TAG, "Output tensor info mismatch. Do setNPU_dataInfo() first properly\n");
     return nullptr;
   }
 
index c6d0787..c169a3b 100644 (file)
@@ -56,10 +56,8 @@ class Metadata {
   virtual uint32_t getInputOffset (uint32_t idx) const = 0;
   virtual uint32_t getOutputOffset (uint32_t idx) const = 0;
 
-  virtual uint32_t getInputTensorSize (uint32_t idx,
-                                       data_layout layout) const = 0;
-  virtual uint32_t getOutputTensorSize (uint32_t idx,
-                                        data_layout layout) const = 0;
+  virtual uint32_t getInputTensorSize (uint32_t idx, data_layout layout) const = 0;
+  virtual uint32_t getOutputTensorSize (uint32_t idx, data_layout layout) const = 0;
 
   virtual uint32_t getInputElemSize (uint32_t idx) const = 0;
   virtual uint32_t getOutputElemSize (uint32_t idx) const = 0;
@@ -67,26 +65,14 @@ class Metadata {
   virtual const uint32_t *getInputDims (uint32_t idx) const = 0;
   virtual const uint32_t *getOutputDims (uint32_t idx) const = 0;
 
-  virtual uint32_t getInputQuantZero (uint32_t idx) const {
-    return default_quant_zero;
-  }
-  virtual float getInputQuantScale (uint32_t idx) const {
-    return default_quant_scale;
-  }
+  virtual uint32_t getInputQuantZero (uint32_t idx) const { return default_quant_zero; }
+  virtual float getInputQuantScale (uint32_t idx) const { return default_quant_scale; }
 
-  virtual uint32_t getOutputQuantZero (uint32_t idx) const {
-    return default_quant_zero;
-  }
-  virtual float getOutputQuantScale (uint32_t idx) const {
-    return default_quant_scale;
-  }
+  virtual uint32_t getOutputQuantZero (uint32_t idx) const { return default_quant_zero; }
+  virtual float getOutputQuantScale (uint32_t idx) const { return default_quant_scale; }
 
-  virtual data_type getInputQuantType (uint32_t idx) const {
-    return default_data_type;
-  }
-  virtual data_type getOutputQuantType (uint32_t idx) const {
-    return default_data_type;
-  }
+  virtual data_type getInputQuantType (uint32_t idx) const { return default_data_type; }
+  virtual data_type getOutputQuantType (uint32_t idx) const { return default_data_type; }
 
   virtual uint32_t getSegmentsNum () const { return 0; }
   virtual uint32_t getSegmentSize (uint32_t idx) const { return 0; }
@@ -95,12 +81,8 @@ class Metadata {
   virtual uint32_t getOutputSegmentIndex (uint32_t idx) const { return 0; }
   virtual uint32_t getInputSegmentOffset (uint32_t idx) const { return 0; }
   virtual uint32_t getOutputSegmentOffset (uint32_t idx) const { return 0; }
-  virtual data_layout getInputSegmentLayout (uint32_t idx) const {
-    return DATA_LAYOUT_NONE;
-  }
-  virtual data_layout getOutputSegmentLayout (uint32_t idx) const {
-    return DATA_LAYOUT_NONE;
-  }
+  virtual data_layout getInputSegmentLayout (uint32_t idx) const { return DATA_LAYOUT_NONE; }
+  virtual data_layout getOutputSegmentLayout (uint32_t idx) const { return DATA_LAYOUT_NONE; }
 
   virtual uint32_t getInputEmodY (uint32_t idx) const { return 0; }
   virtual uint32_t getInputEmodZ (uint32_t idx) const { return 0; }
@@ -114,9 +96,7 @@ class Metadata {
   uint64_t getProgramSize () const { return meta_->program_size; }
   uint64_t getWeightSize () const { return meta_->weight_size; }
   uint64_t getBufferSize () const { return meta_->buffer_size; }
-  uint64_t getMetaSize () const {
-    return NPUBIN_META_SIZE + getMetaExtendedSize ();
-  }
+  uint64_t getMetaSize () const { return NPUBIN_META_SIZE + getMetaExtendedSize (); }
   uint64_t getMetaExtendedSize () const {
     if (meta_->extended_metasize == 0)
       return NPUBIN_META_EXTENDED_SIZE (meta_->magiccode);
@@ -149,30 +129,20 @@ class Metadata_v1 : public Metadata {
   uint32_t getOutputOffset (uint32_t idx) const override {
     return static_cast<uint32_t> (meta_->output_offset);
   }
-  uint32_t getInputTensorSize (uint32_t idx,
-                               data_layout layout) const override {
+  uint32_t getInputTensorSize (uint32_t idx, data_layout layout) const override {
     return static_cast<uint32_t> (meta_->input_size);
   }
-  uint32_t getOutputTensorSize (uint32_t idx,
-                                data_layout layout) const override {
+  uint32_t getOutputTensorSize (uint32_t idx, data_layout layout) const override {
     return static_cast<uint32_t> (meta_->output_size);
   }
   uint32_t getInputElemSize (uint32_t idx) const override { return 1; }
   uint32_t getOutputElemSize (uint32_t idx) const override { return 1; }
-  const uint32_t *getInputDims (uint32_t idx) const override {
-    return input_dims[idx];
-  }
-  const uint32_t *getOutputDims (uint32_t idx) const override {
-    return output_dims[idx];
-  }
+  const uint32_t *getInputDims (uint32_t idx) const override { return input_dims[idx]; }
+  const uint32_t *getOutputDims (uint32_t idx) const override { return output_dims[idx]; }
 
-  data_type getInputQuantType (uint32_t idx) const override {
-    return DATA_TYPE_SRNPU;
-  }
+  data_type getInputQuantType (uint32_t idx) const override { return DATA_TYPE_SRNPU; }
 
-  data_type getOutputQuantType (uint32_t idx) const override {
-    return DATA_TYPE_SRNPU;
-  }
+  data_type getOutputQuantType (uint32_t idx) const override { return DATA_TYPE_SRNPU; }
 
  private:
   Metadata_v1 (npubin_meta *meta);
@@ -200,8 +170,7 @@ class Metadata_v2 : public Metadata {
   }
 
   uint32_t getInputTensorSize (uint32_t idx, data_layout layout) const override;
-  uint32_t getOutputTensorSize (uint32_t idx,
-                                data_layout layout) const override;
+  uint32_t getOutputTensorSize (uint32_t idx, data_layout layout) const override;
 
   uint32_t getInputElemSize (uint32_t idx) const override {
     assert (idx < getInputNum ());
@@ -268,8 +237,7 @@ class Metadata_v3 : public Metadata {
   uint32_t getOutputOffset (uint32_t idx) const override { return 0; }
 
   uint32_t getInputTensorSize (uint32_t idx, data_layout layout) const override;
-  uint32_t getOutputTensorSize (uint32_t idx,
-                                data_layout layout) const override;
+  uint32_t getOutputTensorSize (uint32_t idx, data_layout layout) const override;
 
   uint32_t getInputElemSize (uint32_t idx) const override {
     return get_data_size (getInputQuantType (idx));
@@ -336,9 +304,7 @@ class Metadata_v3 : public Metadata {
     assert (idx < getSegmentsNum ());
     return meta_->segment_size[idx];
   }
-  uint32_t getWeightSegmentIndex () const override {
-    return meta_->weight_seg_idx;
-  }
+  uint32_t getWeightSegmentIndex () const override { return meta_->weight_seg_idx; }
   uint32_t getInputSegmentIndex (uint32_t idx) const override {
     assert (idx < getInputNum ());
     return meta_->input_seg_idx[idx];
@@ -379,9 +345,7 @@ class Model : public HWmem {
 
   uint32_t getNumInsts ();
 
-  void setConstraint (const npuConstraint &constraint) {
-    constraint_ = constraint;
-  }
+  void setConstraint (const npuConstraint &constraint) { constraint_ = constraint; }
   int setDataInfo (const tensors_data_info *in, const tensors_data_info *out);
   int setMetadata (void *data);
   void setExtendedMetadata (HWmem *data) { extended_meta_ = data; }
@@ -417,17 +381,16 @@ class Model : public HWmem {
  private:
   static std::atomic<uint32_t> global_model_id_; /**< global model id */
   uint32_t model_id_;                            /**< model id */
-  uint64_t internal_id_; /**< model id internally managed by the device */
+  uint64_t internal_id_;                         /**< model id internally managed by the device */
 
   HWmem *weight_data_;   /**< weight data */
   HWmem *program_data_;  /**< weight data */
   HWmem *extended_meta_; /**< extended metadata */
 
   std::unique_ptr<Metadata> meta_; /**< metadata */
-  npuConstraint
-      constraint_;        /**< per-model constraint (e.g., timeout/priority) */
-  tensors_data_info in_;  /**< input tensor info. (e.g., data type/layout) */
-  tensors_data_info out_; /**< output tensor info. */
+  npuConstraint constraint_;       /**< per-model constraint (e.g., timeout/priority) */
+  tensors_data_info in_;           /**< input tensor info. (e.g., data type/layout) */
+  tensors_data_info out_;          /**< output tensor info. */
 };
 
 #endif /* __NE_MODEL_HH__ */
index fa6bc65..603284e 100644 (file)
@@ -26,8 +26,7 @@ ModelProfiler::appendRequest (int req_id, const Model *model) {
 }
 
 int
-ModelProfiler::getProfile (int req_id, const npu_profile_opt &opt,
-                           npu_profile *profile) {
+ModelProfiler::getProfile (int req_id, const npu_profile_opt &opt, npu_profile *profile) {
   ProfileData *data = profile_map_.find (req_id);
   if (data == nullptr)
     return -ENOENT;
@@ -56,8 +55,7 @@ void
 ModelProfiler::manipulateProfile (HWmem *extended, npu_profile *profile) {
   npubin_meta_profile *meta_profile =
       reinterpret_cast<npubin_meta_profile *> (extended->getData ());
-  npu_profile_layer *new_layers =
-      new npu_profile_layer[meta_profile->node_entry_num + 1];
+  npu_profile_layer *new_layers = new npu_profile_layer[meta_profile->node_entry_num + 1];
 
   npu_profile_layer *unclassified = &new_layers[meta_profile->node_entry_num];
 
@@ -143,14 +141,10 @@ ModelProfiler::manipulateProfile (HWmem *extended, npu_profile *profile) {
             layer->start_cycles = profile->layers[i].start_cycles;
           if (layer->end_cycles < profile->layers[i].end_cycles)
             layer->end_cycles = profile->layers[i].end_cycles;
-          layer->dram_read_bytes +=
-              profile->layers[i].dram_read_bytes / node_num;
-          layer->dram_write_bytes +=
-              profile->layers[i].dram_write_bytes / node_num;
-          layer->sram_read_bytes +=
-              profile->layers[i].sram_read_bytes / node_num;
-          layer->sram_write_bytes +=
-              profile->layers[i].sram_write_bytes / node_num;
+          layer->dram_read_bytes += profile->layers[i].dram_read_bytes / node_num;
+          layer->dram_write_bytes += profile->layers[i].dram_write_bytes / node_num;
+          layer->sram_read_bytes += profile->layers[i].sram_read_bytes / node_num;
+          layer->sram_write_bytes += profile->layers[i].sram_write_bytes / node_num;
           layer->visa_exec_seq = -1;
         } else {
           std::cerr << "Unable to find the node ID " << node_id << std::endl;
index c7581dd..548a9e9 100644 (file)
@@ -19,8 +19,7 @@
 
 class ProfileData {
  public:
-  ProfileData (int req_id, const Model *model)
-      : req_id_ (req_id), model_ (model) {}
+  ProfileData (int req_id, const Model *model) : req_id_ (req_id), model_ (model) {}
 
   const Model *getModel () { return model_; }
 
index 9cba57d..66ad297 100644 (file)
@@ -62,8 +62,7 @@ class Request {
   void setInferMode (npu_infer_mode infer_mode) { infer_mode_ = infer_mode; }
   npu_infer_mode getInferMode () const { return infer_mode_; }
 
-  void setScheduler (const npu_scheduler &sched,
-                     const npu_scheduler_param &sched_param) {
+  void setScheduler (const npu_scheduler &sched, const npu_scheduler_param &sched_param) {
     sched_ = sched;
     sched_param_ = sched_param;
   }
index 921fa96..f526d04 100644 (file)
@@ -142,8 +142,7 @@ Scheduler::submitRequest (Request *req) {
   }
 
   req->setSubmitted (true);
-  int ret = service->submit (api_, req,
-                             std::bind (&Scheduler::handleCallback, this, req));
+  int ret = service->submit (api_, req, std::bind (&Scheduler::handleCallback, this, req));
   if (ret != 0)
     req->setSubmitted (false);
 
index c073471..2340889 100644 (file)
@@ -60,15 +60,13 @@ SegmentTable::updateSegmentSlot (HWmem *hwmem, int slot) {
   int dbuf_fd = hwmem->getDmabuf ();
   if (dbuf_fd != KERNEL_INPUT_SEG && dbuf_fd != KERNEL_OUTPUT_SEG) {
     reinterpret_cast<int32_t *> (getData ())[slot] = dbuf_fd;
-    reinterpret_cast<uint32_t *> (getData () + getSize () / 2)[slot] =
-        hwmem->getOffset ();
+    reinterpret_cast<uint32_t *> (getData () + getSize () / 2)[slot] = hwmem->getOffset ();
 
     if (hwmem->getOffset () % SEGMENT_ALIGN != 0)
       logwarn (TAG, "Segment is not aligned..?\n");
   } else {
     reinterpret_cast<int32_t *> (getData ())[slot] = dbuf_fd;
-    reinterpret_cast<uint32_t *> (getData () + getSize () / 2)[slot] =
-        hwmem->getSize ();
+    reinterpret_cast<uint32_t *> (getData () + getSize () / 2)[slot] = hwmem->getSize ();
   }
 }
 
@@ -114,11 +112,10 @@ SegmentTable::createSegment (uint32_t seg_idx, uint32_t seg_size) {
  * @note A non-zero segment offset is currently not supported
  */
 int
-SegmentTable::createExternalSegment (uint32_t seg_idx, uint32_t seg_size,
-                                     uint32_t seg_off, int dbuf_fd) {
+SegmentTable::createExternalSegment (uint32_t seg_idx, uint32_t seg_size, uint32_t seg_off,
+                                     int dbuf_fd) {
   if (seg_off != 0) {
-    logerr (TAG,
-            "Non-zero segment offset is not supported for BUFFER_DMABUF\n");
+    logerr (TAG, "Non-zero segment offset is not supported for BUFFER_DMABUF\n");
     return -EINVAL;
   }
 
@@ -144,9 +141,7 @@ SegmentTable::createWeightSegment (const Model *model) {
   uint32_t idx = meta->getWeightSegmentIndex ();
   uint32_t size = meta->getSegmentSize (idx);
   if (meta->getWeightSize () > size) {
-    logerr (TAG,
-            "The size of weight (%" PRIu64
-            ") is larger than segment size (%u)\n",
+    logerr (TAG, "The size of weight (%" PRIu64 ") is larger than segment size (%u)\n",
             meta->getWeightSize (), size);
     return -EINVAL;
   }
@@ -175,8 +170,7 @@ SegmentTable::createWeightSegment (const Model *model) {
 }
 
 int
-SegmentTable::createExternalInputSegments (const Model *model,
-                                           const input_buffers *input) {
+SegmentTable::createExternalInputSegments (const Model *model, const input_buffers *input) {
   const Metadata *meta = model->getMetadata ();
 
   if (input == nullptr)
@@ -189,8 +183,7 @@ SegmentTable::createExternalInputSegments (const Model *model,
       uint32_t offset = meta->getInputSegmentOffset (i);
       uint32_t size = meta->getSegmentSize (idx);
 
-      int status =
-          createExternalSegment (idx, size, offset, input->bufs[i].dmabuf);
+      int status = createExternalSegment (idx, size, offset, input->bufs[i].dmabuf);
       if (status != 0)
         return status;
     }
@@ -200,8 +193,7 @@ SegmentTable::createExternalInputSegments (const Model *model,
 }
 
 int
-SegmentTable::createExternalOutputSegments (const Model *model,
-                                            const output_buffers *output) {
+SegmentTable::createExternalOutputSegments (const Model *model, const output_buffers *output) {
   const Metadata *meta = model->getMetadata ();
 
   if (output == nullptr || output->num_buffers == 0)
@@ -214,8 +206,7 @@ SegmentTable::createExternalOutputSegments (const Model *model,
       uint32_t offset = meta->getOutputSegmentOffset (i);
       uint32_t size = meta->getSegmentSize (idx);
 
-      int status =
-          createExternalSegment (idx, size, offset, output->bufs[i].dmabuf);
+      int status = createExternalSegment (idx, size, offset, output->bufs[i].dmabuf);
       if (status != 0)
         return status;
     }
@@ -282,8 +273,7 @@ SegmentTable::createSegments (const Model *model, const input_buffers *input,
       uint32_t size = meta->getSegmentSize (idx);
       status = createSegment (idx, size);
       if (status != 0) {
-        logerr (TAG, "Failed to allocate %uth segment with size %u: %d\n", idx,
-                size, status);
+        logerr (TAG, "Failed to allocate %uth segment with size %u: %d\n", idx, size, status);
         goto err_clear;
       }
     }
@@ -356,8 +346,8 @@ SegmentTable::getWeightSegment (uint32_t idx) {
     return nullptr;
 
   if (idx >= num_weight_segments_) {
-    logerr (TAG, "Invalid weight segment index (%u). Should be less than %u\n",
-            idx, num_weight_segments_);
+    logerr (TAG, "Invalid weight segment index (%u). Should be less than %u\n", idx,
+            num_weight_segments_);
     return nullptr;
   }
 
@@ -380,8 +370,8 @@ SegmentTable::getInputSegment (uint32_t idx) {
   }
 
   if (idx >= num_input_segments_) {
-    logerr (TAG, "Invalid input segment index (%u). Should be less than %u\n",
-            idx, num_input_segments_);
+    logerr (TAG, "Invalid input segment index (%u). Should be less than %u\n", idx,
+            num_input_segments_);
     return nullptr;
   }
 
@@ -404,8 +394,8 @@ SegmentTable::getOutputSegment (uint32_t idx) {
   }
 
   if (idx >= num_output_segments_) {
-    logerr (TAG, "Invalid output segment index (%u). Should be less than %u\n",
-            idx, num_output_segments_);
+    logerr (TAG, "Invalid output segment index (%u). Should be less than %u\n", idx,
+            num_output_segments_);
     return nullptr;
   }
 
@@ -428,8 +418,8 @@ SegmentTable::getInputSegmentOffset (uint32_t idx) {
   }
 
   if (idx >= num_input_segments_) {
-    logerr (TAG, "Invalid input segment index (%u). Should be less than %u\n",
-            idx, num_input_segments_);
+    logerr (TAG, "Invalid input segment index (%u). Should be less than %u\n", idx,
+            num_input_segments_);
     return 0;
   }
 
@@ -449,8 +439,8 @@ SegmentTable::getOutputSegmentOffset (uint32_t idx) {
   }
 
   if (idx >= num_output_segments_) {
-    logerr (TAG, "Invalid output segment index (%u). Should be less than %u\n",
-            idx, num_output_segments_);
+    logerr (TAG, "Invalid output segment index (%u). Should be less than %u\n", idx,
+            num_output_segments_);
     return 0;
   }
 
index befea1c..3a3cd9e 100644 (file)
@@ -30,15 +30,12 @@ class SegmentTable : public HWmem {
   ~SegmentTable ();
 
   /** Override alloc () and DO NOT support a variable-sized segment table */
-  int alloc (size_t = 0) {
-    return static_cast<HWmem *> (this)->alloc (PAGE_SIZE);
-  }
+  int alloc (size_t = 0) { return static_cast<HWmem *> (this)->alloc (PAGE_SIZE); }
   int createSegments (const Model *model, const input_buffers *input,
                       const output_buffers *output = nullptr);
   int restoreSegments (void);
 
-  HWmem *getWeightSegment (
-      uint32_t idx = 0); /** maybe, # weight segments is 1 */
+  HWmem *getWeightSegment (uint32_t idx = 0); /** maybe, # weight segments is 1 */
   HWmem *getInputSegment (uint32_t idx);
   HWmem *getOutputSegment (uint32_t idx);
 
@@ -58,14 +55,11 @@ class SegmentTable : public HWmem {
   void updateSegmentSlot (HWmem *hwmem, int slot);
 
   int createSegment (uint32_t seg_idx, uint32_t seg_size);
-  int createExternalSegment (uint32_t seg_idx, uint32_t seg_size,
-                             uint32_t seg_off, int dbuf_fd);
+  int createExternalSegment (uint32_t seg_idx, uint32_t seg_size, uint32_t seg_off, int dbuf_fd);
 
   int createWeightSegment (const Model *model);
-  int createExternalInputSegments (const Model *model,
-                                   const input_buffers *input);
-  int createExternalOutputSegments (const Model *model,
-                                    const output_buffers *output);
+  int createExternalInputSegments (const Model *model, const input_buffers *input);
+  int createExternalOutputSegments (const Model *model, const output_buffers *output);
 
   std::vector<std::unique_ptr<HWmem>> segments_; /**< segments */
 
index 9ae8522..aefad45 100644 (file)
@@ -29,8 +29,7 @@ ThreadPool::getInstance () {
 ThreadPool::ThreadPool () : stop_ (false) {
   /** create workers with the number of threads configured */
   num_threads_ = (Conf::getInstance ().getNumThreads ());
-  for (uint32_t i = 0; i < num_threads_; i++)
-    threads_.emplace_back ([this]() { this->worker (); });
+  for (uint32_t i = 0; i < num_threads_; i++) threads_.emplace_back ([this]() { this->worker (); });
 }
 
 /** @brief destructor of thread pool */
@@ -81,10 +80,9 @@ ThreadPool::enqueueTask (ThreadTask* task) {
     std::deque<std::unique_ptr<ThreadTask>>::iterator it;
     uint32_t task_id = task->getID ();
 
-    it = std::find_if (queue_.begin (), queue_.end (),
-                       [&task_id](const std::unique_ptr<ThreadTask>& t) {
-                         return t->getID () == task_id;
-                       });
+    it = std::find_if (
+        queue_.begin (), queue_.end (),
+        [&task_id](const std::unique_ptr<ThreadTask>& t) { return t->getID () == task_id; });
     /** does not allow the same ID */
     if (it != queue_.end ())
       return -EBUSY;
@@ -107,10 +105,9 @@ ThreadPool::removeTask (uint32_t task_id) {
   std::unique_lock<std::mutex> lock (m_);
   std::deque<std::unique_ptr<ThreadTask>>::iterator it;
 
-  it = std::find_if (queue_.begin (), queue_.end (),
-                     [&task_id](const std::unique_ptr<ThreadTask>& task) {
-                       return task->getID () == task_id;
-                     });
+  it = std::find_if (
+      queue_.begin (), queue_.end (),
+      [&task_id](const std::unique_ptr<ThreadTask>& task) { return task->getID () == task_id; });
   if (it == queue_.end ())
     return -EBUSY;
 
index 61ed82d..9cc9d1e 100644 (file)
@@ -60,9 +60,8 @@ class ThreadPool {
   /** the below needs a pre-acquired lock */
   bool should_stop () { return stop_; }
 
-  static std::unique_ptr<ThreadPool>
-      instance_;                    /**< thread pool singleton instance */
-  static std::once_flag once_flag_; /**< call once */
+  static std::unique_ptr<ThreadPool> instance_; /**< thread pool singleton instance */
+  static std::once_flag once_flag_;             /**< call once */
 
   std::mutex m_;               /**< mutex for sync */
   std::condition_variable cv_; /**< cond for sync */
index 5a5a8c9..cb822d4 100644 (file)
@@ -25,9 +25,7 @@ uint32_t DriverAPI::api_level_ = TRINITY_API_LEVEL;
  * @brief DriverAPI constructor
  */
 DriverAPI::DriverAPI (int dev_id)
-    : dev_id_ (dev_id),
-      dev_fd_ (-1) /* not opened yet */,
-      initialized_ (false) {}
+    : dev_id_ (dev_id), dev_fd_ (-1) /* not opened yet */, initialized_ (false) {}
 
 /**
  * @brief get number of available devices with the given type
index 141ce43..31171e8 100644 (file)
@@ -45,8 +45,7 @@ class DriverAPI {
   virtual ~DriverAPI () {}
 
   static int getNumDevices (dev_type type);
-  static std::unique_ptr<DriverAPI> createDriverAPI (dev_type type,
-                                                     int device_id);
+  static std::unique_ptr<DriverAPI> createDriverAPI (dev_type type, int device_id);
   static uint32_t getCompiledAPILevel () { return api_level_; }
   int getDeviceID () const { return dev_id_; }
   int getDeviceFD () const { return dev_fd_; }
@@ -63,25 +62,17 @@ class DriverAPI {
 
   /** The below requires initialized device */
   /** @brief check whether the device is ready (true) or busy (false) */
-  virtual device_state_t isReady () const {
-    return device_state_t::TRINITY_STATE_UNKNOWN;
-  }
+  virtual device_state_t isReady () const { return device_state_t::TRINITY_STATE_UNKNOWN; }
 
   /** @brief return a number of requests submitted */
   virtual uint32_t numRequests () const { return 0; }
 
   /** @brief allocate memory with the given size. return dmabuf fd */
-  virtual int alloc (size_t size, bool contiguous = false) const {
-    return -EPERM;
-  }
+  virtual int alloc (size_t size, bool contiguous = false) const { return -EPERM; }
   /** @brief deallocate memory with the corresponding dmabuf fd */
-  virtual int dealloc (int dmabuf, bool contiguous = false) const {
-    return -EPERM;
-  }
+  virtual int dealloc (int dmabuf, bool contiguous = false) const { return -EPERM; }
   /** @brief get memory status */
-  virtual int getMemoryStatus (size_t *alloc, size_t *free) const {
-    return -EPERM;
-  }
+  virtual int getMemoryStatus (size_t *alloc, size_t *free) const { return -EPERM; }
 
   /** @brief do mmap() for the dmabuf fd */
   virtual void *mmap (int dmabuf, size_t size) const { return nullptr; }
@@ -96,27 +87,21 @@ class DriverAPI {
   virtual int stop_target (int id) const { return -EPERM; }
 
   /** @brief register model config to the driver */
-  virtual int registerModel (model_config_t *model,
-                             uint64_t npu_version = 0) const {
+  virtual int registerModel (model_config_t *model, uint64_t npu_version = 0) const {
     return -EPERM;
   }
   virtual int deregisterModel (unsigned long long id) const { return -EPERM; }
 
 #ifdef __FPGA__
-  virtual int fpga_memcpy (int dmabuf, uint32_t offset, void *addr,
-                           size_t size) const {
+  virtual int fpga_memcpy (int dmabuf, uint32_t offset, void *addr, size_t size) const {
     return -EPERM;
   }
 #endif
 
   /** @brief get profile data for vISA instructions */
-  virtual int getProfile (int req_id, npu_profile *profile) const {
-    return -EPERM;
-  }
+  virtual int getProfile (int req_id, npu_profile *profile) const { return -EPERM; }
   virtual int getStatApps (npu_stat_apps *stat) const { return -EPERM; }
-  virtual int getStatReqs (int appid, npu_stat_reqs *stat) const {
-    return -EPERM;
-  }
+  virtual int getStatReqs (int appid, npu_stat_reqs *stat) const { return -EPERM; }
 
  protected:
   int dev_id_; /**< device id. assume that 0 <= id < getNUmDevices() */
index 8f96b7b..bc2e8c8 100644 (file)
@@ -40,8 +40,7 @@ class EmulReq {
     prof_path_ = prof_path + ".rec";
 
     setMute (true);
-    run_triv2_emul (prog, segt, metadata, cmd_path.c_str (),
-                    prof_path.c_str ());
+    run_triv2_emul (prog, segt, metadata, cmd_path.c_str (), prof_path.c_str ());
     setMute (false);
 
     delete[] segt;
@@ -72,8 +71,7 @@ class EmulReq {
 
     profile->prof_path = strdup (prof_path_.c_str ());
     if (!profile->prof_path) {
-      std::cerr << "Unable to duplicate the profile path " << prof_path_
-                << "\n";
+      std::cerr << "Unable to duplicate the profile path " << prof_path_ << "\n";
       return false;
     }
 
@@ -82,8 +80,7 @@ class EmulReq {
 
     if (head.fmt_vesion != TRIV2PROF_FMT_VER) {
       std::cerr << "Profile data format mismatch: "
-                << "(" << head.fmt_vesion << " vs. " << TRIV2PROF_FMT_VER
-                << ")\n";
+                << "(" << head.fmt_vesion << " vs. " << TRIV2PROF_FMT_VER << ")\n";
       return false;
     }
 
@@ -144,20 +141,16 @@ class EmulReq {
 
             layer->visa_opcode = 0x02;
             snprintf (layer->name, NPU_OPNAME_MAX, "%s", "ADMA_IN");
-            layer->dram_read_bytes =
-                nna_dma.src_addr_end - nna_dma.src_addr_start;
-            layer->sram_write_bytes =
-                nna_dma.dest_addr_end - nna_dma.dest_addr_start;
+            layer->dram_read_bytes = nna_dma.src_addr_end - nna_dma.src_addr_start;
+            layer->sram_write_bytes = nna_dma.dest_addr_end - nna_dma.dest_addr_start;
             break;
           case TRIV2PROF_BLOCKID_NNA_DMA_OUT:
             ifs.read ((char *) &nna_dma, sizeof (T2PF_DUMP_DMA));
 
             layer->visa_opcode = 0x03;
             snprintf (layer->name, NPU_OPNAME_MAX, "%s", "ADMA_OUT");
-            layer->dram_write_bytes =
-                nna_dma.dest_addr_end - nna_dma.dest_addr_start;
-            layer->sram_read_bytes =
-                nna_dma.src_addr_end - nna_dma.src_addr_start;
+            layer->dram_write_bytes = nna_dma.dest_addr_end - nna_dma.dest_addr_start;
+            layer->sram_read_bytes = nna_dma.src_addr_end - nna_dma.src_addr_start;
             break;
           case TRIV2PROF_BLOCKID_DSP:
             ifs.read ((char *) &dsp, sizeof (T2PF_DUMP_DSP));
@@ -170,24 +163,19 @@ class EmulReq {
 
             layer->visa_opcode = 0x40;
             snprintf (layer->name, NPU_OPNAME_MAX, "%s", "PDMA_IN");
-            layer->dram_read_bytes =
-                dsp_dma.src_addr_end - dsp_dma.src_addr_start;
-            layer->sram_write_bytes =
-                dsp_dma.dest_addr_end - dsp_dma.dest_addr_start;
+            layer->dram_read_bytes = dsp_dma.src_addr_end - dsp_dma.src_addr_start;
+            layer->sram_write_bytes = dsp_dma.dest_addr_end - dsp_dma.dest_addr_start;
             break;
           case TRIV2PROF_BLOCKID_DSP_DMA_OUT:
             ifs.read ((char *) &dsp_dma, sizeof (T2PF_DUMP_DMA));
 
             layer->visa_opcode = 0x41;
             snprintf (layer->name, NPU_OPNAME_MAX, "%s", "PDMA_OUT");
-            layer->dram_write_bytes =
-                dsp_dma.dest_addr_end - dsp_dma.dest_addr_start;
-            layer->sram_read_bytes =
-                dsp_dma.src_addr_end - dsp_dma.src_addr_start;
+            layer->dram_write_bytes = dsp_dma.dest_addr_end - dsp_dma.dest_addr_start;
+            layer->sram_read_bytes = dsp_dma.src_addr_end - dsp_dma.src_addr_start;
             break;
           default:
-            std::cerr << "Unknown block id detected: " << common.block_id
-                      << std::endl;
+            std::cerr << "Unknown block id detected: " << common.block_id << std::endl;
             delete[] profile->layers;
             profile->layers = nullptr;
             ifs.close ();
@@ -253,13 +241,9 @@ class EmulElement {
   void *getAddr () const { return addr_; }
   size_t getSize () const { return size_; }
 
-  void setModelConfig (model_config_t *model) {
-    model_config_map_.insert (model->id, model);
-  }
+  void setModelConfig (model_config_t *model) { model_config_map_.insert (model->id, model); }
 
-  model_config_t *getModelConfig (uint64_t id) {
-    return model_config_map_.find (id);
-  }
+  model_config_t *getModelConfig (uint64_t id) { return model_config_map_.find (id); }
 
   void unsetModelConfig (uint64_t id) { model_config_map_.remove (id); }
 
@@ -318,8 +302,7 @@ static std::mutex global_lock;
  * @brief constructor of emulation API driver
  * @param[in] dev_id device id. device id is used to emulate device fd
  */
-TrinityEmulAPI::TrinityEmulAPI (int dev_id, dev_type type)
-    : DriverAPI (dev_id), dev_type_ (type) {
+TrinityEmulAPI::TrinityEmulAPI (int dev_id, dev_type type) : DriverAPI (dev_id), dev_type_ (type) {
   prefix_share_ = Conf::getInstance ().getPrefixShare ();
   prefix_profile_ = Conf::getInstance ().getPrefixProfile ();
 }
@@ -463,8 +446,7 @@ TrinityEmulAPI::dealloc (int dmabuf, bool contiguous) const {
  * @return 0 if no error. otherwise a negatice error value
  */
 int
-TrinityEmulAPI::getMemoryStatus (size_t *alloc_total,
-                                 size_t *free_total) const {
+TrinityEmulAPI::getMemoryStatus (size_t *alloc_total, size_t *free_total) const {
   if (!initialized ())
     return -EPERM;
 
@@ -525,8 +507,7 @@ TrinityEmulAPI::munmap (void *addr, size_t size) const {
  * @return 0 if no error. otherwise a negative errno
  */
 int
-TrinityEmulAPI::registerModel (model_config_t *model_config,
-                               uint64_t npu_version) const {
+TrinityEmulAPI::registerModel (model_config_t *model_config, uint64_t npu_version) const {
   static std::atomic<uint64_t> global_internal_id (0);
 
   if (!initialized ())
@@ -637,12 +618,12 @@ TrinityEmulAPI::runInput (input_config_t *input_config) const {
     char **segment_table = new char *[num_segs];
     bool is_kernel = false;
 
+    /* Reconstruct the segment table for libmrpsim */
     for (uint32_t i = 0; i < num_segs; i++) {
       int32_t dmabuf = reinterpret_cast<int32_t *> (addr_input)[i];
-      uint32_t offset = reinterpret_cast<uint32_t *> (
-          addr_input + elem_input->getSize () / 2)[i];
+      uint32_t offset = reinterpret_cast<uint32_t *> (addr_input + elem_input->getSize () / 2)[i];
 
-      /** Check it's a kernel request */
+      /* Check it's a kernel request */
       if (input_config->input_mode != TRINITY_INPUT_HW) {
         EmulElement *elem = elem_map_.find (dmabuf);
         if (elem == nullptr) {
@@ -650,7 +631,7 @@ TrinityEmulAPI::runInput (input_config_t *input_config) const {
           return -EINVAL;
         }
 
-        /** Here, set virtual address for emulations */
+        /* Here, set virtual address for emulations */
         segment_table[i] = static_cast<char *> (elem->getAddr ()) + offset;
       } else {
         is_kernel = true;
@@ -658,13 +639,6 @@ TrinityEmulAPI::runInput (input_config_t *input_config) const {
       }
     }
 
-    std::string cmd_path (prefix_share_);
-
-    if (elem_model->getNpuTops () == 2)
-      cmd_path += "/mRPsim/triv2_2tops.cmd";
-    else
-      cmd_path += "/mRPsim/triv2.cmd";
-
     int req_id = input_config->req_id;
     EmulReq *req = req_map_.find (req_id);
     if (req != nullptr)
@@ -678,16 +652,23 @@ TrinityEmulAPI::runInput (input_config_t *input_config) const {
       return status;
     }
 
-    std::string prof_path (prefix_profile_);
-
-    prof_path += "/ne_profile." + std::to_string (req_id);
+    if (is_kernel) {
+      /* skip execution of kernel requests */
+      delete[] segment_table;
+    } else {
+      std::string cmd_path (prefix_share_);
+      if (elem_model->getNpuTops () == 2)
+        cmd_path += "/mRPsim/triv2_2tops.cmd";
+      else
+        cmd_path += "/mRPsim/triv2.cmd";
 
-    auto func = std::bind (&EmulReq::run_emul, req, prog, segment_table,
-                           static_cast<char *> (elem_metadata->getAddr ()),
-                           cmd_path, prof_path);
+      std::string prof_path (prefix_profile_);
+      prof_path += "/ne_profile." + std::to_string (req_id);
 
-    if (!is_kernel)
+      auto func = std::bind (&EmulReq::run_emul, req, prog, segment_table,
+                             static_cast<char *> (elem_metadata->getAddr ()), cmd_path, prof_path);
       req->run (func);
+    }
   }
 
   return 0;
index 81de78d..9d4780c 100644 (file)
@@ -69,8 +69,7 @@ ThreadSafeMap<int, CuseElement> TrinityVision2API::cuse_map;
  * @brief constructor of the API instance for Trinity Vision driver
  * @param[in] dev_id device id
  */
-TrinityVision2API::TrinityVision2API (int dev_id)
-    : DriverAPI (dev_id), is_cuse_ (false) {
+TrinityVision2API::TrinityVision2API (int dev_id) : DriverAPI (dev_id), is_cuse_ (false) {
   int num_devs;
 
   if (dev_id > max_num_devs) {
@@ -109,8 +108,7 @@ TrinityVision2API::open () {
     return -ENODEV;
   }
 
-  path = "/dev/" + TrinityVision2API::dev_node_base + "-" +
-         std::to_string (dev_id_);
+  path = "/dev/" + TrinityVision2API::dev_node_base + "-" + std::to_string (dev_id_);
   fd = ::open (path.c_str (), O_RDWR);
   if (fd < 0) {
     logerr (TAG, "Unable to find device node: %s\n", path.c_str ());
@@ -124,8 +122,8 @@ int
 TrinityVision2API::checkSanity () {
   int lib_ver = trinity_gen_ver (0, VER_NE_MAJOR, VER_NE_MINOR, VER_NE_EXTRA);
   int min_ver = this->getDrvVersion ();
-  enum trinity_dev_type type = static_cast<enum trinity_dev_type> (
-      (min_ver & TRINITY_MASK_DEV) >> TRINITY_SHIFT_DEV);
+  enum trinity_dev_type type =
+      static_cast<enum trinity_dev_type> ((min_ver & TRINITY_MASK_DEV) >> TRINITY_SHIFT_DEV);
 
   /* Check if this device is a TRIV2-compatible one */
   if (type != TRINITY_DEV_VISION2 && type != TRINITY_DEV_VISION2_CUSE) {
@@ -139,8 +137,7 @@ TrinityVision2API::checkSanity () {
 
   min_ver &= ~TRINITY_MASK_DEV;
   /* Check if the major version numbers are same */
-  if ((lib_ver & TRINITY_MASK_MAJOR_VER) !=
-      (min_ver & TRINITY_MASK_MAJOR_VER)) {
+  if ((lib_ver & TRINITY_MASK_MAJOR_VER) != (min_ver & TRINITY_MASK_MAJOR_VER)) {
     logerr (TAG, "Version mismatch between driver and library\n");
     return -ENOTSUP;
   }
@@ -168,8 +165,7 @@ TrinityVision2API::getNumDevices () {
   path.clear ();
 
   for (int i = 0; i < max_num_devs; ++i) {
-    path =
-        "/dev/" + TrinityVision2API::dev_node_base + "-" + std::to_string (i);
+    path = "/dev/" + TrinityVision2API::dev_node_base + "-" + std::to_string (i);
     ret = stat (path.c_str (), &sb);
     if (ret == 0 && S_ISCHR (sb.st_mode)) {
       cnt++;
@@ -215,8 +211,7 @@ TrinityVision2API::numRequests () const {
     if (ret == 0) {
       uint32_t num_requests = 0;
 
-      for (uint32_t i = 0; i < stat.num_apps; i++)
-        num_requests += stat.stat[i].num_active_reqs;
+      for (uint32_t i = 0; i < stat.num_apps; i++) num_requests += stat.stat[i].num_active_reqs;
 
       return num_requests;
     }
@@ -262,8 +257,7 @@ TrinityVision2API::alloc (size_t size, bool contiguous) const {
   struct stat statbuf;
 
   /* Let's use shared memory for emulated dmabuf */
-  shm_name =
-      "/triv2_" + std::to_string (getpid ()) + "_" + std::to_string (dbuf_fd);
+  shm_name = "/triv2_" + std::to_string (getpid ()) + "_" + std::to_string (dbuf_fd);
   ret = shm_open (shm_name.c_str (), O_RDWR, 0666);
   if (ret < 0)
     return ret;
@@ -334,8 +328,7 @@ TrinityVision2API::dealloc (int dmabuf, bool contiguous) const {
  * @return 0 if no error. otherwise a negatice error value
  */
 int
-TrinityVision2API::getMemoryStatus (size_t *alloc_total,
-                                    size_t *free_total) const {
+TrinityVision2API::getMemoryStatus (size_t *alloc_total, size_t *free_total) const {
   struct trinity_ioctl_stat_app stat;
   int ret;
 
@@ -416,8 +409,7 @@ TrinityVision2API::munmap (void *addr, size_t size) const {
  * @return 0 if no error. otherwise a negative errno
  */
 int
-TrinityVision2API::registerModel (model_config_t *model_config,
-                                  uint64_t npu_version) const {
+TrinityVision2API::registerModel (model_config_t *model_config, uint64_t npu_version) const {
   uint32_t model_tops;
   uint32_t device_tops;
   int ret;
@@ -461,8 +453,7 @@ TrinityVision2API::registerModel (model_config_t *model_config,
     model_config->metadata_dbuf_fd = meta->getDbufFD ();
   }
 
-  ret =
-      ioctl (this->getDeviceFD (), TRINITY_IOCTL_REGISTER_MODEL, model_config);
+  ret = ioctl (this->getDeviceFD (), TRINITY_IOCTL_REGISTER_MODEL, model_config);
 
   /* rollback FDs to prevent any side-effects */
   if (is_cuse_) {
@@ -609,8 +600,7 @@ TrinityVision2API::getDrvVersion () const {
 
 #ifdef __FPGA__
 int
-TrinityVision2API::fpga_memcpy (int dmabuf, uint32_t offset, void *addr,
-                                size_t size) const {
+TrinityVision2API::fpga_memcpy (int dmabuf, uint32_t offset, void *addr, size_t size) const {
   struct trinity_ioctl_fpga_memcpy fpga;
   int ret;
 
index 94304bc..1c1cc98 100644 (file)
@@ -86,8 +86,7 @@ Conf::loadConf (const char *inipath) {
   iniparser_set_error_callback (error_callback);
 
   /** Load up config from ini if available */
-  dictionary *ini =
-      iniparser_load (inipath != nullptr ? inipath : default_ini_path);
+  dictionary *ini = iniparser_load (inipath != nullptr ? inipath : default_ini_path);
   if (ini) {
     loadConfIni (ini);
     iniparser_freedict (ini);
@@ -222,14 +221,10 @@ Conf::setNumThreads (const char *num_threads) {
 */
 void
 Conf::loadConfIni (dictionary *ini) {
-  const char *resv_mem_size =
-      iniparser_getstring (ini, "main:resv_mem_size", nullptr);
-  const char *num_threads =
-      iniparser_getstring (ini, "main:num_threads", nullptr);
-  const char *prefix_share =
-      iniparser_getstring (ini, "main:prefix_share", nullptr);
-  const char *prefix_profile =
-      iniparser_getstring (ini, "main:prefix_profile", nullptr);
+  const char *resv_mem_size = iniparser_getstring (ini, "main:resv_mem_size", nullptr);
+  const char *num_threads = iniparser_getstring (ini, "main:num_threads", nullptr);
+  const char *prefix_share = iniparser_getstring (ini, "main:prefix_share", nullptr);
+  const char *prefix_profile = iniparser_getstring (ini, "main:prefix_profile", nullptr);
 
   const char *log_dir = iniparser_getstring (ini, "debug:log_dir", nullptr);
   const char *log_level = iniparser_getstring (ini, "debug:log_level", nullptr);
index 9b73bd9..e3cb659 100644 (file)
@@ -38,14 +38,12 @@ static const char *loglevelstr[NPU_LOG_END] = {
  * @brief Module Name String in 8 characters
  */
 static const char *modulestr[_NEND] = {
-    [_N1] = "N1/CommPl",  [_N11] = "N11/IP   ", [_N2] = "N2/Handlr",
-    [_N21] = "N21/Host ", [_N3] = "N3/Sched ",  [_N4] = "N4/InputC",
-    [_N41] = "N41/HWrec", [_N42] = "N42/Host ", [_N5] = "N5/ThPool",
-    [_N6] = "N6/Mem   ",  [_N61] = "N61/MemDe", [_N62] = "N62/MemPl",
-    [_N7] = "N7/HWmem ",  [_N71] = "N71/Model", [_N72] = "N72/Buff ",
-    [_N73] = "N72/Segt ", [_N8] = "N8/HWmemI",  [_N9] = "N9/NPUdrv",
-    [_N91] = "N91/TRIV ", [_N92] = "N92/TRIV2", [_N93] = "N93/TRIA ",
-    [_N94] = "N94/Emul ",
+    [_N1] = "N1/CommPl",  [_N11] = "N11/IP   ", [_N2] = "N2/Handlr",  [_N21] = "N21/Host ",
+    [_N3] = "N3/Sched ",  [_N4] = "N4/InputC",  [_N41] = "N41/HWrec", [_N42] = "N42/Host ",
+    [_N5] = "N5/ThPool",  [_N6] = "N6/Mem   ",  [_N61] = "N61/MemDe", [_N62] = "N62/MemPl",
+    [_N7] = "N7/HWmem ",  [_N71] = "N71/Model", [_N72] = "N72/Buff ", [_N73] = "N72/Segt ",
+    [_N8] = "N8/HWmemI",  [_N9] = "N9/NPUdrv",  [_N91] = "N91/TRIV ", [_N92] = "N92/TRIV2",
+    [_N93] = "N93/TRIA ", [_N94] = "N94/Emul ",
 };
 
 /** @brief singleton instance */
@@ -95,8 +93,7 @@ Logger::logwrite (npu_loglevel l, module m, const char *format, ...) {
 }
 
 int
-Logger::logwrite_args (npu_loglevel l, const char *tag, const char *format,
-                       va_list args) {
+Logger::logwrite_args (npu_loglevel l, const char *tag, const char *format, va_list args) {
   std::unique_lock<std::mutex> lock (m_);
 
   time_t ltime = time (nullptr);
@@ -111,8 +108,7 @@ Logger::logwrite_args (npu_loglevel l, const char *tag, const char *format,
   time_str[strcspn (time_str, "\n")] = '\x00';
 
   char log_msg[MAX_LOG_MSG];
-  int log_len = snprintf (log_msg, MAX_LOG_MSG, "[%s][%s][%s] ", loglevelstr[l],
-                          tag, time_str);
+  int log_len = snprintf (log_msg, MAX_LOG_MSG, "[%s][%s][%s] ", loglevelstr[l], tag, time_str);
 
   log_len += vsnprintf (log_msg + log_len, MAX_LOG_MSG - log_len, format, args);
 
@@ -133,8 +129,7 @@ Logger::logwrite_args (npu_loglevel l, const char *tag, const char *format,
   if (fp_ == nullptr) {
     char filename[FILENAME_MAX];
 
-    snprintf (filename, FILENAME_MAX, "%s/%s",
-              Conf::getInstance ().getLogDir (), LOG_FILENAME);
+    snprintf (filename, FILENAME_MAX, "%s/%s", Conf::getInstance ().getLogDir (), LOG_FILENAME);
     fp_ = fopen (filename, "a");
     if (fp_ == nullptr)
       return -errno;
index 3debf04..6b77fb3 100644 (file)
@@ -92,8 +92,7 @@ class Logger {
   static Logger &getInstance ();
 
   int logwrite (npu_loglevel l, module m, const char *format, ...);
-  int logwrite_args (npu_loglevel l, const char *tag, const char *format,
-                     va_list args);
+  int logwrite_args (npu_loglevel l, const char *tag, const char *format, va_list args);
 
   ~Logger ();
 
@@ -108,17 +107,16 @@ class Logger {
 };
 
 /** @brief log macros with different log levels */
-#define __FILENAME__ \
-  (strrchr (__FILE__, '/') ? strrchr (__FILE__, '/') + 1 : __FILE__)
-#define logerr(m, fmt, ...)                                          \
-  Logger::getInstance ().logwrite (NPU_LOG_ERROR, m, "(%s:%d) " fmt, \
-                                   __FILENAME__, __LINE__, ##__VA_ARGS__)
-#define logwarn(m, fmt, ...)                                        \
-  Logger::getInstance ().logwrite (NPU_LOG_WARN, m, "(%s:%d) " fmt, \
-                                   __FILENAME__, __LINE__, ##__VA_ARGS__)
-#define loginfo(m, fmt, ...)                                        \
-  Logger::getInstance ().logwrite (NPU_LOG_INFO, m, "(%s:%d) " fmt, \
-                                   __FILENAME__, __LINE__, ##__VA_ARGS__)
+#define __FILENAME__ (strrchr (__FILE__, '/') ? strrchr (__FILE__, '/') + 1 : __FILE__)
+#define logerr(m, fmt, ...)                                                                  \
+  Logger::getInstance ().logwrite (NPU_LOG_ERROR, m, "(%s:%d) " fmt, __FILENAME__, __LINE__, \
+                                   ##__VA_ARGS__)
+#define logwarn(m, fmt, ...)                                                                \
+  Logger::getInstance ().logwrite (NPU_LOG_WARN, m, "(%s:%d) " fmt, __FILENAME__, __LINE__, \
+                                   ##__VA_ARGS__)
+#define loginfo(m, fmt, ...)                                                                \
+  Logger::getInstance ().logwrite (NPU_LOG_INFO, m, "(%s:%d) " fmt, __FILENAME__, __LINE__, \
+                                   ##__VA_ARGS__)
 
 /** @brief thread-safe map */
 template <typename K, typename V>
@@ -148,8 +146,7 @@ class ThreadSafeMap {
   /** @brief insert element to the map */
   int insert (K key, V *value) {
     std::unique_lock<std::mutex> lock (m_);
-    auto status =
-        map_.insert (std::make_pair (key, std::unique_ptr<V> (value)));
+    auto status = map_.insert (std::make_pair (key, std::unique_ptr<V> (value)));
 
     if (status.second == false)
       return -EINVAL;
index 9188c9e..e46364e 100644 (file)
@@ -203,8 +203,7 @@ getNPU_profile (npudev_h dev, int req_id, npu_profile *profile) {
  * @note Internal data of npu_profile is valid until putNPU_profile is called
  */
 int
-getNPU_profile_opt (npudev_h dev, int req_id, const npu_profile_opt opt,
-                    npu_profile *profile) {
+getNPU_profile_opt (npudev_h dev, int req_id, const npu_profile_opt opt, npu_profile *profile) {
   INIT_HOST_HANDLER (host_handler, dev);
 
   return host_handler->getProfile (req_id, opt, profile);
@@ -375,8 +374,8 @@ unregisterNPUmodel_all (npudev_h dev) {
  * @return 0 if no error. otherwise a negative error value
  */
 int
-getNPUmodel_tensorSize (npudev_h dev, uint32_t model_id, bool input,
-                        uint32_t index, uint32_t *size) {
+getNPUmodel_tensorSize (npudev_h dev, uint32_t model_id, bool input, uint32_t index,
+                        uint32_t *size) {
   INIT_HOST_HANDLER (host_handler, dev);
 
   return host_handler->getTensorSize (model_id, input, index, size);
@@ -428,9 +427,8 @@ setNPU_constraint (npudev_h dev, uint32_t modelid, npuConstraint constraint) {
  *       to avoid unnecessary memcpy. Make sure that they have 'BUFFER_DMABUF' types.
  */
 int
-runNPU_model (npudev_h dev, uint32_t modelid, npu_infer_mode mode,
-              const input_buffers *input, output_buffers *output,
-              npuOutputNotify cb, void *data) {
+runNPU_model (npudev_h dev, uint32_t modelid, npu_infer_mode mode, const input_buffers *input,
+              output_buffers *output, npuOutputNotify cb, void *data) {
   INIT_HOST_HANDLER (host_handler, dev);
 
   return host_handler->runModel (modelid, mode, input, output, cb, data);
@@ -449,12 +447,10 @@ runNPU_model (npudev_h dev, uint32_t modelid, npu_infer_mode mode,
  * @detail There is a memcpy for the output buffer.
  */
 int
-runNPU_sync (npudev_h dev, uint32_t modelid, const input_buffers *input,
-             output_buffers *output) {
+runNPU_sync (npudev_h dev, uint32_t modelid, const input_buffers *input, output_buffers *output) {
   /* runNPU_sync() assumes that output_buffers is filled by npu-engine */
   memset (output, '\x00', sizeof (output_buffers));
-  return runNPU_model (dev, modelid, NPU_INFER_BLOCKING, input, output, nullptr,
-                       nullptr);
+  return runNPU_model (dev, modelid, NPU_INFER_BLOCKING, input, output, nullptr, nullptr);
 }
 
 /**
@@ -473,11 +469,9 @@ runNPU_sync (npudev_h dev, uint32_t modelid, const input_buffers *input,
  * @detail There is a memcpy for the output buffer.
  */
 int
-runNPU_async (npudev_h dev, uint32_t modelid, const input_buffers *input,
-              npuOutputNotify cb, uint64_t *sequence, void *data,
-              npu_async_mode mode) {
-  return runNPU_model (dev, modelid, NPU_INFER_NON_BLOCKING, input, nullptr, cb,
-                       data);
+runNPU_async (npudev_h dev, uint32_t modelid, const input_buffers *input, npuOutputNotify cb,
+              uint64_t *sequence, void *data, npu_async_mode mode) {
+  return runNPU_model (dev, modelid, NPU_INFER_NON_BLOCKING, input, nullptr, cb, data);
 }
 
 /**
@@ -776,13 +770,11 @@ getNPU_requestModel (npudev_h dev, int req_id, uint32_t *model_id) {
  *       internally (e.g., NHWC <-> TRIV2).
  */
 int
-setNPU_requestData (npudev_h dev, int req_id, input_buffers *input,
-                    tensors_data_info *in_info, output_buffers *output,
-                    tensors_data_info *out_info) {
+setNPU_requestData (npudev_h dev, int req_id, input_buffers *input, tensors_data_info *in_info,
+                    output_buffers *output, tensors_data_info *out_info) {
   INIT_HOST_HANDLER (host_handler, dev);
 
-  return host_handler->setRequestData (req_id, input, in_info, output,
-                                       out_info);
+  return host_handler->setRequestData (req_id, input, in_info, output, out_info);
 }
 
 /**
@@ -794,8 +786,7 @@ setNPU_requestData (npudev_h dev, int req_id, input_buffers *input,
  * @return 0 if no error. Otherwise a negative errno
  */
 int
-setNPU_requestCallback (npudev_h dev, int req_id, npuOutputNotify cb,
-                        void *data) {
+setNPU_requestCallback (npudev_h dev, int req_id, npuOutputNotify cb, void *data) {
   INIT_HOST_HANDLER (host_handler, dev);
 
   return host_handler->setRequestCallback (req_id, cb, data);
index 929b000..97ba038 100644 (file)
@@ -65,8 +65,7 @@ class TesterTRIV2 {
       return status;
 
     for (uint32_t i = 0; i < repeat_; i++) {
-      status = runNPU_async (dev_, model_id_, &input_, callback, NULL, this,
-                             NPUASYNC_WAIT);
+      status = runNPU_async (dev_, model_id_, &input_, callback, NULL, this, NPUASYNC_WAIT);
       if (status < 0)
         return status;
     }
@@ -105,8 +104,7 @@ class TesterTRIV2 {
 
     /** TRIV2 requires segment table */
     meta.segment_num = 3;
-    for (uint32_t idx = 0; idx < meta.segment_num; idx++)
-      meta.segment_size[idx] = segment_size;
+    for (uint32_t idx = 0; idx < meta.segment_num; idx++) meta.segment_size[idx] = segment_size;
 
     meta.weight_seg_idx = 0;
 
index d132159..05274a0 100644 (file)
@@ -85,8 +85,7 @@ class TesterTRIV2 {
 
     /** TRIV2 requires segment table */
     meta.segment_num = 3;
-    for (uint32_t idx = 0; idx < meta.segment_num; idx++)
-      meta.segment_size[idx] = segment_size;
+    for (uint32_t idx = 0; idx < meta.segment_num; idx++) meta.segment_size[idx] = segment_size;
 
     meta.weight_seg_idx = 0;
 
index e9d7054..3b46703 100644 (file)
@@ -41,8 +41,7 @@ class Tester : public UtilTRIV2 {
       return status;
     }
 
-    return UtilTRIV2::loadModel (model_dir, &model_id_, NPU_PRIORITY_MID,
-                                 NPU_TIMEOUT_MS);
+    return UtilTRIV2::loadModel (model_dir, &model_id_, NPU_PRIORITY_MID, NPU_TIMEOUT_MS);
   }
 
   /** @brief run the inference */
index 5a41e5b..9907756 100644 (file)
@@ -61,8 +61,7 @@ class Tester : public UtilTRIV2 {
       return;
 
     if (alloc_total != free_total)
-      cerr << "Possible memory leak..? (" << alloc_total << " vs. "
-           << free_total << ")\n";
+      cerr << "Possible memory leak..? (" << alloc_total << " vs. " << free_total << ")\n";
   }
 
   /** @brief configure testing mode */
@@ -99,8 +98,7 @@ class Tester : public UtilTRIV2 {
       for (uint32_t i = 0; i < num_iter_; i++) {
         PRINT_STATUS_ITERS (i, num_iter_);
 
-        status = UtilTRIV2::loadModel (model_dir_, &model_id, NPU_PRIORITY_MID,
-                                       NPU_TIMEOUT_MS);
+        status = UtilTRIV2::loadModel (model_dir_, &model_id, NPU_PRIORITY_MID, NPU_TIMEOUT_MS);
         if (status != 0)
           return status;
 
@@ -114,8 +112,7 @@ class Tester : public UtilTRIV2 {
       status = test_ret_success;
     } else if (mode_ == AGING_TEST_INFERENCE) {
       /* repeat model_inference only */
-      status = UtilTRIV2::loadModel (model_dir_, &model_id, NPU_PRIORITY_MID,
-                                     NPU_TIMEOUT_MS);
+      status = UtilTRIV2::loadModel (model_dir_, &model_id, NPU_PRIORITY_MID, NPU_TIMEOUT_MS);
       if (status != 0)
         return status;
 
@@ -146,8 +143,7 @@ class Tester : public UtilTRIV2 {
       for (uint32_t i = 0; i < num_iter_; i++) {
         PRINT_STATUS_ITERS (i, num_iter_);
 
-        status = UtilTRIV2::loadModel (model_dir_, &model_id, NPU_PRIORITY_MID,
-                                       NPU_TIMEOUT_MS);
+        status = UtilTRIV2::loadModel (model_dir_, &model_id, NPU_PRIORITY_MID, NPU_TIMEOUT_MS);
         if (status != 0)
           return status;
 
@@ -187,8 +183,7 @@ class Tester : public UtilTRIV2 {
           return status;
         }
 
-        status = UtilTRIV2::loadModel (model_dir_, &model_id, NPU_PRIORITY_MID,
-                                       NPU_TIMEOUT_MS);
+        status = UtilTRIV2::loadModel (model_dir_, &model_id, NPU_PRIORITY_MID, NPU_TIMEOUT_MS);
         if (status != 0)
           return status;
 
index 469e24f..b56aa98 100644 (file)
@@ -45,8 +45,7 @@ class Tester : public UtilTRIV2 {
       return status;
     }
 
-    return UtilTRIV2::loadModel (model_dir, &model_id_, NPU_PRIORITY_MID,
-                                 NPU_TIMEOUT_MS);
+    return UtilTRIV2::loadModel (model_dir, &model_id_, NPU_PRIORITY_MID, NPU_TIMEOUT_MS);
   }
 
   /** @brief run the inference */
index 2bb2693..8dd4a8e 100644 (file)
@@ -26,8 +26,7 @@
 /** @brief c++ class to describe how to use npu-engine library */
 class TesterTRIV2 {
  public:
-  TesterTRIV2 ()
-      : dev_ (nullptr), dev_tmp_ (nullptr), meta_ (nullptr), model_id_ (0) {
+  TesterTRIV2 () : dev_ (nullptr), dev_tmp_ (nullptr), meta_ (nullptr), model_id_ (0) {
     memset (&input_, '\x00', sizeof (input_buffers));
     memset (&input_tmp_, '\x00', sizeof (input_buffers));
   }
@@ -146,8 +145,7 @@ class TesterTRIV2 {
       size_t size = ifs.tellg ();
 
       ifs.seekg (0);
-      ifs.read (static_cast<char *> (input_tmp_.bufs[idx].addr) + input_seg_off,
-                size);
+      ifs.read (static_cast<char *> (input_tmp_.bufs[idx].addr) + input_seg_off, size);
       ifs.close ();
 
       input_.bufs[idx].type = BUFFER_DMABUF;
index e1e2a24..48df154 100644 (file)
@@ -79,8 +79,8 @@ main (int argc, char **argv) {
     }
 
     for (int j = 0; j < num_models; j++) {
-      status = testers[j].loadModel (model_paths[j].c_str (), &model_ids[j],
-                                     NPU_PRIORITY_MID, NPU_TIMEOUT_MS);
+      status = testers[j].loadModel (model_paths[j].c_str (), &model_ids[j], NPU_PRIORITY_MID,
+                                     NPU_TIMEOUT_MS);
       if (status != 0) {
         cerr << "Unable to load model\n";
         is_error = true;
index 4abf0a6..807c1a9 100644 (file)
@@ -32,17 +32,15 @@ class Tester : public UtilTRIV2 {
       return status;
     }
 
-    status =
-        UtilTRIV2::loadModel (models_dir + "/" + MID_MODEL_NAME, &mid_model_id_,
-                              NPU_PRIORITY_MID, NPU_TIMEOUT_MS);
+    status = UtilTRIV2::loadModel (models_dir + "/" + MID_MODEL_NAME, &mid_model_id_,
+                                   NPU_PRIORITY_MID, NPU_TIMEOUT_MS);
     if (status != test_ret_success) {
       cerr << "Failed to find a model: " << MID_MODEL_NAME << "\n";
       return status;
     }
 
-    status = UtilTRIV2::loadModel (models_dir + "/" + HIGH_MODEL_NAME,
-                                   &high_model_id_, NPU_PRIORITY_HIGH,
-                                   NPU_TIMEOUT_MS);
+    status = UtilTRIV2::loadModel (models_dir + "/" + HIGH_MODEL_NAME, &high_model_id_,
+                                   NPU_PRIORITY_HIGH, NPU_TIMEOUT_MS);
     if (status != test_ret_success) {
       cerr << "Failed to find a model: " << HIGH_MODEL_NAME << "\n";
       return status;
index e81ee64..64ad15e 100644 (file)
@@ -30,8 +30,7 @@ class Tester : public UtilTRIV2 {
       return status;
     }
 
-    return UtilTRIV2::loadModel (model_dir, &model_id_, NPU_PRIORITY_MID,
-                                 NPU_TIMEOUT_MS);
+    return UtilTRIV2::loadModel (model_dir, &model_id_, NPU_PRIORITY_MID, NPU_TIMEOUT_MS);
   }
 
   /** @brief run the inference */
@@ -59,39 +58,30 @@ class Tester : public UtilTRIV2 {
         cerr << "Profile Path : " << profile.prof_path << "\n";
       cerr << "Total System Cycles : " << profile.total_system_cycles << "\n";
       if (profile.dram_input_footprint > 0)
-        cerr << "DRAM Input Footprint (KB) : "
-             << (profile.dram_input_footprint >> 10) << "\n";
+        cerr << "DRAM Input Footprint (KB) : " << (profile.dram_input_footprint >> 10) << "\n";
       if (profile.dram_output_footprint > 0)
-        cerr << "DRAM Output Footprint (KB) : "
-             << (profile.dram_output_footprint >> 10) << "\n";
+        cerr << "DRAM Output Footprint (KB) : " << (profile.dram_output_footprint >> 10) << "\n";
 
       if (profile.layers != nullptr) {
         cerr << "\n";
         for (uint32_t i = 0; i < profile.num_layers; i++) {
           cerr << "[" << i << "] " << profile.layers[i].name << "\n";
           if (profile.layers[i].running_cycles > 0)
-            cerr << "\tRunning Cycles  : " << profile.layers[i].running_cycles
-                 << "\n";
+            cerr << "\tRunning Cycles  : " << profile.layers[i].running_cycles << "\n";
           if (profile.layers[i].start_cycles > 0)
-            cerr << "\tStart Cycles  : " << profile.layers[i].start_cycles
-                 << "\n";
+            cerr << "\tStart Cycles  : " << profile.layers[i].start_cycles << "\n";
           if (profile.layers[i].end_cycles > 0)
             cerr << "\tEnd Cycles  : " << profile.layers[i].end_cycles << "\n";
           if (profile.layers[i].dram_read_bytes > 0)
-            cerr << "\tDRAM Read  (KB) : "
-                 << (profile.layers[i].dram_read_bytes >> 10) << "\n";
+            cerr << "\tDRAM Read  (KB) : " << (profile.layers[i].dram_read_bytes >> 10) << "\n";
           if (profile.layers[i].dram_write_bytes > 0)
-            cerr << "\tDRAM Write (KB) : "
-                 << (profile.layers[i].dram_write_bytes >> 10) << "\n";
+            cerr << "\tDRAM Write (KB) : " << (profile.layers[i].dram_write_bytes >> 10) << "\n";
           if (profile.layers[i].sram_read_bytes > 0)
-            cerr << "\tSRAM Read  (KB) : "
-                 << (profile.layers[i].sram_read_bytes >> 10) << "\n";
+            cerr << "\tSRAM Read  (KB) : " << (profile.layers[i].sram_read_bytes >> 10) << "\n";
           if (profile.layers[i].sram_write_bytes > 0)
-            cerr << "\tSRAM Write (KB) : "
-                 << (profile.layers[i].sram_write_bytes >> 10) << "\n";
+            cerr << "\tSRAM Write (KB) : " << (profile.layers[i].sram_write_bytes >> 10) << "\n";
           if (profile.layers[i].visa_exec_seq > 0)
-            cerr << "\tvISA Exec Seq   : " << profile.layers[i].visa_exec_seq
-                 << "\n";
+            cerr << "\tvISA Exec Seq   : " << profile.layers[i].visa_exec_seq << "\n";
         }
       }
 
index 3cf9f9c..c44e89f 100644 (file)
@@ -69,39 +69,30 @@ class Tester {
       cerr << "Profile Path : " << profile.prof_path << "\n";
     cerr << "Total System Cycles : " << profile.total_system_cycles << "\n";
     if (profile.dram_input_footprint > 0)
-      cerr << "DRAM Input Footprint (KB) : "
-           << (profile.dram_input_footprint >> 10) << "\n";
+      cerr << "DRAM Input Footprint (KB) : " << (profile.dram_input_footprint >> 10) << "\n";
     if (profile.dram_output_footprint > 0)
-      cerr << "DRAM Output Footprint (KB) : "
-           << (profile.dram_output_footprint >> 10) << "\n";
+      cerr << "DRAM Output Footprint (KB) : " << (profile.dram_output_footprint >> 10) << "\n";
 
     if (profile.layers != nullptr) {
       cerr << "\n";
       for (uint32_t i = 0; i < profile.num_layers; i++) {
         cerr << "[" << i << "] " << profile.layers[i].name << "\n";
         if (profile.layers[i].running_cycles > 0)
-          cerr << "\tRunning Cycles  : " << profile.layers[i].running_cycles
-               << "\n";
+          cerr << "\tRunning Cycles  : " << profile.layers[i].running_cycles << "\n";
         if (profile.layers[i].start_cycles > 0)
-          cerr << "\tStart Cycles  : " << profile.layers[i].start_cycles
-               << "\n";
+          cerr << "\tStart Cycles  : " << profile.layers[i].start_cycles << "\n";
         if (profile.layers[i].end_cycles > 0)
           cerr << "\tEnd Cycles  : " << profile.layers[i].end_cycles << "\n";
         if (profile.layers[i].dram_read_bytes > 0)
-          cerr << "\tDRAM Read  (KB) : "
-               << (profile.layers[i].dram_read_bytes >> 10) << "\n";
+          cerr << "\tDRAM Read  (KB) : " << (profile.layers[i].dram_read_bytes >> 10) << "\n";
         if (profile.layers[i].dram_write_bytes > 0)
-          cerr << "\tDRAM Write (KB) : "
-               << (profile.layers[i].dram_write_bytes >> 10) << "\n";
+          cerr << "\tDRAM Write (KB) : " << (profile.layers[i].dram_write_bytes >> 10) << "\n";
         if (profile.layers[i].sram_read_bytes > 0)
-          cerr << "\tSRAM Read  (KB) : "
-               << (profile.layers[i].sram_read_bytes >> 10) << "\n";
+          cerr << "\tSRAM Read  (KB) : " << (profile.layers[i].sram_read_bytes >> 10) << "\n";
         if (profile.layers[i].sram_write_bytes > 0)
-          cerr << "\tSRAM Write (KB) : "
-               << (profile.layers[i].sram_write_bytes >> 10) << "\n";
+          cerr << "\tSRAM Write (KB) : " << (profile.layers[i].sram_write_bytes >> 10) << "\n";
         if (profile.layers[i].visa_exec_seq > 0)
-          cerr << "\tvISA Exec Seq   : " << profile.layers[i].visa_exec_seq
-               << "\n";
+          cerr << "\tvISA Exec Seq   : " << profile.layers[i].visa_exec_seq << "\n";
       }
     }
 
index 740f498..db7114f 100644 (file)
@@ -106,9 +106,7 @@ class ThirdPartyHW {
 /** @brief c++ class to describe how to use npu-engine library */
 class TesterTRIV2 {
  public:
-  TesterTRIV2 () : dev_ (nullptr), meta_ (nullptr), model_id_ (0) {
-    loop_ = DEFAULT_LOOPS;
-  }
+  TesterTRIV2 () : dev_ (nullptr), meta_ (nullptr), model_id_ (0) { loop_ = DEFAULT_LOOPS; }
 
   ~TesterTRIV2 () {
     /** release resources */
@@ -186,8 +184,7 @@ class TesterTRIV2 {
     if (status != 0)
       return status;
 
-    int id = runNPU_internalInput (dev_, model_id_, NPUINPUT_HW_RECURRING,
-                                   hw_dev_.c_str ());
+    int id = runNPU_internalInput (dev_, model_id_, NPUINPUT_HW_RECURRING, hw_dev_.c_str ());
     if (id < 0)
       return id;
 
index 84fb11d..f9b1eea 100644 (file)
@@ -53,8 +53,7 @@ work_child (int argc, char **argv) {
   uint32_t model_id;
   int req_id;
 
-  status =
-      tester.loadModel (model_dir, &model_id, NPU_PRIORITY_MID, NPU_TIMEOUT_MS);
+  status = tester.loadModel (model_dir, &model_id, NPU_PRIORITY_MID, NPU_TIMEOUT_MS);
   if (status != test_ret_success) {
     cerr << "Unable to load model\n";
     return status;
index 8c863c8..0f9d8ef 100644 (file)
@@ -71,16 +71,14 @@ class Tester : public UtilTRIV2 {
       int priority = elem->IntAttribute ("priority");
       int timeout = elem->IntAttribute ("timeout");
 
-      if (priority < NPU_PRIORITY_LOW || priority > NPU_PRIORITY_HIGH ||
-          timeout < 0)
+      if (priority < NPU_PRIORITY_LOW || priority > NPU_PRIORITY_HIGH || timeout < 0)
         return -EINVAL;
 
       XMLElement *item = elem->FirstChildElement ("dirpath");
       if (item == nullptr)
         return -EINVAL;
 
-      if (UtilTRIV2::loadModel (item->GetText (), nullptr,
-                                static_cast<npu_priority> (priority),
+      if (UtilTRIV2::loadModel (item->GetText (), nullptr, static_cast<npu_priority> (priority),
                                 timeout) != 0)
         return -EINVAL;
 
index dbc41a9..366195c 100644 (file)
 
 #define STATECHANGE_TIMEOUT 100000 /* 100s */
 
-typedef enum {
-  MODEL_CONV_2D_000 = 0,
-  MODEL_MOBILENET_V1,
-  MODEL_END
-} srnpu_model;
+typedef enum { MODEL_CONV_2D_000 = 0, MODEL_MOBILENET_V1, MODEL_END } srnpu_model;
 
 static const gchar *model_names[MODEL_END] = {
     [MODEL_CONV_2D_000] = "CONV_2D_000",
@@ -40,8 +36,7 @@ static const gchar *output_dims[MODEL_END] = {
 };
 
 static int
-set_pipeline_state_sync (GstElement *pipeline, GstState state,
-                         uint32_t timeout_ms) {
+set_pipeline_state_sync (GstElement *pipeline, GstState state, uint32_t timeout_ms) {
   GstState cur_state = GST_STATE_VOID_PENDING;
   GstStateChangeReturn ret;
   gint counter = 0;
@@ -69,8 +64,8 @@ make_pipeline_srnpu (srnpu_model model) {
 
   const gchar *input_dim = input_dims[model];
   const gchar *output_dim = output_dims[model];
-  gchar *model_path = g_strdup_printf ("%s/testdata/TRIV235_2TOPS/%s",
-                                       NE_DATADIR, model_names[model]);
+  gchar *model_path =
+      g_strdup_printf ("%s/testdata/TRIV235_2TOPS/%s", NE_DATADIR, model_names[model]);
   gchar *pipeline = g_strdup_printf (
       "filesrc location=%s/input_fmap_0.bin blocksize=-1 ! "
       "application/octet-stream "
@@ -95,12 +90,8 @@ TEST (nnstreamer_test, launch_conv_2d) {
   gstpipe = gst_parse_launch (pipeline, &err);
   EXPECT_NE (gstpipe, nullptr);
 
-  EXPECT_EQ (
-      set_pipeline_state_sync (gstpipe, GST_STATE_PLAYING, STATECHANGE_TIMEOUT),
-      0);
-  EXPECT_EQ (
-      set_pipeline_state_sync (gstpipe, GST_STATE_NULL, STATECHANGE_TIMEOUT),
-      0);
+  EXPECT_EQ (set_pipeline_state_sync (gstpipe, GST_STATE_PLAYING, STATECHANGE_TIMEOUT), 0);
+  EXPECT_EQ (set_pipeline_state_sync (gstpipe, GST_STATE_NULL, STATECHANGE_TIMEOUT), 0);
 
   gst_object_unref (gstpipe);
   g_free (pipeline);
@@ -115,12 +106,8 @@ TEST (nnstreamer_test, launch_mobilenet_v1) {
   gstpipe = gst_parse_launch (pipeline, &err);
   EXPECT_NE (gstpipe, nullptr);
 
-  EXPECT_EQ (
-      set_pipeline_state_sync (gstpipe, GST_STATE_PLAYING, STATECHANGE_TIMEOUT),
-      0);
-  EXPECT_EQ (
-      set_pipeline_state_sync (gstpipe, GST_STATE_NULL, STATECHANGE_TIMEOUT),
-      0);
+  EXPECT_EQ (set_pipeline_state_sync (gstpipe, GST_STATE_PLAYING, STATECHANGE_TIMEOUT), 0);
+  EXPECT_EQ (set_pipeline_state_sync (gstpipe, GST_STATE_NULL, STATECHANGE_TIMEOUT), 0);
 
   gst_object_unref (gstpipe);
   g_free (pipeline);
index 682abd6..6752e7c 100644 (file)
@@ -70,9 +70,9 @@ start_npumgr_test (int fd, const string &dir) {
     return NPUMGR_STATUS_ERR_FAIL;
   }
 
-  status = npumgr_network_create (
-      context, 1, input_files, NPUMGR_BUF_TYPE_DRIVER, 1, input_tensor_names,
-      NPUMGR_BUF_TYPE_DRIVER, 1, output_tensor_names, &network);
+  status =
+      npumgr_network_create (context, 1, input_files, NPUMGR_BUF_TYPE_DRIVER, 1, input_tensor_names,
+                             NPUMGR_BUF_TYPE_DRIVER, 1, output_tensor_names, &network);
   if (status != NPUMGR_STATUS_SUCCESS) {
     cerr << "Unable to create a npumgr network, " << status << "\n";
     goto destroy_ctx;
@@ -128,8 +128,8 @@ start_npumgr_test (int fd, const string &dir) {
 
     size_t read_bytes = fread (data, 1, input_bufs[i].buf_size, f);
     if (read_bytes != input_bufs[i].buf_size) {
-      cerr << "Unable to read input data, " << read_bytes << " vs. "
-           << input_bufs[i].buf_size << "\n";
+      cerr << "Unable to read input data, " << read_bytes << " vs. " << input_bufs[i].buf_size
+           << "\n";
       fclose (f);
       goto destroy_all;
     }
@@ -200,8 +200,7 @@ start_npumgr_test (int fd, const string &dir) {
       goto destroy_all;
     }
 
-    if (compare_data (file_path.c_str (), (const char *) data,
-                      output_bufs[i].buf_size) != 0) {
+    if (compare_data (file_path.c_str (), (const char *) data, output_bufs[i].buf_size) != 0) {
       cerr << "Failed to get valid output data\n";
       goto destroy_all;
     }
index 102b6c8..2ea0a69 100644 (file)
@@ -19,8 +19,7 @@
  * @brief fill dummy metadata v1
  */
 static void
-fill_test_metadata_v1 (npubin_meta &data, uint32_t input_size,
-                       uint32_t output_size) {
+fill_test_metadata_v1 (npubin_meta &data, uint32_t input_size, uint32_t output_size) {
   data.magiccode = NPUBIN_MAGICCODE | 0x1; /* v1 */
   data.size = 8192;
   data.buffer_size = 4096;
@@ -37,8 +36,7 @@ fill_test_metadata_v1 (npubin_meta &data, uint32_t input_size,
  * @brief fill dummy metadata v2
  */
 static void
-fill_test_metadata_v2 (npubin_meta &data, uint32_t input_num,
-                       uint32_t output_num) {
+fill_test_metadata_v2 (npubin_meta &data, uint32_t input_num, uint32_t output_num) {
   data.magiccode = NPUBIN_MAGICCODE | 0x2; /* v2 */
   data.size = 8192;
   data.buffer_size = 4096;
@@ -49,8 +47,7 @@ fill_test_metadata_v2 (npubin_meta &data, uint32_t input_num,
   for (uint32_t i = 0; i < data.input_num; i++) {
     data.input_offsets[i] = 100 * (i + 1);
     data.input_elem_size[i] = 1 * (i + 1);
-    for (uint32_t j = 0; j < MAX_RANK - 1; j++)
-      data.input_dims[i][j] = 1 * (i + 1);
+    for (uint32_t j = 0; j < MAX_RANK - 1; j++) data.input_dims[i][j] = 1 * (i + 1);
     data.input_dims[i][MAX_RANK - 1] = DATA_GRANULARITY;
     data.input_quant_z[i] = 3 * (i + 1);
     data.input_quant_s[i] = 4 * (i + 1);
@@ -60,8 +57,7 @@ fill_test_metadata_v2 (npubin_meta &data, uint32_t input_num,
   for (uint32_t i = 0; i < data.output_num; i++) {
     data.output_offsets[i] = 100 * (i + 1);
     data.output_elem_size[i] = 1 * (i + 1);
-    for (uint32_t j = 0; j < MAX_RANK - 1; j++)
-      data.output_dims[i][j] = 1 * (i + 1);
+    for (uint32_t j = 0; j < MAX_RANK - 1; j++) data.output_dims[i][j] = 1 * (i + 1);
     data.output_dims[i][MAX_RANK - 1] = DATA_GRANULARITY;
     data.output_quant_z[i] = 3 * (i + 1);
     data.output_quant_s[i] = 4 * (i + 1);
index 2e07ab6..fd553a5 100644 (file)
@@ -185,16 +185,13 @@ TEST (ne_core_comm_test, insert_buffer) {
 
   EXPECT_EQ (plugin.insertGenericBuffer (data, &buffer), 0);
 
-  for (size_t i = 0; i < size; i++)
-    EXPECT_EQ (static_cast<char *> (buffer.addr)[i], 'a');
+  for (size_t i = 0; i < size; i++) EXPECT_EQ (static_cast<char *> (buffer.addr)[i], 'a');
 
   /** data manipulation func is called */
-  auto manip_func =
-      std::bind (test_manip, static_cast<char *> (buffer.addr), size);
+  auto manip_func = std::bind (test_manip, static_cast<char *> (buffer.addr), size);
   EXPECT_EQ (plugin.insertGenericBuffer (data, &buffer, manip_func), 0);
 
-  for (size_t i = 0; i < size; i++)
-    EXPECT_EQ (static_cast<char *> (buffer.addr)[i], 'b');
+  for (size_t i = 0; i < size; i++) EXPECT_EQ (static_cast<char *> (buffer.addr)[i], 'b');
 
   delete[] static_cast<char *> (buffer.addr);
   delete[] data;
index e51ebd3..edc150c 100644 (file)
@@ -280,12 +280,10 @@ TEST (ne_core_data_test, perform_layer_conversion_asymm8) {
 
   for (int i = 0; i < 4096; i += granularity) {
     EXPECT_EQ (
-        memcmp (src_data + i, dst_data + (granularity / 2) * (i / granularity),
-                granularity / 2),
+        memcmp (src_data + i, dst_data + (granularity / 2) * (i / granularity), granularity / 2),
         0);
     EXPECT_EQ (memcmp (src_data + i + (granularity / 2),
-                       dst_data + (granularity / 2) * (i / granularity) + 2048,
-                       granularity / 2),
+                       dst_data + (granularity / 2) * (i / granularity) + 2048, granularity / 2),
                0);
   }
 
@@ -319,12 +317,10 @@ TEST (ne_core_data_test, perform_layer_conversion_symm16) {
   /* check values */
   for (int i = 0; i < 4096; i += granularity) {
     EXPECT_EQ (
-        memcmp (src_data + i, dst_data + (granularity / 2) * (i / granularity),
-                granularity / 2),
+        memcmp (src_data + i, dst_data + (granularity / 2) * (i / granularity), granularity / 2),
         0);
     EXPECT_EQ (memcmp (src_data + i + (granularity / 2),
-                       dst_data + (granularity / 2) * (i / granularity) + 2048,
-                       granularity / 2),
+                       dst_data + (granularity / 2) * (i / granularity) + 2048, granularity / 2),
                0);
   }
 
@@ -334,20 +330,16 @@ TEST (ne_core_data_test, perform_layer_conversion_symm16) {
 
   for (int i = 0; i < 4096; i += granularity) {
     EXPECT_EQ (
-        memcmp (src_data + i, dst_data + (granularity / 4) * (i / granularity),
-                granularity / 4),
+        memcmp (src_data + i, dst_data + (granularity / 4) * (i / granularity), granularity / 4),
         0);
     EXPECT_EQ (memcmp (src_data + i + (granularity / 4),
-                       dst_data + (granularity / 4) * (i / granularity) + 1024,
-                       granularity / 4),
+                       dst_data + (granularity / 4) * (i / granularity) + 1024, granularity / 4),
                0);
     EXPECT_EQ (memcmp (src_data + i + 2 * (granularity / 4),
-                       dst_data + (granularity / 4) * (i / granularity) + 2048,
-                       granularity / 4),
+                       dst_data + (granularity / 4) * (i / granularity) + 2048, granularity / 4),
                0);
     EXPECT_EQ (memcmp (src_data + i + 3 * (granularity / 4),
-                       dst_data + (granularity / 4) * (i / granularity) + 3072,
-                       granularity / 4),
+                       dst_data + (granularity / 4) * (i / granularity) + 3072, granularity / 4),
                0);
   }
 
@@ -391,12 +383,10 @@ TEST (ne_core_data_test, perform_n) {
  * @brief Test quantize() with various types (dummy)
  */
 TEST (ne_core_data_test, dummy_quantize) {
-  data_type npu_types[] = {DATA_TYPE_SRNPU, DATA_TYPE_QASYMM8,
-                           DATA_TYPE_QSYMM16};
-  data_type std_types[] = {
-      DATA_TYPE_INT8,    DATA_TYPE_UINT8,  DATA_TYPE_INT16, DATA_TYPE_UINT16,
-      DATA_TYPE_INT32,   DATA_TYPE_UINT32, DATA_TYPE_INT64, DATA_TYPE_UINT64,
-      DATA_TYPE_FLOAT32, DATA_TYPE_FLOAT64};
+  data_type npu_types[] = {DATA_TYPE_SRNPU, DATA_TYPE_QASYMM8, DATA_TYPE_QSYMM16};
+  data_type std_types[] = {DATA_TYPE_INT8,    DATA_TYPE_UINT8,  DATA_TYPE_INT16, DATA_TYPE_UINT16,
+                           DATA_TYPE_INT32,   DATA_TYPE_UINT32, DATA_TYPE_INT64, DATA_TYPE_UINT64,
+                           DATA_TYPE_FLOAT32, DATA_TYPE_FLOAT64};
   uint32_t data_dims[] = {1, 1, 1, 1024};
 
   void *src_data = malloc (4096);
@@ -487,8 +477,7 @@ TEST (ne_core_data_test, layout_conversion_from_nhwc) {
         for (int w = 0; w < W; w++) {
           for (int c = 0; c < C; c++) {
             std_offset = c + C * (w + W * (h + n * H));
-            npu_offset =
-                c % MPA_L + MPA_L * (w + W * (h + (n + c / MPA_L) * H));
+            npu_offset = c % MPA_L + MPA_L * (w + W * (h + (n + c / MPA_L) * H));
             EXPECT_EQ (src_data[std_offset], dst_data[npu_offset]);
           }
         }
@@ -540,8 +529,7 @@ TEST (ne_core_data_test, layout_conversion_to_nhwc) {
         for (int w = 0; w < W; w++) {
           for (int c = 0; c < C; c++) {
             std_offset = c + C * (w + W * (h + n * H));
-            npu_offset =
-                (c % MPA_L) + MPA_L * (w + W * (h + (n + c / MPA_L) * H));
+            npu_offset = (c % MPA_L) + MPA_L * (w + W * (h + (n + c / MPA_L) * H));
             EXPECT_EQ (src_data[npu_offset], dst_data[std_offset]);
           }
         }
@@ -595,8 +583,7 @@ TEST (ne_core_data_test, layout_conversion_from_nchw) {
         for (int h = 0; h < H; h++) {
           for (int w = 0; w < W; w++) {
             std_offset = w + W * (h + H * (c + n * C));
-            npu_offset =
-                (c % MPA_L) + MPA_L * (w + W * (h + (n + c / MPA_L) * H));
+            npu_offset = (c % MPA_L) + MPA_L * (w + W * (h + (n + c / MPA_L) * H));
             EXPECT_EQ (src_data[std_offset], dst_data[npu_offset]);
           }
         }
@@ -648,8 +635,7 @@ TEST (ne_core_data_test, layout_conversion_to_nchw) {
         for (int h = 0; h < H; h++) {
           for (int w = 0; w < W; w++) {
             std_offset = w + W * (h + H * (c + n * C));
-            npu_offset =
-                (c % MPA_L) + MPA_L * (w + W * (h + (n + c / MPA_L) * H));
+            npu_offset = (c % MPA_L) + MPA_L * (w + W * (h + (n + c / MPA_L) * H));
             EXPECT_EQ (src_data[npu_offset], dst_data[std_offset]);
           }
         }
index 421a884..fc5b0a6 100644 (file)
@@ -57,10 +57,8 @@ TEST (ne_core_handler_test, device_create_instance_out_of_range_n) {
  * @brief test Device's createInstance() with invalid types
  */
 TEST (ne_core_handler_test, device_create_instance_invalid_n) {
-  EXPECT_EQ (Device::createInstance (static_cast<dev_type> (0x1111), 0),
-             nullptr);
-  EXPECT_EQ (Device::createInstance (static_cast<dev_type> (0xFFFF), 0),
-             nullptr);
+  EXPECT_EQ (Device::createInstance (static_cast<dev_type> (0x1111), 0), nullptr);
+  EXPECT_EQ (Device::createInstance (static_cast<dev_type> (0xFFFF), 0), nullptr);
 }
 
 /**
@@ -95,9 +93,7 @@ TEST (ne_core_handler_test, device_instance_uninitilized_n) {
   EXPECT_EQ (triv2->deallocMemory (0, 4096, addr), -EPERM);
   EXPECT_EQ (triv2->stop (true), -EPERM);
   EXPECT_EQ (triv2->setModel (&model_buf, &model), -EPERM);
-  EXPECT_EQ (
-      triv2->run (NPUINPUT_HOST, model, &input, nullptr, nullptr, nullptr),
-      -EPERM);
+  EXPECT_EQ (triv2->run (NPUINPUT_HOST, model, &input, nullptr, nullptr, nullptr), -EPERM);
   EXPECT_EQ (triv2->unsetModel (model), -EPERM);
 }
 
@@ -105,8 +101,7 @@ TEST (ne_core_handler_test, device_instance_uninitilized_n) {
  * @brief test Device's alloc/deallocMemory ()
  */
 TEST (ne_core_handler_test, device_memory) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   void *addr;
@@ -120,8 +115,7 @@ TEST (ne_core_handler_test, device_memory) {
  * @brief test Device's allocMemory () with error handling
  */
 TEST (ne_core_handler_test, device_memory_args_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   void *addr;
@@ -187,8 +181,7 @@ destroy_model_buffer (generic_buffer &model_buf) {
  * @brief test TRIV2's setModel ()
  */
 TEST (ne_core_handler_test, triv2_set_model) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   generic_buffer model_buf = {0};
@@ -206,8 +199,7 @@ TEST (ne_core_handler_test, triv2_set_model) {
  * @brief test TRIV2's setModel () with error handling
  */
 TEST (ne_core_handler_test, triv2_set_model_invalid_args_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   generic_buffer model_buf = {0};
@@ -225,8 +217,7 @@ TEST (ne_core_handler_test, triv2_set_model_invalid_args_n) {
  * @brief test TRIV2's setModel () with error handling
  */
 TEST (ne_core_handler_test, triv2_set_model_invalid_data_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   generic_buffer model_buf = {0};
@@ -277,8 +268,7 @@ TEST (ne_core_handler_test, triv2_set_model_invalid_data_n) {
  * @brief test TRIV2's unsetModel () with error handling
  */
 TEST (ne_core_handler_test, triv2_unset_model_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
   EXPECT_NE (device->unsetModel (nullptr), 0);
 }
@@ -316,8 +306,7 @@ user_cb (output_buffers *output, int req_id, void *data) {
  * @brief test Device's run ()
  */
 TEST (ne_core_handler_test, triv2_run) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   /** prepare model */
@@ -344,12 +333,9 @@ TEST (ne_core_handler_test, triv2_run) {
   user_cb_data data;
   data.num_called = 0;
 
-  EXPECT_GT (device->run (opmode, model, &input_buf, nullptr, user_cb, &data),
-             0);
-  EXPECT_GT (device->run (opmode, model, &input_buf, nullptr, user_cb, &data),
-             0);
-  EXPECT_GT (device->run (opmode, model, &input_buf, nullptr, user_cb, &data),
-             0);
+  EXPECT_GT (device->run (opmode, model, &input_buf, nullptr, user_cb, &data), 0);
+  EXPECT_GT (device->run (opmode, model, &input_buf, nullptr, user_cb, &data), 0);
+  EXPECT_GT (device->run (opmode, model, &input_buf, nullptr, user_cb, &data), 0);
 
   wait_callbacks (data.num_called, max_called, data.m, data.cv);
   EXPECT_EQ (data.num_called, max_called);
@@ -362,8 +348,7 @@ TEST (ne_core_handler_test, triv2_run) {
  * @brief test TRIV2's run () with error handling
  */
 TEST (ne_core_handler_test, triv2_run_invalid_args_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   /** TRIV2 requires valid model and buffer arguments */
@@ -394,8 +379,7 @@ TEST (ne_core_handler_test, triv2_run_invalid_args_n) {
  * @brief test TRIV2's run () with error handling
  */
 TEST (ne_core_handler_test, triv2_run_invalid_opmode_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   /** prepare model */
@@ -414,8 +398,7 @@ TEST (ne_core_handler_test, triv2_run_invalid_opmode_n) {
   EXPECT_NE (device->run (NPUINPUT_INTERNAL_CAM, model, &input_buf), 0);
   EXPECT_NE (device->run (NPUINPUT_I2S_MIC, model, &input_buf), 0);
   EXPECT_NE (device->run (NPUINPUT_HW_RECURRING, model, &input_buf), 0);
-  EXPECT_NE (
-      device->run (static_cast<npu_input_opmode> (0x10), model, &input_buf), 0);
+  EXPECT_NE (device->run (static_cast<npu_input_opmode> (0x10), model, &input_buf), 0);
 
   destroy_input_buffers (input_buf);
   destroy_model_buffer (model_buf);
@@ -425,8 +408,7 @@ TEST (ne_core_handler_test, triv2_run_invalid_opmode_n) {
  * @brief test Device's stop ()
  */
 TEST (ne_core_handler_test, triv2_stop) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   /** prepare model */
@@ -454,17 +436,12 @@ TEST (ne_core_handler_test, triv2_stop) {
   user_cb_data data;
   data.num_called = 0;
 
-  EXPECT_GT (device->run (opmode, model, &input_buf, nullptr, user_cb, &data),
-             0);
-  EXPECT_GT (device->run (opmode, model, &input_buf, nullptr, user_cb, &data),
-             0);
-  EXPECT_GT (device->run (opmode, model, &input_buf, nullptr, user_cb, &data),
-             0);
-  EXPECT_EQ (device->stop (false),
-             0);          /* wait until all requests are resolved */
-  usleep (TEST_SLEEP_MS); /** TODO remove this when stop() is implemented */
-  EXPECT_EQ (data.num_called,
-             max_called); /** callbacks are called successfully */
+  EXPECT_GT (device->run (opmode, model, &input_buf, nullptr, user_cb, &data), 0);
+  EXPECT_GT (device->run (opmode, model, &input_buf, nullptr, user_cb, &data), 0);
+  EXPECT_GT (device->run (opmode, model, &input_buf, nullptr, user_cb, &data), 0);
+  EXPECT_EQ (device->stop (false), 0);     /* wait until all requests are resolved */
+  usleep (TEST_SLEEP_MS);                  /** TODO remove this when stop() is implemented */
+  EXPECT_EQ (data.num_called, max_called); /** callbacks are called successfully */
 
   destroy_input_buffers (input_buf);
   destroy_model_buffer (model_buf);
@@ -474,8 +451,7 @@ TEST (ne_core_handler_test, triv2_stop) {
  * @brief test HostHandler's registerModel ()
  */
 TEST (ne_core_handler_test, handler_register_model) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -518,8 +494,7 @@ TEST (ne_core_handler_test, handler_register_model) {
  * @brief test HostHandler's registerModel () with error handling
  */
 TEST (ne_core_handler_test, handler_register_model_invalid_args_01_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -540,8 +515,7 @@ TEST (ne_core_handler_test, handler_register_model_invalid_args_01_n) {
  * @brief test HostHandler's registerModel () with error handling
  */
 TEST (ne_core_handler_test, handler_register_model_invalid_args_02_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -562,8 +536,7 @@ TEST (ne_core_handler_test, handler_register_model_invalid_args_02_n) {
  * @brief test HostHandler's unregisterModel () with error handling
  */
 TEST (ne_core_handler_test, handler_unregister_model_invalid_id_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -591,8 +564,7 @@ TEST (ne_core_handler_test, handler_unregister_model_invalid_id_n) {
  * @brief test HostHandler's getModel () with error handling
  */
 TEST (ne_core_handler_test, handler_get_model_invalid_id_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -617,8 +589,7 @@ TEST (ne_core_handler_test, handler_get_model_invalid_id_n) {
  * @brief test HostHandler's setDataInfo ()
  */
 TEST (ne_core_handler_test, handler_set_data_info) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -646,8 +617,7 @@ TEST (ne_core_handler_test, handler_set_data_info) {
  * @brief test HostHandler's setDataInfo () with error handling
  */
 TEST (ne_core_handler_test, handler_set_data_info_invalid_args_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -680,8 +650,7 @@ TEST (ne_core_handler_test, handler_set_data_info_invalid_args_n) {
  * @brief test HostHandler's setConstraint ()
  */
 TEST (ne_core_handler_test, handler_set_constraint) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -713,8 +682,7 @@ TEST (ne_core_handler_test, handler_set_constraint) {
  * @brief test HostHandler's setConstraint () with error handling
  */
 TEST (ne_core_handler_test, handler_set_constraint_invalid_args_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -740,8 +708,7 @@ TEST (ne_core_handler_test, handler_set_constraint_invalid_args_n) {
  * @brief test HostHandler's allocGenericBuffer ()
  */
 TEST (ne_core_handler_test, handler_generic_buffer) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -775,19 +742,15 @@ TEST (ne_core_handler_test, handler_generic_buffer) {
  * @brief test HostHandler's allocGenericBuffer () with error handling
  */
 TEST (ne_core_handler_test, handler_generic_buffer_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
   ASSERT_NE (handler, nullptr);
 
   /** invalid args */
-  EXPECT_NE (
-      handler->allocGenericBuffer (static_cast<generic_buffer *> (nullptr)), 0);
-  EXPECT_NE (
-      handler->deallocGenericBuffer (static_cast<generic_buffer *> (nullptr)),
-      0);
+  EXPECT_NE (handler->allocGenericBuffer (static_cast<generic_buffer *> (nullptr)), 0);
+  EXPECT_NE (handler->deallocGenericBuffer (static_cast<generic_buffer *> (nullptr)), 0);
 
   /** invalid type */
   generic_buffer buf = {0};
@@ -828,20 +791,15 @@ TEST (ne_core_handler_test, handler_generic_buffer_n) {
  * @brief test HostHandler's allocGenericBuffer () with error handling
  */
 TEST (ne_core_handler_test, handler_generic_buffers_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
   ASSERT_NE (handler, nullptr);
 
   /** invalid args */
-  EXPECT_NE (
-      handler->allocGenericBuffer (static_cast<generic_buffers *> (nullptr)),
-      0);
-  EXPECT_NE (
-      handler->deallocGenericBuffer (static_cast<generic_buffers *> (nullptr)),
-      0);
+  EXPECT_NE (handler->allocGenericBuffer (static_cast<generic_buffers *> (nullptr)), 0);
+  EXPECT_NE (handler->deallocGenericBuffer (static_cast<generic_buffers *> (nullptr)), 0);
 
   /** invalid type */
 
@@ -858,8 +816,7 @@ TEST (ne_core_handler_test, handler_generic_buffers_n) {
  * @brief test HostHandler's runModel (sync)
  */
 TEST (ne_core_handler_test, handler_triv2_run_sync) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -896,8 +853,7 @@ TEST (ne_core_handler_test, handler_triv2_run_sync) {
  * @brief test HostHandler's runModel (sync) with error handling
  */
 TEST (ne_core_handler_test, handler_triv2_run_model_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -935,8 +891,7 @@ TEST (ne_core_handler_test, handler_triv2_run_model_n) {
  * @brief test HostHandler's runModel (async)
  */
 TEST (ne_core_handler_test, handler_triv2_run_async) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -973,8 +928,7 @@ TEST (ne_core_handler_test, handler_triv2_run_async) {
  * @brief test HostHandler's runModel (async) with error handling
  */
 TEST (ne_core_handler_test, handler_triv2_run_async_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -1010,8 +964,7 @@ TEST (ne_core_handler_test, handler_triv2_run_async_n) {
 TEST (ne_core_handler_test, handler_triv2_get_memory_status) {
   // disabled until this feature is implemented
 #if defined(ENABLE_EMUL)
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
@@ -1066,8 +1019,7 @@ TEST (ne_core_handler_test, handler_triv2_get_memory_status) {
  * @brief test HostHandler's getMemoryStatus () with error handling
  */
 TEST (ne_core_handler_test, handler_triv2_get_memory_status_n) {
-  std::unique_ptr<Device> device (
-      Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
+  std::unique_ptr<Device> device (Device::createInstance (NPUCOND_TRIV2_CONN_SOCIP, 0));
   ASSERT_NE (device.get (), nullptr);
 
   HostHandler *handler = device->getHostHandler ();
index 83c0495..83e44b0 100644 (file)
@@ -23,8 +23,7 @@
  * @brief test primitives of memory allocator default (MemDefault)
  */
 TEST (ne_core_mem_test, mem_default_primitives) {
-  std::unique_ptr<DriverAPI> api =
-      DriverAPI::createDriverAPI (NPUCOND_TRIV2_CONN_SOCIP, 0);
+  std::unique_ptr<DriverAPI> api = DriverAPI::createDriverAPI (NPUCOND_TRIV2_CONN_SOCIP, 0);
   ASSERT_NE (api.get (), nullptr);
 
   /**
@@ -56,8 +55,7 @@ TEST (ne_core_mem_test, mem_default_primitives) {
  * @brief test primitives of memory allocator (unimplemented)
  */
 TEST (ne_core_mem_test, mem_pool_primitives_n) {
-  std::unique_ptr<DriverAPI> api =
-      DriverAPI::createDriverAPI (NPUCOND_TRIV2_CONN_SOCIP, 0);
+  std::unique_ptr<DriverAPI> api = DriverAPI::createDriverAPI (NPUCOND_TRIV2_CONN_SOCIP, 0);
   ASSERT_NE (api.get (), nullptr);
 
   /** 'resv_mem_size' > 0: MemPool (not implemented yet) */
index 47fa129..372bdb3 100644 (file)
@@ -41,8 +41,7 @@ TEST (ne_core_model_test, model_primitives) {
   EXPECT_EQ (model->setMetadata (&data), 0);
   EXPECT_NE (model->getMetadata (), nullptr);
 
-  EXPECT_EQ (model->getInputTensorNum (),
-             exp_num_tensors_v1); /* v1 has one input/output tensors */
+  EXPECT_EQ (model->getInputTensorNum (), exp_num_tensors_v1); /* v1 has one input/output tensors */
   EXPECT_EQ (model->getOutputTensorNum (), exp_num_tensors_v1);
 
   EXPECT_EQ (model->getInputTensorSize (0), exp_size_input);
@@ -275,16 +274,13 @@ TEST (ne_core_model_test, metadata_primitives_v1) {
   EXPECT_EQ (meta->getInputOffset (0), data.input_offset);
   EXPECT_EQ (meta->getInputTensorSize (0, DATA_LAYOUT_SRNPU), data.input_size);
   EXPECT_EQ (meta->getOutputOffset (0), data.output_offset);
-  EXPECT_EQ (meta->getOutputTensorSize (0, DATA_LAYOUT_SRNPU),
-             data.output_size);
+  EXPECT_EQ (meta->getOutputTensorSize (0, DATA_LAYOUT_SRNPU), data.output_size);
 
   /** return default values for unsupported info */
   EXPECT_EQ (meta->getInputElemSize (0), (uint32_t) 1);
   EXPECT_EQ (meta->getOutputElemSize (0), (uint32_t) 1);
-  EXPECT_EQ (meta->getInputDims (0)[0],
-             meta->getInputTensorSize (0, default_data_layout));
-  EXPECT_EQ (meta->getOutputDims (0)[0],
-             meta->getOutputTensorSize (0, default_data_layout));
+  EXPECT_EQ (meta->getInputDims (0)[0], meta->getInputTensorSize (0, default_data_layout));
+  EXPECT_EQ (meta->getOutputDims (0)[0], meta->getOutputTensorSize (0, default_data_layout));
   EXPECT_EQ (meta->getInputQuantZero (0), default_quant_zero);
   EXPECT_EQ (meta->getOutputQuantZero (0), default_quant_zero);
   EXPECT_FLOAT_EQ (meta->getInputQuantScale (0), default_quant_scale);
@@ -336,8 +332,7 @@ TEST (ne_core_model_test, metadata_primitives_v2) {
   for (uint32_t i = 0; i < data.output_num; i++) {
     data.output_offsets[i] = 100 * (i + 1);
     data.output_elem_size[i] = 1 * (i + 1);
-    for (uint32_t j = 0; j < MAX_RANK; j++)
-      data.output_dims[i][j] = 2 * (i + 1);
+    for (uint32_t j = 0; j < MAX_RANK; j++) data.output_dims[i][j] = 2 * (i + 1);
     data.output_quant_z[i] = 3 * (i + 1);
     data.output_quant_s[i] = 4 * (i + 1);
   }
@@ -356,8 +351,7 @@ TEST (ne_core_model_test, metadata_primitives_v2) {
   for (uint32_t i = 0; i < meta->getInputNum (); i++) {
     EXPECT_EQ (meta->getInputOffset (i), 100 * (i + 1));
     EXPECT_EQ (meta->getInputElemSize (i), 1 * (i + 1));
-    for (uint32_t j = 0; j < MAX_RANK; j++)
-      EXPECT_EQ (meta->getInputDims (i)[j], 2 * (i + 1));
+    for (uint32_t j = 0; j < MAX_RANK; j++) EXPECT_EQ (meta->getInputDims (i)[j], 2 * (i + 1));
     EXPECT_EQ (meta->getInputQuantZero (i), 3 * (i + 1));
     EXPECT_EQ (meta->getInputQuantScale (i), 4 * (i + 1));
   }
@@ -366,8 +360,7 @@ TEST (ne_core_model_test, metadata_primitives_v2) {
   for (uint32_t i = 0; i < meta->getOutputNum (); i++) {
     EXPECT_EQ (meta->getOutputOffset (i), 100 * (i + 1));
     EXPECT_EQ (meta->getOutputElemSize (i), 1 * (i + 1));
-    for (uint32_t j = 0; j < MAX_RANK; j++)
-      EXPECT_EQ (meta->getOutputDims (i)[j], 2 * (i + 1));
+    for (uint32_t j = 0; j < MAX_RANK; j++) EXPECT_EQ (meta->getOutputDims (i)[j], 2 * (i + 1));
     EXPECT_EQ (meta->getOutputQuantZero (i), 3 * (i + 1));
     EXPECT_EQ (meta->getOutputQuantScale (i), 4 * (i + 1));
   }
@@ -397,8 +390,7 @@ TEST (ne_core_model_test, metadata_primitives_v3) {
   data.input_seg_num = input_num;
   for (uint32_t i = 0; i < data.input_seg_num; i++) {
     data.input_seg_idx[i] = i;
-    for (uint32_t j = 0; j < MAX_RANK; j++)
-      data.input_seg_dims[i][j] = 2 * (i + 1);
+    for (uint32_t j = 0; j < MAX_RANK; j++) data.input_seg_dims[i][j] = 2 * (i + 1);
     data.input_seg_quant_z[i] = 3 * (i + 1);
     data.input_seg_quant_s[i] = 4 * (i + 1);
     data.input_seg_quant_type[i] = DATA_TYPE_QASYMM8;
@@ -407,8 +399,7 @@ TEST (ne_core_model_test, metadata_primitives_v3) {
   data.output_seg_num = output_num;
   for (uint32_t i = 0; i < data.output_seg_num; i++) {
     data.output_seg_idx[i] = data.input_seg_num + i;
-    for (uint32_t j = 0; j < MAX_RANK; j++)
-      data.output_seg_dims[i][j] = 2 * (i + 1);
+    for (uint32_t j = 0; j < MAX_RANK; j++) data.output_seg_dims[i][j] = 2 * (i + 1);
     data.output_seg_quant_z[i] = 3 * (i + 1);
     data.output_seg_quant_s[i] = 4 * (i + 1);
     data.output_seg_quant_type[i] = DATA_TYPE_QSYMM16;
index 08be624..0e21513 100644 (file)
@@ -172,8 +172,7 @@ TEST (ne_core_utils_test, load_conf_env) {
   const uint32_t exp_num_threads = 16;
   const size_t exp_rsv_mem_sizeg = 1;
   const size_t exp_rsv_mem_sizeb = exp_rsv_mem_sizeg * 1024 * 1024 * 1024;
-  const std::string exp_str_rsv_mem_sizeg (std::to_string (exp_rsv_mem_sizeg) +
-                                           "G");
+  const std::string exp_str_rsv_mem_sizeg (std::to_string (exp_rsv_mem_sizeg) + "G");
   const std::string exp_str_num_threads (std::to_string (exp_num_threads));
   ENV_PAIR envvars;
   save_and_unset_envvars (envvars);
@@ -301,14 +300,11 @@ TEST (ne_core_utils_test, log_write) {
   Logger &logger = Logger::getInstance ();
 
   int ret;
-  ret = logger.logwrite (NPU_LOG_ERROR, _N1,
-                         "testing log severity level (error)\n");
+  ret = logger.logwrite (NPU_LOG_ERROR, _N1, "testing log severity level (error)\n");
   EXPECT_GE (ret, 0);
-  ret = logger.logwrite (NPU_LOG_WARN, _N1,
-                         "testing log severity level (warn)\n");
+  ret = logger.logwrite (NPU_LOG_WARN, _N1, "testing log severity level (warn)\n");
   EXPECT_GE (ret, 0);
-  ret = logger.logwrite (NPU_LOG_INFO, _N1,
-                         "testing log severity level (info)\n");
+  ret = logger.logwrite (NPU_LOG_INFO, _N1, "testing log severity level (info)\n");
   EXPECT_GE (ret, 0);
 }
 
index 4811026..a8933c4 100644 (file)
@@ -545,8 +545,7 @@ TEST (ne_libnpuhost_test, get_npumodel_metadata_04_n) {
   extra = (uint8_t *) malloc (extra_size * NPUBIN_META_SIZE);
   memset (extra, 0, extra_size * NPUBIN_META_SIZE);
 
-  cnt =
-      fwrite (extra, extra_size * (NPUBIN_META_SIZE / 2), 1, meta_only_bin_fp);
+  cnt = fwrite (extra, extra_size * (NPUBIN_META_SIZE / 2), 1, meta_only_bin_fp);
   fclose (meta_only_bin_fp);
   free (extra);
   if (cnt != 1)
@@ -783,9 +782,7 @@ TEST (ne_libnpuhost_test, request_decoupled_apis) {
   /* actual testing (blocking) */
   int req_id;
   EXPECT_EQ (createNPU_request (dev, modelid, &req_id), 0);
-  EXPECT_EQ (
-      setNPU_requestData (dev, req_id, &input, &info_in, &output, &info_out),
-      0);
+  EXPECT_EQ (setNPU_requestData (dev, req_id, &input, &info_in, &output, &info_out), 0);
   EXPECT_EQ (setNPU_requestMode (dev, req_id, NPU_INFER_BLOCKING), 0);
   EXPECT_EQ (setNPU_requestConstraint (dev, req_id, constraint), 0);
 
@@ -801,9 +798,7 @@ TEST (ne_libnpuhost_test, request_decoupled_apis) {
   sync.done = false;
 
   EXPECT_EQ (createNPU_request (dev, modelid, &req_id), 0);
-  EXPECT_EQ (
-      setNPU_requestData (dev, req_id, &input, &info_in, &output, &info_out),
-      0);
+  EXPECT_EQ (setNPU_requestData (dev, req_id, &input, &info_in, &output, &info_out), 0);
   EXPECT_EQ (setNPU_requestMode (dev, req_id, NPU_INFER_NON_BLOCKING), 0);
   EXPECT_EQ (setNPU_requestCallback (dev, req_id, test_callback, &sync), 0);
   EXPECT_EQ (setNPU_requestConstraint (dev, req_id, constraint), 0);
@@ -822,17 +817,13 @@ TEST (ne_libnpuhost_test, request_decoupled_apis) {
   int req_ids[max_iters];
 
   /* nobody will invoke the requests */
-  for (int i = 0; i < max_iters; i++) {
+  for (uint32_t i = 0; i < max_iters; i++) {
     EXPECT_EQ (createNPU_request (dev, modelid, &req_ids[i]), 0);
     /* regardless of setting which scheduler, kernel requests will use the VD scheculder */
     if ((i % 3) == 1) {
-      EXPECT_EQ (
-          setNPU_requestScheduler (dev, req_ids[i], NPU_SCHEDULER_SR, nullptr),
-          0);
+      EXPECT_EQ (setNPU_requestScheduler (dev, req_ids[i], NPU_SCHEDULER_SR, nullptr), 0);
     } else if ((i % 3) == 2) {
-      EXPECT_EQ (
-          setNPU_requestScheduler (dev, req_ids[i], NPU_SCHEDULER_VD, nullptr),
-          0);
+      EXPECT_EQ (setNPU_requestScheduler (dev, req_ids[i], NPU_SCHEDULER_VD, nullptr), 0);
     }
     EXPECT_EQ (setNPU_requestConstraint (dev, req_ids[i], constraint), 0);
     EXPECT_EQ (submitNPU_requestKernel (dev, req_ids[i]), 0);
@@ -840,8 +831,7 @@ TEST (ne_libnpuhost_test, request_decoupled_apis) {
 
   sleep (1);
 
-  for (int i = 0; i < max_iters; i++)
-    EXPECT_EQ (removeNPU_request (dev, req_ids[i]), 0);
+  for (uint32_t i = 0; i < max_iters; i++) EXPECT_EQ (removeNPU_request (dev, req_ids[i]), 0);
 
   ASSERT_EQ (unregisterNPUmodel (dev, modelid), 0);
   putNPUdevice (dev);
@@ -930,8 +920,7 @@ TEST (ne_libnpuhost_test, write_logs) {
       NPU_LOG_INFO,
   };
 
-  for (auto &level : levels)
-    EXPECT_EQ (writeNPU_log (level, "TEST", "testing logs..."), 0);
+  for (auto &level : levels) EXPECT_EQ (writeNPU_log (level, "TEST", "testing logs..."), 0);
 }
 
 /**
index 767878e..3b9c549 100644 (file)
@@ -91,11 +91,9 @@ make_model (npudev_h dev, npubin_meta *meta, buffer_types buf_type) {
     case BUFFER_DMABUF:
       /* BUFFER_MAPPED, BUFFER_DMABUF */
       memcpy (buffer->addr, meta, NPUBIN_META_SIZE);
-      fill_program ((char *) buffer->addr + NPUBIN_META_SIZE,
-                    meta->program_size);
-      fill_weight (
-          (char *) buffer->addr + NPUBIN_META_SIZE + meta->program_size,
-          meta->weight_size);
+      fill_program ((char *) buffer->addr + NPUBIN_META_SIZE, meta->program_size);
+      fill_weight ((char *) buffer->addr + NPUBIN_META_SIZE + meta->program_size,
+                   meta->weight_size);
       break;
     default:
       break;
@@ -166,8 +164,8 @@ run_apptest (npudev_h dev, char **argv, FUNC_APPTEST func) {
   closedir (d);
   putNPUdevice (dev);
 
-  fprintf (stderr, "[APPTEST] %s: PASSED (%d), FAILED (%d), SKIPPED (%d)\n",
-           name, total_succs, total_fails, total_skpds);
+  fprintf (stderr, "[APPTEST] %s: PASSED (%d), FAILED (%d), SKIPPED (%d)\n", name, total_succs,
+           total_fails, total_skpds);
 
   return -total_fails;
 }
@@ -193,8 +191,7 @@ recheck:
       goto recheck;
     }
 
-    fprintf (stderr, "memory leak check failed (0x%zx != 0x%zx)\n", free_total,
-             alloc_total);
+    fprintf (stderr, "memory leak check failed (0x%zx != 0x%zx)\n", free_total, alloc_total);
     return -EINVAL;
   }
 
@@ -318,8 +315,7 @@ UtilTrinity::setProfLevel (const std::string level) {
 }
 /** @brief parse/set arguments and get working directory */
 int
-UtilTrinity::parseArgs (int argc, char **argv, const char *param_str,
-                        int *index) {
+UtilTrinity::parseArgs (int argc, char **argv, const char *param_str, int *index) {
   int c;
 
   if (index != nullptr)
@@ -371,8 +367,8 @@ UtilTrinity::parseArgs (int argc, char **argv, const char *param_str,
 
 /** @brief load NPU model and set relevant info */
 int
-UtilTrinity::loadModel (std::string dirpath, uint32_t *model_id_ptr,
-                        npu_priority priority, uint32_t timeout) {
+UtilTrinity::loadModel (std::string dirpath, uint32_t *model_id_ptr, npu_priority priority,
+                        uint32_t timeout) {
   if (dirpath == "")
     return -EINVAL;
 
@@ -509,8 +505,7 @@ UtilTrinity::callback (output_buffers *output, int req_id, void *data) {
   UtilModel *model = static_cast<UtilModel *> (data);
 
   if (model == nullptr) {
-    for (uint32_t idx = 0; idx < output->num_buffers; idx++)
-      free (output->bufs[idx].addr);
+    for (uint32_t idx = 0; idx < output->num_buffers; idx++) free (output->bufs[idx].addr);
   }
 
   std::unique_lock<std::mutex> lock (m_);
@@ -544,9 +539,8 @@ UtilTrinity::run_each (UtilModel *model, bool sync) {
 
     if (model) {
       cb_output = model->getOutput ();
-      status =
-          runNPU_model (dev_, model->getModelID (), NPU_INFER_BLOCKING,
-                        model->getInput (), model->getOutput (), NULL, NULL);
+      status = runNPU_model (dev_, model->getModelID (), NPU_INFER_BLOCKING, model->getInput (),
+                             model->getOutput (), NULL, NULL);
     } else {
       /* TODO: revise this when TRIA is implemented */
       input_buffers input;
@@ -573,9 +567,8 @@ UtilTrinity::run_each (UtilModel *model, bool sync) {
     }
   } else {
     if (model) {
-      status =
-          runNPU_model (dev_, model->getModelID (), NPU_INFER_NON_BLOCKING,
-                        model->getInput (), model->getOutput (), cb, cb_data);
+      status = runNPU_model (dev_, model->getModelID (), NPU_INFER_NON_BLOCKING, model->getInput (),
+                             model->getOutput (), cb, cb_data);
     } else {
       /* TODO: revise this when TRIA is implemented */
       input_buffers input;
@@ -613,8 +606,8 @@ UtilTrinity::createRequest (uint32_t model_id) {
   if (status != 0)
     return status;
 
-  status = setNPU_requestData (dev_, req_id, model->getInput (), nullptr,
-                               model->getOutput (), nullptr);
+  status =
+      setNPU_requestData (dev_, req_id, model->getInput (), nullptr, model->getOutput (), nullptr);
   if (status != 0) {
     removeNPU_request (dev_, req_id);
     return status;
@@ -641,8 +634,7 @@ UtilTrinity::submitRequest (int req_id) {
   status = submitNPU_request (dev_, req_id);
   if (status == 0) {
     total_++;
-    UtilTrinity::callbackVerify (model->getOutput (), req_id,
-                                 static_cast<void *> (model));
+    UtilTrinity::callbackVerify (model->getOutput (), req_id, static_cast<void *> (model));
   }
 
   return status;
@@ -701,8 +693,7 @@ UtilTrinity::getMemoryStatus (size_t *alloc_total, size_t *free_total) {
 
 /** @brief configure constraint for the model */
 int
-UtilTrinity::set_constraint (uint32_t model_id, uint32_t timeout,
-                             npu_priority priority) {
+UtilTrinity::set_constraint (uint32_t model_id, uint32_t timeout, npu_priority priority) {
   npuConstraint constraint;
 
   constraint.timeout_ms = timeout;
index 7349c50..aed4f86 100644 (file)
@@ -56,8 +56,7 @@ class UtilModel {
     } else {
       inpath_.resize (num);
       for (uint32_t idx = 0; idx < num; idx++)
-        inpath_[idx] =
-            dirpath_ + "/input_fmap_" + std::to_string (idx) + ".bin";
+        inpath_[idx] = dirpath_ + "/input_fmap_" + std::to_string (idx) + ".bin";
     }
   }
   void prepareOutputPath (uint32_t num) {
@@ -67,8 +66,7 @@ class UtilModel {
     } else {
       outpath_.resize (num);
       for (uint32_t idx = 0; idx < num; idx++)
-        outpath_[idx] =
-            dirpath_ + "/output_fmap_" + std::to_string (idx) + ".bin";
+        outpath_[idx] = dirpath_ + "/output_fmap_" + std::to_string (idx) + ".bin";
     }
   }
   const char *getInputPath (uint32_t idx) { return inpath_[idx].c_str (); }
@@ -114,10 +112,8 @@ class UtilTrinity {
   int init (uint32_t tops = default_tops);
   void clear ();
   void printUsage (const char *prog_name, const char *param_str = nullptr);
-  int parseArgs (int argc, char **argv, const char *param_str = nullptr,
-                 int *index = nullptr);
-  int loadModel (std::string dirpath, uint32_t *model_id,
-                 npu_priority priority = NPU_PRIORITY_MID,
+  int parseArgs (int argc, char **argv, const char *param_str = nullptr, int *index = nullptr);
+  int loadModel (std::string dirpath, uint32_t *model_id, npu_priority priority = NPU_PRIORITY_MID,
                  uint32_t timeout = 5000);
   int unloadModel (uint32_t model_id);
 
@@ -154,15 +150,12 @@ class UtilTrinity {
   std::string node_;
 
  private:
-  int set_constraint (uint32_t model_id, uint32_t timeout,
-                      npu_priority priority);
+  int set_constraint (uint32_t model_id, uint32_t timeout, npu_priority priority);
   int run_each (UtilModel *model, bool sync);
 
   virtual bool check_version (npubin_meta *meta) { return false; }
   virtual int prepare_model (UtilModel *model) { return -EPERM; }
-  virtual int set_data_info (npubin_meta *meta, uint32_t model_id) {
-    return -EPERM;
-  }
+  virtual int set_data_info (npubin_meta *meta, uint32_t model_id) { return -EPERM; }
   virtual bool extract_node_id (uint32_t *id) { return false; }
 
   dev_type type_;
@@ -233,8 +226,7 @@ void fill_input_data (generic_buffer *buffer, size_t offset, size_t size);
  * @param[in] buf_type The memory type of the buffer included in the model
  * @return A generic buffer including dummy model data, NULL if error
  */
-generic_buffer *make_model (npudev_h dev, npubin_meta *meta,
-                            buffer_types buf_type);
+generic_buffer *make_model (npudev_h dev, npubin_meta *meta, buffer_types buf_type);
 
 /**
  * @brief Destroy generic buffer with model data
index 544c502..3b07387 100644 (file)
@@ -55,8 +55,7 @@ get_file_size (const char *file_path) {
  * @return 0 if no error, otherwise a negative errno
  */
 int
-compare_data (const char *golden_path, const char *output_data,
-              uint64_t output_size) {
+compare_data (const char *golden_path, const char *output_data, uint64_t output_size) {
   ifstream ifs (golden_path, ios::binary | ios::ate);
   if (!ifs.good ()) {
     cerr << "Unable to find the file " << golden_path << "\n";
@@ -81,8 +80,7 @@ compare_data (const char *golden_path, const char *output_data,
 
   /* find the first mismatch */
   int err = 0;
-  auto mispair =
-      mismatch (golden_vec.begin (), golden_vec.end (), output_vec.begin ());
+  auto mispair = mismatch (golden_vec.begin (), golden_vec.end (), output_vec.begin ());
   if (mispair.first != golden_vec.end ()) {
     uint32_t idx = distance (golden_vec.begin (), mispair.first);
 
index 4cb9a4c..a28db6e 100644 (file)
@@ -33,8 +33,7 @@ test_callback (int *num_called, std::mutex *m, std::condition_variable *cv) {
 }
 
 static inline void
-test_callback_sleep (int *num_called, std::mutex *m,
-                     std::condition_variable *cv) {
+test_callback_sleep (int *num_called, std::mutex *m, std::condition_variable *cv) {
   {
     std::unique_lock<std::mutex> lock (*m);
     (*num_called)++;
@@ -46,8 +45,7 @@ test_callback_sleep (int *num_called, std::mutex *m,
 }
 
 static inline void
-wait_callbacks (int &num_called, int max_called, std::mutex &m,
-                std::condition_variable &cv) {
+wait_callbacks (int &num_called, int max_called, std::mutex &m, std::condition_variable &cv) {
   std::unique_lock<std::mutex> lock (m);
   cv.wait (lock, [&]() { return max_called == num_called; });
 }
@@ -69,8 +67,7 @@ off_t get_file_size (const char *file_path);
  * @param[in] output_size the output data size
  * @return 0 if no error, otherwise a negative errno
  */
-int compare_data (const char *golden_path, const char *output_data,
-                  uint64_t output_size);
+int compare_data (const char *golden_path, const char *output_data, uint64_t output_size);
 
 #if defined(__cplusplus)
 }
index 078f1c6..8bf01d8 100644 (file)
@@ -23,14 +23,12 @@ start_gtest (int argc, char **argv) {
   try {
     testing::InitGoogleTest (&argc, argv);
   } catch (...) {
-    std::cerr << "catch 'testing::internal::<unnamed>::ClassUniqueToAlwaysTrue'"
-              << std::endl;
+    std::cerr << "catch 'testing::internal::<unnamed>::ClassUniqueToAlwaysTrue'" << std::endl;
   }
   try {
     ret = RUN_ALL_TESTS ();
   } catch (...) {
-    std::cerr << "catch `testing::internal::GoogleTestFailureException`"
-              << std::endl;
+    std::cerr << "catch `testing::internal::GoogleTestFailureException`" << std::endl;
   }
   return ret;
 }
index 325c7a6..d5a659b 100644 (file)
@@ -246,9 +246,8 @@ Inspector::show_v3 () {
   }
   std::cout << "\n";
   std::cout << "  weight_seg_idx: ";
-  std::cout << (meta_->weight_seg_idx < meta_->segment_num
-                    ? std::to_string (meta_->weight_seg_idx)
-                    : "N/A");
+  std::cout << (meta_->weight_seg_idx < meta_->segment_num ? std::to_string (meta_->weight_seg_idx)
+                                                           : "N/A");
   std::cout << "\n\n";
   std::cout << "  input_seg_num: " << meta_->input_seg_num << "\n";
   for (uint32_t i = 0; i < meta_->input_seg_num; i++) {
index 8fcbb84..d446ee7 100644 (file)
@@ -58,8 +58,7 @@ class EmulDmabuf {
 
     /* create a shared memory */
     mode_t old_umask = umask (0);
-    shm_name_ =
-        "/triv2_" + std::to_string (app_id) + "_" + std::to_string (fd_);
+    shm_name_ = "/triv2_" + std::to_string (app_id) + "_" + std::to_string (fd_);
     shm_fd_ = shm_open (shm_name_.c_str (), O_RDWR | O_CREAT, 0666);
     umask (old_umask);
   }
@@ -157,8 +156,7 @@ class EmulModel {
     if (l.deleted_ || r.deleted_)
       return false;
 
-    if ((l.dbuf_fd_ != r.dbuf_fd_) ||
-        (l.program_offset_addr_ != r.program_offset_addr_) ||
+    if ((l.dbuf_fd_ != r.dbuf_fd_) || (l.program_offset_addr_ != r.program_offset_addr_) ||
         (l.program_size_ != r.program_size_) || (l.version_ != r.version_))
       return false;
 
@@ -207,9 +205,7 @@ class EmulProfile {
   int64_t getInputFootprint () const { return profile_.dram_input_footprint; }
   int64_t getOutputFootprint () const { return profile_.dram_output_footprint; }
   void *getData () const { return profile_.layers; }
-  size_t getDataSize () const {
-    return profile_.num_layers * sizeof (npu_profile_layer);
-  }
+  size_t getDataSize () const { return profile_.num_layers * sizeof (npu_profile_layer); }
 
   bool parse () {
     std::ifstream ifs (prof_path_, std::ios::binary);
@@ -220,8 +216,7 @@ class EmulProfile {
 
     profile_.prof_path = strdup (prof_path_.c_str ());
     if (!profile_.prof_path) {
-      std::cerr << "Unable to duplicate the profile path " << prof_path_
-                << "\n";
+      std::cerr << "Unable to duplicate the profile path " << prof_path_ << "\n";
       return false;
     }
 
@@ -230,8 +225,7 @@ class EmulProfile {
 
     if (head.fmt_vesion != TRIV2PROF_FMT_VER) {
       std::cerr << "Profile data format mismatch: "
-                << "(" << head.fmt_vesion << " vs. " << TRIV2PROF_FMT_VER
-                << ")\n";
+                << "(" << head.fmt_vesion << " vs. " << TRIV2PROF_FMT_VER << ")\n";
       return false;
     }
 
@@ -287,19 +281,15 @@ class EmulProfile {
             ifs.read ((char *) &nna_dma, sizeof (T2PF_DUMP_DMA));
 
             snprintf (layer->name, NPU_OPNAME_MAX, "%s", "ADMA_IN");
-            layer->dram_read_bytes =
-                nna_dma.src_addr_end - nna_dma.src_addr_start;
-            layer->sram_write_bytes =
-                nna_dma.dest_addr_end - nna_dma.dest_addr_start;
+            layer->dram_read_bytes = nna_dma.src_addr_end - nna_dma.src_addr_start;
+            layer->sram_write_bytes = nna_dma.dest_addr_end - nna_dma.dest_addr_start;
             break;
           case TRIV2PROF_BLOCKID_NNA_DMA_OUT:
             ifs.read ((char *) &nna_dma, sizeof (T2PF_DUMP_DMA));
 
             snprintf (layer->name, NPU_OPNAME_MAX, "%s", "ADMA_OUT");
-            layer->dram_write_bytes =
-                nna_dma.dest_addr_end - nna_dma.dest_addr_start;
-            layer->sram_read_bytes =
-                nna_dma.src_addr_end - nna_dma.src_addr_start;
+            layer->dram_write_bytes = nna_dma.dest_addr_end - nna_dma.dest_addr_start;
+            layer->sram_read_bytes = nna_dma.src_addr_end - nna_dma.src_addr_start;
             break;
           case TRIV2PROF_BLOCKID_DSP:
             ifs.read ((char *) &dsp, sizeof (T2PF_DUMP_DSP));
@@ -310,23 +300,18 @@ class EmulProfile {
             ifs.read ((char *) &dsp_dma, sizeof (T2PF_DUMP_DMA));
 
             snprintf (layer->name, NPU_OPNAME_MAX, "%s", "PDMA_IN");
-            layer->dram_read_bytes =
-                dsp_dma.src_addr_end - dsp_dma.src_addr_start;
-            layer->sram_write_bytes =
-                dsp_dma.dest_addr_end - dsp_dma.dest_addr_start;
+            layer->dram_read_bytes = dsp_dma.src_addr_end - dsp_dma.src_addr_start;
+            layer->sram_write_bytes = dsp_dma.dest_addr_end - dsp_dma.dest_addr_start;
             break;
           case TRIV2PROF_BLOCKID_DSP_DMA_OUT:
             ifs.read ((char *) &dsp_dma, sizeof (T2PF_DUMP_DMA));
 
             snprintf (layer->name, NPU_OPNAME_MAX, "%s", "PDMA_OUT");
-            layer->dram_write_bytes =
-                dsp_dma.dest_addr_end - dsp_dma.dest_addr_start;
-            layer->sram_read_bytes =
-                dsp_dma.src_addr_end - dsp_dma.src_addr_start;
+            layer->dram_write_bytes = dsp_dma.dest_addr_end - dsp_dma.dest_addr_start;
+            layer->sram_read_bytes = dsp_dma.src_addr_end - dsp_dma.src_addr_start;
             break;
           default:
-            std::cerr << "Unknown block id detected: " << common.block_id
-                      << std::endl;
+            std::cerr << "Unknown block id detected: " << common.block_id << std::endl;
             delete[] profile_.layers;
             profile_.layers = nullptr;
             ifs.close ();
@@ -347,8 +332,7 @@ class EmulProfile {
 
 class EmulStatReq {
  public:
-  EmulStatReq (const trinity_cuse_stat_req &stat)
-      : stat_ (stat), profile_ (nullptr) {}
+  EmulStatReq (const trinity_cuse_stat_req &stat) : stat_ (stat), profile_ (nullptr) {}
   ~EmulStatReq () {
     if (profile_)
       global_profile_map.remove (stat_.req_id);
@@ -599,8 +583,7 @@ triv2_hwmem_alloc (trinity_cuse_context *ctx, const trinity_cuse_hwmem *hwmem) {
  * @brief TRIV2 impl. of hwmem_dealloc ioctl()
  */
 static int
-triv2_hwmem_dealloc (trinity_cuse_context *ctx,
-                     const trinity_cuse_hwmem *hwmem) {
+triv2_hwmem_dealloc (trinity_cuse_context *ctx, const trinity_cuse_hwmem *hwmem) {
   EmulDmabuf *dmabuf = global_dmabuf_map.find (hwmem->dbuf_fd);
   if (dmabuf == nullptr)
     return -ENOENT;
@@ -661,8 +644,7 @@ triv2_deregister_model (trinity_cuse_context *ctx, const uint64_t model_id) {
  * @brief TRIV2 impl. of run_input ioctl()
  */
 static int
-triv2_run_input (trinity_cuse_context *ctx, const trinity_cuse_input *in,
-                 trinity_cuse_input *out) {
+triv2_run_input (trinity_cuse_context *ctx, const trinity_cuse_input *in, trinity_cuse_input *out) {
   EmulDmabuf *dbuf_input = global_dmabuf_map.find (in->dbuf_fd);
   if (dbuf_input == nullptr)
     return -ENOENT;
@@ -709,8 +691,7 @@ triv2_run_input (trinity_cuse_context *ctx, const trinity_cuse_input *in,
 
   for (uint32_t i = 0; i < num_segs; i++) {
     int dbuf_fd = reinterpret_cast<int *> (input)[i];
-    uint32_t offset =
-        reinterpret_cast<uint32_t *> ((char *) input + PAGE_SIZE / 2)[i];
+    uint32_t offset = reinterpret_cast<uint32_t *> ((char *) input + PAGE_SIZE / 2)[i];
 
     EmulDmabuf *dbuf_seg = global_dmabuf_map.find (dbuf_fd);
     if (dbuf_seg == nullptr) {
@@ -744,14 +725,12 @@ triv2_run_input (trinity_cuse_context *ctx, const trinity_cuse_input *in,
 
   EmulStatReq *stat_req = stat->createReqStat (stat_req_data);
 
-  std::chrono::steady_clock::time_point begin =
-      std::chrono::steady_clock::now ();
+  std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now ();
   run_triv2_emul (prog, segt, meta, cmd_path.c_str (), prof_path.c_str ());
   std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now ();
 
   stat_req->updateInferTime (
-      std::chrono::duration_cast<std::chrono::milliseconds> (end - begin)
-          .count ());
+      std::chrono::duration_cast<std::chrono::milliseconds> (end - begin).count ());
 
   EmulProfile *profile = new EmulProfile (req_id, prof_path + ".rec");
   stat_req->setProfile (profile);
@@ -784,8 +763,7 @@ triv2_stop_request (trinity_cuse_context *ctx, const int id) {
  * @brief TRIV2 impl. of stat_current_app ioctl()
  */
 static int
-triv2_stat_current_app (trinity_cuse_context *ctx,
-                        trinity_cuse_stat_app *stat) {
+triv2_stat_current_app (trinity_cuse_context *ctx, trinity_cuse_stat_app *stat) {
   EmulStat *s = global_stat_map.find (ctx->app_id);
   if (s == nullptr)
     return -ENOENT;
@@ -804,8 +782,7 @@ triv2_stat_apps (trinity_cuse_context *ctx, trinity_cuse_stat_apps *stat) {
 
   std::function<bool(EmulStat *)> functor = [&](EmulStat *s) -> bool {
     if (stat->num_apps < TRINITY_APP_STAT_MAX) {
-      memcpy (&stat->stat[stat->num_apps++], s->getStatApp (),
-              sizeof (trinity_cuse_stat_app));
+      memcpy (&stat->stat[stat->num_apps++], s->getStatApp (), sizeof (trinity_cuse_stat_app));
     }
     /* don't remove */
     return false;
@@ -841,8 +818,7 @@ triv2_stat_reqs (trinity_cuse_context *ctx, const trinity_cuse_stat_reqs *in,
  * @brief TRIV2 impl. of get_profile_meta ioctl()
  */
 static int
-triv2_get_profile_meta (trinity_cuse_context *ctx,
-                        const trinity_cuse_profile_meta *in,
+triv2_get_profile_meta (trinity_cuse_context *ctx, const trinity_cuse_profile_meta *in,
                         trinity_cuse_profile_meta *out) {
   EmulProfile *profile = global_profile_map.find (in->req_id);
   if (profile == nullptr)
@@ -865,8 +841,7 @@ triv2_get_profile_meta (trinity_cuse_context *ctx,
  * @brief TRIV2 impl. of get_profile_buff ioctl()
  */
 static int
-triv2_get_profile_buff (trinity_cuse_context *ctx,
-                        const trinity_cuse_profile_buff *in,
+triv2_get_profile_buff (trinity_cuse_context *ctx, const trinity_cuse_profile_buff *in,
                         trinity_cuse_profile_buff *out, void *data) {
   EmulProfile *profile = global_profile_map.find (in->req_id);
   if (profile == nullptr)
@@ -876,8 +851,7 @@ triv2_get_profile_buff (trinity_cuse_context *ctx,
     return -ERANGE;
 
   *out = *in;
-  memcpy (data, (char *) profile->getData () + in->profile_pos,
-          in->profile_size);
+  memcpy (data, (char *) profile->getData () + in->profile_pos, in->profile_size);
 
   return 0;
 }
index a6e6256..5a23b6e 100644 (file)
@@ -84,9 +84,8 @@ trinity_cuse_release (fuse_req_t req, struct fuse_file_info *fi) {
  * @brief impl. of .ioctl ()
  */
 static void
-trinity_cuse_ioctl (fuse_req_t req, int cmd, void *arg,
-                    struct fuse_file_info *fi, unsigned int flags,
-                    const void *in_buf, size_t in_size, size_t out_size) {
+trinity_cuse_ioctl (fuse_req_t req, int cmd, void *arg, struct fuse_file_info *fi,
+                    unsigned int flags, const void *in_buf, size_t in_size, size_t out_size) {
   trinity_cuse_context *ctx = (trinity_cuse_context *) fi->fh;
 
   if (flags & FUSE_IOCTL_COMPAT) {
@@ -167,8 +166,7 @@ trinity_cuse_ioctl (fuse_req_t req, int cmd, void *arg,
         struct iovec iov = {arg, sizeof (trinity_cuse_hwmem)};
         fuse_reply_ioctl_retry (req, &iov, 1, NULL, 0);
       } else {
-        const trinity_cuse_hwmem *val =
-            static_cast<const trinity_cuse_hwmem *> (in_buf);
+        const trinity_cuse_hwmem *val = static_cast<const trinity_cuse_hwmem *> (in_buf);
         fuse_reply_ioctl (req, vtable->hwmem_alloc (ctx, val), NULL, 0);
       }
       break;
@@ -177,8 +175,7 @@ trinity_cuse_ioctl (fuse_req_t req, int cmd, void *arg,
         struct iovec iov = {arg, sizeof (trinity_cuse_hwmem)};
         fuse_reply_ioctl_retry (req, &iov, 1, NULL, 0);
       } else {
-        const trinity_cuse_hwmem *val =
-            static_cast<const trinity_cuse_hwmem *> (in_buf);
+        const trinity_cuse_hwmem *val = static_cast<const trinity_cuse_hwmem *> (in_buf);
         fuse_reply_ioctl (req, vtable->hwmem_dealloc (ctx, val), NULL, 0);
       }
       break;
@@ -187,11 +184,10 @@ trinity_cuse_ioctl (fuse_req_t req, int cmd, void *arg,
         struct iovec iov = {arg, sizeof (trinity_cuse_model)};
         fuse_reply_ioctl_retry (req, &iov, 1, &iov, 1);
       } else {
-        const trinity_cuse_model *in_val =
-            static_cast<const trinity_cuse_model *> (in_buf);
+        const trinity_cuse_model *in_val = static_cast<const trinity_cuse_model *> (in_buf);
         trinity_cuse_model out_val;
-        fuse_reply_ioctl (req, vtable->register_model (ctx, in_val, &out_val),
-                          &out_val, sizeof (out_val));
+        fuse_reply_ioctl (req, vtable->register_model (ctx, in_val, &out_val), &out_val,
+                          sizeof (out_val));
       }
       break;
     case TRINITY_IOCTL_DEREGISTER_MODEL:
@@ -208,11 +204,10 @@ trinity_cuse_ioctl (fuse_req_t req, int cmd, void *arg,
         struct iovec iov = {arg, sizeof (trinity_cuse_input)};
         fuse_reply_ioctl_retry (req, &iov, 1, &iov, 1);
       } else {
-        const trinity_cuse_input *in_val =
-            static_cast<const trinity_cuse_input *> (in_buf);
+        const trinity_cuse_input *in_val = static_cast<const trinity_cuse_input *> (in_buf);
         trinity_cuse_input out_val;
-        fuse_reply_ioctl (req, vtable->run_input (ctx, in_val, &out_val),
-                          &out_val, sizeof (out_val));
+        fuse_reply_ioctl (req, vtable->run_input (ctx, in_val, &out_val), &out_val,
+                          sizeof (out_val));
       }
       break;
     case TRINITY_IOCTL_STOP_REQUESTS:
@@ -233,8 +228,7 @@ trinity_cuse_ioctl (fuse_req_t req, int cmd, void *arg,
         fuse_reply_ioctl_retry (req, NULL, 0, &iov, 1);
       } else {
         trinity_cuse_stat_app val;
-        fuse_reply_ioctl (req, vtable->stat_current_app (ctx, &val), &val,
-                          sizeof (val));
+        fuse_reply_ioctl (req, vtable->stat_current_app (ctx, &val), &val, sizeof (val));
       }
       break;
     case TRINITY_IOCTL_STAT_APPS:
@@ -243,8 +237,7 @@ trinity_cuse_ioctl (fuse_req_t req, int cmd, void *arg,
         fuse_reply_ioctl_retry (req, NULL, 0, &iov, 1);
       } else {
         trinity_cuse_stat_apps val;
-        fuse_reply_ioctl (req, vtable->stat_apps (ctx, &val), &val,
-                          sizeof (val));
+        fuse_reply_ioctl (req, vtable->stat_apps (ctx, &val), &val, sizeof (val));
       }
       break;
     case TRINITY_IOCTL_STAT_REQS:
@@ -252,11 +245,10 @@ trinity_cuse_ioctl (fuse_req_t req, int cmd, void *arg,
         struct iovec iov = {arg, sizeof (trinity_cuse_stat_reqs)};
         fuse_reply_ioctl_retry (req, &iov, 1, &iov, 1);
       } else {
-        const trinity_cuse_stat_reqs *in_val =
-            static_cast<const trinity_cuse_stat_reqs *> (in_buf);
+        const trinity_cuse_stat_reqs *in_val = static_cast<const trinity_cuse_stat_reqs *> (in_buf);
         trinity_cuse_stat_reqs out_val;
-        fuse_reply_ioctl (req, vtable->stat_reqs (ctx, in_val, &out_val),
-                          &out_val, sizeof (out_val));
+        fuse_reply_ioctl (req, vtable->stat_reqs (ctx, in_val, &out_val), &out_val,
+                          sizeof (out_val));
       }
       break;
     case TRINITY_IOCTL_GET_PROFILE_META:
@@ -267,8 +259,8 @@ trinity_cuse_ioctl (fuse_req_t req, int cmd, void *arg,
         const trinity_cuse_profile_meta *in_val =
             static_cast<const trinity_cuse_profile_meta *> (in_buf);
         trinity_cuse_profile_meta out_val;
-        fuse_reply_ioctl (req, vtable->get_profile_meta (ctx, in_val, &out_val),
-                          &out_val, sizeof (out_val));
+        fuse_reply_ioctl (req, vtable->get_profile_meta (ctx, in_val, &out_val), &out_val,
+                          sizeof (out_val));
       }
       break;
     case TRINITY_IOCTL_GET_PROFILE_BUFF: {
@@ -328,14 +320,13 @@ typedef struct {
 enum { KEY_HELP };
 
 /** @brief The definitions of available options */
-static const struct fuse_opt trinity_cuse_opts[] = {
-    TRINITY_OPT ("-M %u", major),
-    TRINITY_OPT ("--maj=%u", major),
-    TRINITY_OPT ("-m %u", minor),
-    TRINITY_OPT ("--min=%u", minor),
-    FUSE_OPT_KEY ("-h", KEY_HELP),
-    FUSE_OPT_KEY ("--help", KEY_HELP),
-    FUSE_OPT_END};
+static const struct fuse_opt trinity_cuse_opts[] = {TRINITY_OPT ("-M %u", major),
+                                                    TRINITY_OPT ("--maj=%u", major),
+                                                    TRINITY_OPT ("-m %u", minor),
+                                                    TRINITY_OPT ("--min=%u", minor),
+                                                    FUSE_OPT_KEY ("-h", KEY_HELP),
+                                                    FUSE_OPT_KEY ("--help", KEY_HELP),
+                                                    FUSE_OPT_END};
 
 /** @brief Print the help message */
 static void
@@ -352,8 +343,7 @@ print_help_message () {
 
 /** @brief Parse the given arguments */
 static int
-trinity_cuse_parse_args (void *data, const char *arg, int key,
-                         struct fuse_args *outargs) {
+trinity_cuse_parse_args (void *data, const char *arg, int key, struct fuse_args *outargs) {
   trinity_cuse_param *param = (trinity_cuse_param *) data;
 
   (void) outargs;
@@ -373,18 +363,17 @@ trinity_cuse_parse_args (void *data, const char *arg, int key,
 }
 
 /** @brief trinity cuse driver's lowlevel ops */
-static const struct cuse_lowlevel_ops trinity_cuse_clop = {
-    .init = nullptr,
-    .init_done = nullptr,
-    .destroy = nullptr,
-    .open = trinity_cuse_open,
-    .read = nullptr,
-    .write = nullptr,
-    .flush = nullptr,
-    .release = trinity_cuse_release,
-    .fsync = nullptr,
-    .ioctl = trinity_cuse_ioctl,
-    .poll = nullptr};
+static const struct cuse_lowlevel_ops trinity_cuse_clop = {.init = nullptr,
+                                                           .init_done = nullptr,
+                                                           .destroy = nullptr,
+                                                           .open = trinity_cuse_open,
+                                                           .read = nullptr,
+                                                           .write = nullptr,
+                                                           .flush = nullptr,
+                                                           .release = trinity_cuse_release,
+                                                           .fsync = nullptr,
+                                                           .ioctl = trinity_cuse_ioctl,
+                                                           .poll = nullptr};
 
 /**
  * @brief main routine of trinity-cuse
@@ -400,8 +389,7 @@ main (int argc, char **argv) {
     return -EPERM;
   }
 
-  if (fuse_opt_parse (&args, &param, trinity_cuse_opts,
-                      trinity_cuse_parse_args)) {
+  if (fuse_opt_parse (&args, &param, trinity_cuse_opts, trinity_cuse_parse_args)) {
     std::cerr << "[Error] Failed to parse options\n";
     return -EINVAL;
   }
@@ -454,7 +442,6 @@ main (int argc, char **argv) {
     ci.dev_info_argv = dev_info_argv;
     ci.flags = CUSE_UNRESTRICTED_IOCTL;
 
-    return cuse_lowlevel_main (args.argc, args.argv, &ci, &trinity_cuse_clop,
-                               NULL);
+    return cuse_lowlevel_main (args.argc, args.argv, &ci, &trinity_cuse_clop, NULL);
   }
 }
index e25e4f2..5636dd2 100644 (file)
@@ -56,11 +56,9 @@ typedef struct {
   /* Device Control */
   int (*hwmem_alloc) (trinity_cuse_context *, const trinity_cuse_hwmem *);
   int (*hwmem_dealloc) (trinity_cuse_context *, const trinity_cuse_hwmem *);
-  int (*register_model) (trinity_cuse_context *, const trinity_cuse_model *,
-                         trinity_cuse_model *);
+  int (*register_model) (trinity_cuse_context *, const trinity_cuse_model *, trinity_cuse_model *);
   int (*deregister_model) (trinity_cuse_context *, const uint64_t);
-  int (*run_input) (trinity_cuse_context *, const trinity_cuse_input *,
-                    trinity_cuse_input *);
+  int (*run_input) (trinity_cuse_context *, const trinity_cuse_input *, trinity_cuse_input *);
   int (*stop_requests) (trinity_cuse_context *);
   int (*stop_request) (trinity_cuse_context *, const int);
   /* Device Statistics/Profile */
@@ -68,11 +66,9 @@ typedef struct {
   int (*stat_apps) (trinity_cuse_context *, trinity_cuse_stat_apps *);
   int (*stat_reqs) (trinity_cuse_context *, const trinity_cuse_stat_reqs *,
                     trinity_cuse_stat_reqs *);
-  int (*get_profile_meta) (trinity_cuse_context *,
-                           const trinity_cuse_profile_meta *,
+  int (*get_profile_meta) (trinity_cuse_context *, const trinity_cuse_profile_meta *,
                            trinity_cuse_profile_meta *);
-  int (*get_profile_buff) (trinity_cuse_context *,
-                           const trinity_cuse_profile_buff *,
+  int (*get_profile_buff) (trinity_cuse_context *, const trinity_cuse_profile_buff *,
                            trinity_cuse_profile_buff *, void *);
 } trinity_cuse_ioctl_vtable;
 
index 1718061..f6a5518 100644 (file)
@@ -126,8 +126,7 @@ TrinitySMI::parse_device_node (dev_type &type, int &dev_id) {
     type = NPUCOND_TRIV2_CONN_SOCIP;
 
   if (dev_id < 0 || type == NPUCOND_CONN_UNKNOWN) {
-    ss_ << "| Invalid device node provided: " << left << setw (29) << node_
-        << "|\n";
+    ss_ << "| Invalid device node provided: " << left << setw (29) << node_ << "|\n";
     ss_ << "+------------------------------------------------------------+\n";
 
     return false;
@@ -146,8 +145,7 @@ TrinitySMI::parse_app_id (int &app_id) {
   app_id = strtol (nptr, &endptr, 10);
 
   if (errno != 0 || nptr == endptr) {
-    ss_ << "| Invalid app id provided: " << left << setw (34) << app_id_
-        << "|\n";
+    ss_ << "| Invalid app id provided: " << left << setw (34) << app_id_ << "|\n";
     ss_ << "+------------------------------------------------------------+\n";
 
     return false;
@@ -540,8 +538,7 @@ TrinitySMI::check_arguments (int argc, char **argv) {
 
   optind = 0;
   opterr = 0;
-  while ((c = getopt_long (argc, argv, "hd:a:i:", longopts, (int *) 0)) !=
-         EOF) {
+  while ((c = getopt_long (argc, argv, "hd:a:i:", longopts, (int *) 0)) != EOF) {
     switch (c) {
       case 'd':
         set_device (optarg);
@@ -560,8 +557,7 @@ TrinitySMI::check_arguments (int argc, char **argv) {
         else if (optopt == 'i')
           help_msg_ = "\nOption '-i' requires an extra argument\n";
         else
-          help_msg_ =
-              "\nUnknown flag detected: " + to_string ((char) optopt) + "\n";
+          help_msg_ = "\nUnknown flag detected: " + to_string ((char) optopt) + "\n";
         // no-break
       case 'h':
         help_only_ = true;