/** alias */
#define DEVICETYPE_TRIV DEVICETYPE_NPU
#define DEVICETYPE_TRIA DEVICETYPE_ASR
-#define DEVICETYPE_TRIV2 (0x30000) /** VD/SR-NPU 2020 */
+#define DEVICETYPE_TRIV2 (0x40000) /** VD/SR-NPU 2020 */
#define DEVICETYPE_MASK (0xFFFF0000)
int getNPU_driverAPILevel (npudev_h dev, uint32_t *level);
/**
+ * @brief Get the TOPS of the opened NPU device
+ * @param[in] dev the NPU device handle
+ * @param[out] tops npu tops
+ * @return 0 if no error, otherwise a negative errno
+ * @note this does not support for emulated devices
+ */
+int getNPU_tops (npudev_h dev, uint32_t *tops);
+
+/**
* @brief Get metadata for NPU model
* @param[in] model The path of model binary file
* @param[in] need_extra whether you want to extract the extra data in metadata
}
/**
+ * @brief Get the TOPS of the opened NPU device
+ * @param[in] dev the NPU device handle
+ * @param[out] tops npu tops
+ * @return 0 if no error, otherwise a negative errno
+ * @note this does not support for emulated devices
+ */
+int getNPU_tops (npudev_h dev, uint32_t *tops)
+{
+ INIT_HOST_HANDLER (host_handler, dev);
+
+ if (tops == nullptr)
+ return -EINVAL;
+
+ return host_handler->getTops (tops);
+}
+
+/**
* @brief Get the profile information from NPU
* @param[in] dev The NPU device handle
* @param[in] task_id The identifier for each inference
}
/**
+ * @brief Get the TOPS of the opened NPU device
+ * @param[in] dev the NPU device handle
+ * @param[out] tops npu tops
+ * @return 0 if no error, otherwise a negative errno
+ * @note this does not support for emulated devices
+ */
+int
+HostHandler::getTops (uint32_t *tops)
+{
+ const DriverAPI * api = device_->getDriverAPI ();
+ assert (api != nullptr);
+
+ return api->getTops (tops);
+}
+
+/**
* @brief Set the data layout for input/output tensors
* @param[in] modelid The ID of model whose layouts are set
* @param[in] in the layout/type info for input tensors
int getProfile (int run_id, npu_profile *profile);
int getAPILevel (uint32_t *level);
+ int getTops (uint32_t *tops);
int setDataInfo (uint32_t modelid, tensors_data_info *in, tensors_data_info *out);
int setConstraint (uint32_t modelid, npuConstraint constraint);
/** @brief open the device and set device fd */
virtual int open () { return -ENODEV; }
virtual int getAPILevel (uint32_t *level) const { return -EPERM; }
+ virtual int getTops (uint32_t *tops) const { return -EPERM; }
virtual int checkSanity () { return 0; }
int open ();
int checkSanity ();
int getAPILevel (uint32_t *level) const;
+ int getTops (uint32_t *tops) const;
device_state_t isReady () const;
uint32_t numRequests () const;
int open ();
int checkSanity ();
int getAPILevel (uint32_t *level) const;
+ int getTops (uint32_t *tops) const;
device_state_t isReady () const;
uint32_t numRequests () const;
#include <npubinfmt.h>
#include <ne-conf.h>
-#define MAX_EMUL_DEVICES (100)
+#define MAX_EMUL_DEVICES (3)
#define ENV_PREFIX_SHARE "NE_PREFIX_SHARE"
#define DEFAULT_PREFIX_SHARE "/opt/trinity/share"
return 0;
}
+
+/**
+ * @brief get TOPS from the driver
+ * @param[out] tops npu tops
+ * @return 0 if no error. otherwise a negative errno
+ */
+int
+TrinityVisionAPI::getTops (uint32_t *tops) const
+{
+ int ret;
+
+ if (!this->initialized())
+ return -EPERM;
+
+ ret = ioctl (this->getDeviceFD (), TRINITY_IOCTL_GET_TOPS, tops);
+ if (ret != 0)
+ return -errno;
+
+ return ret;
+}
model_tops = NPU_VERSION_TOPS(npu_version);
if (model_tops != 0) {
- ret = ioctl (this->getDeviceFD (), TRINITY_IOCTL_GET_TOPS,
- &device_tops);
+ ret = getTops (&device_tops);
if (ret != 0)
- return -errno;
+ return ret;
if (model_tops != device_tops)
return -EINVAL;
return 0;
}
+
+/**
+ * @brief get TOPS from the driver
+ * @param[out] tops npu tops
+ * @return 0 if no error. otherwise a negative errno
+ */
+int
+TrinityVision2API::getTops (uint32_t *tops) const
+{
+ int ret;
+
+ if (!this->initialized())
+ return -EPERM;
+
+ ret = ioctl (this->getDeviceFD (), TRINITY_IOCTL_GET_TOPS, tops);
+ if (ret != 0)
+ return -errno;
+
+ return ret;
+}