API for Input/Output Tensor information (#6153)
author이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Mon, 12 Aug 2019 02:20:32 +0000 (11:20 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 12 Aug 2019 02:20:32 +0000 (11:20 +0900)
* API for Input/Output Tensor information

- Add nnfw_tensor_info
- input/output size getter

Signed-off-by: Chunseok Lee <chunseok.lee@samsung.com>
* Fix typo, tensor_info -> tensorinfo

runtimes/include/nnfw.h

index d3a9ba7..2a1b22d 100644 (file)
@@ -46,6 +46,15 @@ typedef enum {
   NNFW_STATUS_ERROR = 1,
 } NNFW_STATUS;
 
+/**
+ * tensor_info
+ */
+struct nnfw_tensorinfo {
+  NNFW_TYPE dtype;
+  int rank;
+  int dims[6]; // MAX rank is 6
+}
+
 /*
  * Create a new session instance
  *
@@ -119,6 +128,48 @@ NNFW_STATUS nnfw_set_input(nnfw_session *session, int index, NNFW_TYPE type, con
 NNFW_STATUS nnfw_set_output(nnfw_session *session, int index, NNFW_TYPE type, void *buffer,
                             size_t length);
 
+/*
+ * Get the number of inputs
+ *
+ * @param[in] session session from input information is to be extracted
+ * @param[out] number variable which the number of inputs is put into
+ *
+ * @return NNFW_STATUS_NO_ERROR if successful
+ */
+NNFW_STATUS nnfw_input_size(nnfw_session *session, int index, int *number);
+
+/*
+ * Get the number of outputs
+ *
+ * @param[in] session session from output information is to be extracted
+ * @param[out] number variable which the number of outputs is put into
+ *
+ * @return NNFW_STATUS_NO_ERROR if successful
+ */
+NNFW_STATUS nnfw_output_size(nnfw_session *session, int *number);
+
+/*
+ * Get i-th input tensor info
+ *
+ * @param[in] session session from input information is to be extracted
+ * @param[in] index index of input
+ * @param[out] tensor_info nnfw_tensor_info
+ *
+ * @return NNFW_STATUS_NO_ERROR if successful
+ */
+NNFW_STATUS nnfw_input_tensorinfo(nnfw_session *session, int index, nnfw_tensorinfo *tensor_info);
+
+/*
+ * Get i-th output tensor info
+ *
+ * @param[in] session session from output information is to be extracted
+ * @param[in] index index of output
+ * @param[out] tensor_info nnfw_tensor_info
+ *
+ * @return NNFW_STATUS_NO_ERROR if successful
+ */
+NNFW_STATUS nnfw_output_tensorinfo(nnfw_session *session, int index, nnfw_tensorinfo *tensor_info);
+
 #ifdef __cplusplus
 }
 #endif