[custom op] api addition (#6219)
authorVladimir Plazun/AI Tools Lab /SRR/Engineer/삼성전자 <v.plazun@samsung.com>
Wed, 14 Aug 2019 02:05:49 +0000 (05:05 +0300)
committer이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Wed, 14 Aug 2019 02:05:49 +0000 (11:05 +0900)
* [custom op] Api addition to support custom op registration

Add nnfw_dev.h header with types required to define custom operations

Signed-off-by: Vladimir Plazun <v.plazun@samsung.com>
* Roll back changes to nnfw.h, add separate header for custom kernel development

* format fix

* use limited dim count for typeinfo struct

* remove _t suffix for types

* fix missed _t suffixes for function types

runtimes/include/nnfw_dev.h [new file with mode: 0644]

diff --git a/runtimes/include/nnfw_dev.h b/runtimes/include/nnfw_dev.h
new file mode 100644 (file)
index 0000000..5e46adc
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NNFW_DEV_H__
+#define __NNFW_DEV_H__
+
+#include "nnfw.h"
+
+// Used for custom kernel development
+
+/*
+ * operand type, used only for custom operations
+ */
+typedef struct
+{
+  nnfw_tensorinfo type;
+  void *allocation;
+} nnfw_operand;
+
+/*
+ * Used as input to custom operation eval function
+ */
+typedef struct
+{
+  size ninputs;
+  nnfw_operand *inputs;
+
+  size noutputs;
+  nnfw_operand *outputs;
+} nnfw_custom_kernel_params;
+
+/*
+ * Custom kernel evaluation function
+ *
+ * param[in] params custom operation parameters
+ * param[in] userdata pointer to user-specified buffer( kernel instance specific )
+ */
+typedef void (*nnfw_custom_eval)(nnfw_custom_kernel_params *params, void *userdata);
+
+/*
+ * custom operation registration info
+ */
+typedef struct
+{
+  nnfw_custom_eval eval_function;
+} custom_kernel_registration_info;
+
+#endif // __NNFW_DEV_H__