From 1cb7ac1da2b99a89ea74e741e7fdf6bc221dc1ff Mon Sep 17 00:00:00 2001 From: TE-YongweiSun Date: Wed, 30 Mar 2022 13:29:03 +0900 Subject: [PATCH] feat: Sync api level version from nnabla --- VERSION.txt | 4 ++-- build-tools/code-generator/functions.yaml | 17 +++++++++++++++++ doc/SUPPORT_STATUS.md | 5 +++-- include/nnablart/config.h | 5 +++++ include/nnablart/functions.h | 19 +++++++++++++++++++ include/nnablart/network.h | 18 ++++++++++++++++-- src/functions/implements/unimplemented.c | 18 +++++++++++++++++- src/nnablart/dump_function.c | 7 +++++++ src/runtime/function_context.c | 13 +++++++++++++ 9 files changed, 99 insertions(+), 7 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 5827154..20b86ef 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1,5 +1,5 @@ -NNABLA_VERSION: 1.26.0.dev1 +NNABLA_VERSION: 1.27.0.dev1 C_RUNTIME_VERSION: 1.2.0.dev1_c1 NNB_MINIMUM_VERSION: 2 NNB_VERSION: 3 -API_LEVEL: 40 +API_LEVEL: 41 diff --git a/build-tools/code-generator/functions.yaml b/build-tools/code-generator/functions.yaml index e19d2c7..ec07ad5 100644 --- a/build-tools/code-generator/functions.yaml +++ b/build-tools/code-generator/functions.yaml @@ -2968,6 +2968,23 @@ Array Manipulation: id: 319 func_type: - ALL + BatchCholesky: + snake_name: batch_cholesky + inputs: + x: {} + arguments: + upper: + type: bool + default: 'False' + outputs: + y: {} + c_runtime: not support + function_ids: + B: 347 + uniq_name: BatchCholesky_B + id: 347 + func_type: + - ALL Assign: snake_name: assign inputs: diff --git a/doc/SUPPORT_STATUS.md b/doc/SUPPORT_STATUS.md index 926cf78..c0d1fe1 100644 --- a/doc/SUPPORT_STATUS.md +++ b/doc/SUPPORT_STATUS.md @@ -18,7 +18,7 @@ # Implement status -Total 62/216 +Total 62/217 ## Neural Network Layer @@ -195,7 +195,7 @@ Count 6/23 | ATanh | no | - | - | ## Array Manipulation -Count 11/30 +Count 11/31 | Function | Available | float | generic | |------------------------------|--------------|--------------|--------------| @@ -219,6 +219,7 @@ Count 11/30 | BatchDet | no | - | - | | BatchInv | no | - | - | | BatchLogdet | no | - | - | +| BatchCholesky | no | - | - | | Assign | no | - | - | | Gather | no | - | - | | GatherNd | no | - | - | diff --git a/include/nnablart/config.h b/include/nnablart/config.h index 9309161..49292db 100644 --- a/include/nnablart/config.h +++ b/include/nnablart/config.h @@ -108,6 +108,11 @@ #define CONFIG_AVERAGEPOOLING_FIXED8 1 #define CONFIG_AVERAGEPOOLING_FLOAT32 1 #define CONFIG_AVERAGEPOOLING_GENERIC 1 +#define CONFIG_BATCHCHOLESKY 1 +#define CONFIG_BATCHCHOLESKY_FIXED16 1 +#define CONFIG_BATCHCHOLESKY_FIXED8 1 +#define CONFIG_BATCHCHOLESKY_FLOAT32 1 +#define CONFIG_BATCHCHOLESKY_GENERIC 1 #define CONFIG_BATCHDET 1 #define CONFIG_BATCHDET_FIXED16 1 #define CONFIG_BATCHDET_FIXED8 1 diff --git a/include/nnablart/functions.h b/include/nnablart/functions.h index 6d70150..a0de039 100644 --- a/include/nnablart/functions.h +++ b/include/nnablart/functions.h @@ -2861,6 +2861,25 @@ rt_function_error_t free_batch_logdet_local_context(rt_function_t *f); rt_function_error_t exec_batch_logdet(rt_function_t *f); /// @} +/// @defgroup BatchCholesky BatchCholesky +/// @{ + +/// Local context for BatchCholesky +typedef struct { + uint8_t upper; ///< bool + void *data; ///< General purpose data area +} batch_cholesky_local_context_t; + +/// Allocate BatchCholesky local context +rt_function_error_t allocate_batch_cholesky_local_context(rt_function_t *f); + +/// Free BatchCholesky local context +rt_function_error_t free_batch_cholesky_local_context(rt_function_t *f); + +/// Exec BatchCholesky +rt_function_error_t exec_batch_cholesky(rt_function_t *f); +/// @} + /// @defgroup Assign Assign /// @{ diff --git a/include/nnablart/network.h b/include/nnablart/network.h index 02badcd..19f4cf9 100644 --- a/include/nnablart/network.h +++ b/include/nnablart/network.h @@ -25,11 +25,11 @@ extern "C" { #include // for fixed bit length integer type #include // for size_t -#define NN_NNABLA_VERSION ("1.26.0.dev1") +#define NN_NNABLA_VERSION ("1.27.0.dev1") #define NN_C_RUNTIME_VERSION ("1.2.0.dev1_c1") #define NN_BINARY_FORMAT_MINIMUM_VERSION (2) #define NN_BINARY_FORMAT_VERSION (3) -#define NN_API_LEVEL (40) +#define NN_API_LEVEL (41) #define NN_API_LEVEL_MAX (5000) //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -256,6 +256,7 @@ typedef enum { NN_FUNCTION_BATCH_DET = 276, ///< BatchDet NN_FUNCTION_BATCH_INV = 275, ///< BatchInv NN_FUNCTION_BATCH_LOGDET = 319, ///< BatchLogdet + NN_FUNCTION_BATCH_CHOLESKY = 347, ///< BatchCholesky NN_FUNCTION_ASSIGN = 248, ///< Assign NN_FUNCTION_GATHER_0 = 302, ///< Recent version of Gather has arg [iiI] NN_FUNCTION_GATHER = 303, ///< Gather @@ -2361,6 +2362,19 @@ typedef struct { /// @} +/// @brief BatchCholesky function. +/// @{ +typedef struct { + nn_function_type_t type : 16; ///< Common: type of function. + nn_function_implement_t impl : 16; ///< Common: function implementation. + nn_list_t inputs; ///< Common: List of input variables. + nn_list_t outputs; ///< Common: List of output variables. + // End of common part. + uint8_t upper; ///< Original type is [bool] +} nn_function_batch_cholesky_t; + +/// @} + /// @brief Assign function. /// @{ typedef struct { diff --git a/src/functions/implements/unimplemented.c b/src/functions/implements/unimplemented.c index 024bc0f..882a9ee 100644 --- a/src/functions/implements/unimplemented.c +++ b/src/functions/implements/unimplemented.c @@ -1757,6 +1757,22 @@ rt_function_error_t exec_batch_logdet(rt_function_t *f) { } #endif /* CONFIG_BATCHLOGDET */ +// BatchtCholesky +#ifdef CONFIG_BATCHCHOLESKY +rt_function_error_t allocate_batch_cholesky_local_context(rt_function_t *f) { + f->exec_func = exec_batch_cholesky; + return RT_FUNCTION_ERROR_UNIMPLEMENTED; +} + +rt_function_error_t free_batch_cholesky_local_context(rt_function_t *f) { + return RT_FUNCTION_ERROR_UNIMPLEMENTED; +} + +rt_function_error_t exec_batch_cholesky(rt_function_t *f) { + return RT_FUNCTION_ERROR_UNIMPLEMENTED; +} +#endif /* CONFIG_BATCHCHOLESKY */ + //////////////////////////////////////////////////////////////////////////////// // Stochasticity //////////////////////////////////////////////////////////////////////////////// @@ -2563,4 +2579,4 @@ rt_function_error_t free_patch_correlation_local_context(rt_function_t *f) { rt_function_error_t exec_patch_correlation(rt_function_t *f) { return RT_FUNCTION_ERROR_UNIMPLEMENTED; } -#endif /* CONFIG_PATCHCORRELATION */ \ No newline at end of file +#endif /* CONFIG_PATCHCORRELATION */ diff --git a/src/nnablart/dump_function.c b/src/nnablart/dump_function.c index 99273a7..2cb3795 100644 --- a/src/nnablart/dump_function.c +++ b/src/nnablart/dump_function.c @@ -484,6 +484,9 @@ void dump_function(nn_network_t *net, nn_function_t *func) { case NN_FUNCTION_BATCH_LOGDET: { // BatchLogdet printf("NNB: Function type: BatchLogdet(319)\n"); } break; + case NN_FUNCTION_BATCH_CHOLESKY: { // BatchCholesky + printf("NNB: Function type: BatchCholesky(347)\n"); + } break; case NN_FUNCTION_ASSIGN: { // Assign printf("NNB: Function type: Assign(248)\n"); } break; @@ -1621,6 +1624,10 @@ void dump_function(nn_network_t *net, nn_function_t *func) { } break; case NN_FUNCTION_BATCH_LOGDET: { // BatchLogdet } break; + case NN_FUNCTION_BATCH_CHOLESKY: { // BatchCholesky + nn_function_batch_cholesky_t *f = (nn_function_batch_cholesky_t *)func; + printf("NNB: Function argument upper: %d\n", f->upper); + } break; case NN_FUNCTION_ASSIGN: { // Assign } break; case NN_FUNCTION_GATHER: { // Gather diff --git a/src/runtime/function_context.c b/src/runtime/function_context.c index 847b73a..a69df23 100644 --- a/src/runtime/function_context.c +++ b/src/runtime/function_context.c @@ -2085,6 +2085,19 @@ void allocate_function_context(nn_network_t *n, nn_function_t *function, } break; #endif +#ifdef CONFIG_BATCHCHOLESKY + case NN_FUNCTION_BATCH_CHOLESKY: { // BatchCholesky + function_context->func.free_local_context_func = + free_batch_cholesky_local_context; + nn_function_batch_cholesky_t *f = (nn_function_batch_cholesky_t *)function; + batch_cholesky_local_context_t *ctx = + rt_malloc_func(sizeof(batch_cholesky_local_context_t)); + ctx->upper = f->upper; + function_context->func.local_context = ctx; + allocate_batch_cholesky_local_context(&function_context->func); + } break; +#endif + #ifdef CONFIG_ASSIGN case NN_FUNCTION_ASSIGN: { // Assign function_context->func.free_local_context_func = free_assign_local_context;