react-native-vision-camera-spoof-detector 1.4.1 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -46
- package/VisionCameraSpoofDetector.podspec +12 -2
- package/android/build.gradle +0 -13
- package/android/src/main/java/com/faceantispoof/FaceAntiSpoofPackage.kt +1 -3
- package/android/src/main/java/com/faceantispoof/FaceAntiSpoofingAdvanced.kt +78 -925
- package/android/src/main/java/com/lengdev/livenessdetector/LivenessDetector.kt +228 -0
- package/android/src/main/java/com/margelo/nitro/camera/spoofdetector/HybridSpoofDetectorOutput.kt +17 -31
- package/android/src/main/jniLibs/arm64-v8a/libliveness_detector.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libliveness_detector.so +0 -0
- package/index.d.ts +2 -9
- package/index.js +6 -6
- package/ios/FaceAntiSpoofModule.m +3 -2
- package/ios/HybridSpoofDetectorOutput.swift +73 -158
- package/ios/NcnnLivenessDetector.h +24 -0
- package/ios/NcnnLivenessDetector.mm +248 -0
- package/ios/ncnn.xcframework/Info.plist +27 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/allocator.h +433 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/benchmark.h +28 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/blob.h +33 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/c_api.h +401 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/command.h +111 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/cpu.h +177 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/datareader.h +111 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/expression.h +17 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/gpu.h +566 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/layer.h +212 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/layer_shader_type.h +18 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/layer_shader_type_enum.h +5 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/layer_type.h +19 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/layer_type_enum.h +115 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/mat.h +1868 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/modelbin.h +69 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/ncnn_export.h +43 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/net.h +252 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/option.h +151 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/paramdict.h +66 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/pipeline.h +101 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/pipelinecache.h +71 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/platform.h +372 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/simplemath.h +98 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/simpleocv.h +492 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/simpleomp.h +42 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/simplestl.h +598 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/simplevk.h +2196 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/vulkan_header_fix.h +1674 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Resources/Info.plist +18 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/allocator.h +433 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/benchmark.h +28 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/blob.h +33 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/c_api.h +401 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/command.h +111 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/cpu.h +177 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/datareader.h +111 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/expression.h +17 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/gpu.h +566 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/layer.h +212 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/layer_shader_type.h +18 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/layer_shader_type_enum.h +5 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/layer_type.h +19 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/layer_type_enum.h +115 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/mat.h +1868 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/modelbin.h +69 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/ncnn_export.h +43 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/net.h +252 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/option.h +151 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/paramdict.h +66 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/pipeline.h +101 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/pipelinecache.h +71 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/platform.h +372 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/simplemath.h +98 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/simpleocv.h +492 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/simpleomp.h +42 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/simplestl.h +598 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/simplevk.h +2196 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/vulkan_header_fix.h +1674 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Resources/Info.plist +18 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/ncnn +0 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/allocator.h +433 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/benchmark.h +28 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/blob.h +33 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/c_api.h +401 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/command.h +111 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/cpu.h +177 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/datareader.h +111 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/expression.h +17 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/gpu.h +566 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/layer.h +212 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/layer_shader_type.h +18 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/layer_shader_type_enum.h +5 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/layer_type.h +19 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/layer_type_enum.h +115 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/mat.h +1868 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/modelbin.h +69 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/ncnn_export.h +43 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/net.h +252 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/option.h +151 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/paramdict.h +66 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/pipeline.h +101 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/pipelinecache.h +71 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/platform.h +372 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/simplemath.h +98 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/simpleocv.h +492 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/simpleomp.h +42 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/simplestl.h +598 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/simplevk.h +2196 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/vulkan_header_fix.h +1674 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Resources/Info.plist +18 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/ncnn +0 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/ncnn +0 -0
- package/ios/openmp.xcframework/Info.plist +27 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Headers/omp.h +521 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Headers/ompx.h +165 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Resources/Info.plist +18 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/A/Headers/omp.h +521 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/A/Headers/ompx.h +165 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/A/Resources/Info.plist +18 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/A/openmp +0 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/Current/Headers/omp.h +521 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/Current/Headers/ompx.h +165 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/Current/Resources/Info.plist +18 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/Current/openmp +0 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/openmp +0 -0
- package/lib/assets/live/config.json +1 -0
- package/lib/assets/live/model_1.bin +0 -0
- package/lib/assets/live/model_1.param +214 -0
- package/lib/assets/live/model_2.bin +0 -0
- package/lib/assets/live/model_2.param +238 -0
- package/nitrogen/generated/android/c++/JSpoofDetectorOutputOptions.hpp +1 -9
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/SpoofDetectorOutputOptions.kt +4 -14
- package/nitrogen/generated/ios/swift/SpoofDetectorOutputOptions.swift +1 -37
- package/nitrogen/generated/shared/c++/SpoofDetectorOutputOptions.hpp +1 -9
- package/package.json +1 -2
- package/src/specs/SpoofDetectorFactory.nitro.ts +0 -2
- package/android/fix-prefab.gradle +0 -4
- package/android/src/main/java/com/faceantispoof/AcceleratorConfig.kt +0 -97
- package/android/src/main/java/com/faceantispoof/FaceAntiSpoofModule.kt +0 -242
- package/android/src/main/res/values/strings.xml +0 -3
- package/lib/assets/FaceAntiSpoofing.tflite +0 -0
- package/lib/assets/model_spec.json +0 -16
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/* Copyright 2020 Tencent
|
|
2
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#ifndef NCNN_C_API_H
|
|
6
|
+
#define NCNN_C_API_H
|
|
7
|
+
|
|
8
|
+
#include "platform.h"
|
|
9
|
+
|
|
10
|
+
#if NCNN_C_API
|
|
11
|
+
|
|
12
|
+
#include <stddef.h>
|
|
13
|
+
|
|
14
|
+
#ifdef __cplusplus
|
|
15
|
+
extern "C" {
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
NCNN_EXPORT const char* ncnn_version(void);
|
|
19
|
+
NCNN_EXPORT int ncnn_version_number(void);
|
|
20
|
+
|
|
21
|
+
/* allocator api */
|
|
22
|
+
typedef struct __ncnn_allocator_t* ncnn_allocator_t;
|
|
23
|
+
struct NCNN_EXPORT __ncnn_allocator_t
|
|
24
|
+
{
|
|
25
|
+
void* pthis;
|
|
26
|
+
|
|
27
|
+
void* (*fast_malloc)(ncnn_allocator_t allocator, size_t size);
|
|
28
|
+
void (*fast_free)(ncnn_allocator_t allocator, void* ptr);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
NCNN_EXPORT ncnn_allocator_t ncnn_allocator_create_pool_allocator(void);
|
|
32
|
+
NCNN_EXPORT ncnn_allocator_t ncnn_allocator_create_unlocked_pool_allocator(void);
|
|
33
|
+
NCNN_EXPORT void ncnn_allocator_destroy(ncnn_allocator_t allocator);
|
|
34
|
+
|
|
35
|
+
/* option api */
|
|
36
|
+
typedef struct __ncnn_option_t* ncnn_option_t;
|
|
37
|
+
|
|
38
|
+
NCNN_EXPORT ncnn_option_t ncnn_option_create(void);
|
|
39
|
+
NCNN_EXPORT void ncnn_option_destroy(ncnn_option_t opt);
|
|
40
|
+
|
|
41
|
+
NCNN_EXPORT int ncnn_option_get_num_threads(const ncnn_option_t opt);
|
|
42
|
+
NCNN_EXPORT void ncnn_option_set_num_threads(ncnn_option_t opt, int num_threads);
|
|
43
|
+
|
|
44
|
+
NCNN_EXPORT void ncnn_option_set_blob_allocator(ncnn_option_t opt, ncnn_allocator_t allocator);
|
|
45
|
+
NCNN_EXPORT void ncnn_option_set_workspace_allocator(ncnn_option_t opt, ncnn_allocator_t allocator);
|
|
46
|
+
|
|
47
|
+
NCNN_EXPORT int ncnn_option_get_use_vulkan_compute(const ncnn_option_t opt);
|
|
48
|
+
NCNN_EXPORT int ncnn_option_get_use_local_pool_allocator(const ncnn_option_t opt);
|
|
49
|
+
NCNN_EXPORT int ncnn_option_get_use_winograd_convolution(const ncnn_option_t opt);
|
|
50
|
+
NCNN_EXPORT int ncnn_option_get_use_sgemm_convolution(const ncnn_option_t opt);
|
|
51
|
+
NCNN_EXPORT int ncnn_option_get_use_packing_layout(const ncnn_option_t opt);
|
|
52
|
+
NCNN_EXPORT int ncnn_option_get_use_fp16_packed(const ncnn_option_t opt);
|
|
53
|
+
NCNN_EXPORT int ncnn_option_get_use_fp16_storage(const ncnn_option_t opt);
|
|
54
|
+
NCNN_EXPORT int ncnn_option_get_use_fp16_arithmetic(const ncnn_option_t opt);
|
|
55
|
+
NCNN_EXPORT int ncnn_option_get_use_int8_packed(const ncnn_option_t opt);
|
|
56
|
+
NCNN_EXPORT int ncnn_option_get_use_int8_storage(const ncnn_option_t opt);
|
|
57
|
+
NCNN_EXPORT int ncnn_option_get_use_int8_arithmetic(const ncnn_option_t opt);
|
|
58
|
+
NCNN_EXPORT int ncnn_option_get_use_bf16_packed(const ncnn_option_t opt);
|
|
59
|
+
NCNN_EXPORT int ncnn_option_get_use_bf16_storage(const ncnn_option_t opt);
|
|
60
|
+
NCNN_EXPORT int ncnn_option_get_use_shader_local_memory(const ncnn_option_t opt);
|
|
61
|
+
NCNN_EXPORT int ncnn_option_get_use_cooperative_matrix(const ncnn_option_t opt);
|
|
62
|
+
|
|
63
|
+
NCNN_EXPORT void ncnn_option_set_use_vulkan_compute(ncnn_option_t opt, int enable);
|
|
64
|
+
NCNN_EXPORT void ncnn_option_set_use_local_pool_allocator(ncnn_option_t opt, int enable);
|
|
65
|
+
NCNN_EXPORT void ncnn_option_set_use_winograd_convolution(ncnn_option_t opt, int enable);
|
|
66
|
+
NCNN_EXPORT void ncnn_option_set_use_sgemm_convolution(ncnn_option_t opt, int enable);
|
|
67
|
+
NCNN_EXPORT void ncnn_option_set_use_packing_layout(ncnn_option_t opt, int enable);
|
|
68
|
+
NCNN_EXPORT void ncnn_option_set_use_fp16_packed(ncnn_option_t opt, int enable);
|
|
69
|
+
NCNN_EXPORT void ncnn_option_set_use_fp16_storage(ncnn_option_t opt, int enable);
|
|
70
|
+
NCNN_EXPORT void ncnn_option_set_use_fp16_arithmetic(ncnn_option_t opt, int enable);
|
|
71
|
+
NCNN_EXPORT void ncnn_option_set_use_int8_packed(ncnn_option_t opt, int enable);
|
|
72
|
+
NCNN_EXPORT void ncnn_option_set_use_int8_storage(ncnn_option_t opt, int enable);
|
|
73
|
+
NCNN_EXPORT void ncnn_option_set_use_int8_arithmetic(ncnn_option_t opt, int enable);
|
|
74
|
+
NCNN_EXPORT void ncnn_option_set_use_bf16_packed(ncnn_option_t opt, int enable);
|
|
75
|
+
NCNN_EXPORT void ncnn_option_set_use_bf16_storage(ncnn_option_t opt, int enable);
|
|
76
|
+
NCNN_EXPORT void ncnn_option_set_use_shader_local_memory(ncnn_option_t opt, int enable);
|
|
77
|
+
NCNN_EXPORT void ncnn_option_set_use_cooperative_matrix(ncnn_option_t opt, int enable);
|
|
78
|
+
|
|
79
|
+
/* mat api */
|
|
80
|
+
typedef struct __ncnn_mat_t* ncnn_mat_t;
|
|
81
|
+
|
|
82
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create(void);
|
|
83
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_1d(int w, ncnn_allocator_t allocator);
|
|
84
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_2d(int w, int h, ncnn_allocator_t allocator);
|
|
85
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_3d(int w, int h, int c, ncnn_allocator_t allocator);
|
|
86
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_4d(int w, int h, int d, int c, ncnn_allocator_t allocator);
|
|
87
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_external_1d(int w, void* data, ncnn_allocator_t allocator);
|
|
88
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_external_2d(int w, int h, void* data, ncnn_allocator_t allocator);
|
|
89
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_external_3d(int w, int h, int c, void* data, ncnn_allocator_t allocator);
|
|
90
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_external_4d(int w, int h, int d, int c, void* data, ncnn_allocator_t allocator);
|
|
91
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_1d_elem(int w, size_t elemsize, int elempack, ncnn_allocator_t allocator);
|
|
92
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_2d_elem(int w, int h, size_t elemsize, int elempack, ncnn_allocator_t allocator);
|
|
93
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_3d_elem(int w, int h, int c, size_t elemsize, int elempack, ncnn_allocator_t allocator);
|
|
94
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_4d_elem(int w, int h, int d, int c, size_t elemsize, int elempack, ncnn_allocator_t allocator);
|
|
95
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_external_1d_elem(int w, void* data, size_t elemsize, int elempack, ncnn_allocator_t allocator);
|
|
96
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_external_2d_elem(int w, int h, void* data, size_t elemsize, int elempack, ncnn_allocator_t allocator);
|
|
97
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_external_3d_elem(int w, int h, int c, void* data, size_t elemsize, int elempack, ncnn_allocator_t allocator);
|
|
98
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_create_external_4d_elem(int w, int h, int d, int c, void* data, size_t elemsize, int elempack, ncnn_allocator_t allocator);
|
|
99
|
+
NCNN_EXPORT void ncnn_mat_destroy(ncnn_mat_t mat);
|
|
100
|
+
|
|
101
|
+
NCNN_EXPORT void ncnn_mat_fill_float(ncnn_mat_t mat, float v);
|
|
102
|
+
|
|
103
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_clone(const ncnn_mat_t mat, ncnn_allocator_t allocator);
|
|
104
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_reshape_1d(const ncnn_mat_t mat, int w, ncnn_allocator_t allocator);
|
|
105
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_reshape_2d(const ncnn_mat_t mat, int w, int h, ncnn_allocator_t allocator);
|
|
106
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_reshape_3d(const ncnn_mat_t mat, int w, int h, int c, ncnn_allocator_t allocator);
|
|
107
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_reshape_4d(const ncnn_mat_t mat, int w, int h, int d, int c, ncnn_allocator_t allocator);
|
|
108
|
+
|
|
109
|
+
NCNN_EXPORT int ncnn_mat_get_dims(const ncnn_mat_t mat);
|
|
110
|
+
NCNN_EXPORT int ncnn_mat_get_w(const ncnn_mat_t mat);
|
|
111
|
+
NCNN_EXPORT int ncnn_mat_get_h(const ncnn_mat_t mat);
|
|
112
|
+
NCNN_EXPORT int ncnn_mat_get_d(const ncnn_mat_t mat);
|
|
113
|
+
NCNN_EXPORT int ncnn_mat_get_c(const ncnn_mat_t mat);
|
|
114
|
+
NCNN_EXPORT size_t ncnn_mat_get_elemsize(const ncnn_mat_t mat);
|
|
115
|
+
NCNN_EXPORT int ncnn_mat_get_elempack(const ncnn_mat_t mat);
|
|
116
|
+
NCNN_EXPORT size_t ncnn_mat_get_cstep(const ncnn_mat_t mat);
|
|
117
|
+
NCNN_EXPORT void* ncnn_mat_get_data(const ncnn_mat_t mat);
|
|
118
|
+
|
|
119
|
+
NCNN_EXPORT void* ncnn_mat_get_channel_data(const ncnn_mat_t mat, int c);
|
|
120
|
+
|
|
121
|
+
#if NCNN_PIXEL
|
|
122
|
+
|
|
123
|
+
/* mat pixel api */
|
|
124
|
+
#define NCNN_MAT_PIXEL_RGB 1
|
|
125
|
+
#define NCNN_MAT_PIXEL_BGR 2
|
|
126
|
+
#define NCNN_MAT_PIXEL_GRAY 3
|
|
127
|
+
#define NCNN_MAT_PIXEL_RGBA 4
|
|
128
|
+
#define NCNN_MAT_PIXEL_BGRA 5
|
|
129
|
+
#define NCNN_MAT_PIXEL_X2Y(X, Y) (X | (Y << 16))
|
|
130
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_from_pixels(const unsigned char* pixels, int type, int w, int h, int stride, ncnn_allocator_t allocator);
|
|
131
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_from_pixels_resize(const unsigned char* pixels, int type, int w, int h, int stride, int target_width, int target_height, ncnn_allocator_t allocator);
|
|
132
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_from_pixels_roi(const unsigned char* pixels, int type, int w, int h, int stride, int roix, int roiy, int roiw, int roih, ncnn_allocator_t allocator);
|
|
133
|
+
NCNN_EXPORT ncnn_mat_t ncnn_mat_from_pixels_roi_resize(const unsigned char* pixels, int type, int w, int h, int stride, int roix, int roiy, int roiw, int roih, int target_width, int target_height, ncnn_allocator_t allocator);
|
|
134
|
+
NCNN_EXPORT void ncnn_mat_to_pixels(const ncnn_mat_t mat, unsigned char* pixels, int type, int stride);
|
|
135
|
+
NCNN_EXPORT void ncnn_mat_to_pixels_resize(const ncnn_mat_t mat, unsigned char* pixels, int type, int target_width, int target_height, int target_stride);
|
|
136
|
+
|
|
137
|
+
#endif /* NCNN_PIXEL */
|
|
138
|
+
|
|
139
|
+
NCNN_EXPORT void ncnn_mat_substract_mean_normalize(ncnn_mat_t mat, const float* mean_vals, const float* norm_vals);
|
|
140
|
+
|
|
141
|
+
NCNN_EXPORT void ncnn_convert_packing(const ncnn_mat_t src, ncnn_mat_t* dst, int elempack, const ncnn_option_t opt);
|
|
142
|
+
NCNN_EXPORT void ncnn_flatten(const ncnn_mat_t src, ncnn_mat_t* dst, const ncnn_option_t opt);
|
|
143
|
+
|
|
144
|
+
/* blob api */
|
|
145
|
+
typedef struct __ncnn_blob_t* ncnn_blob_t;
|
|
146
|
+
|
|
147
|
+
#if NCNN_STRING
|
|
148
|
+
NCNN_EXPORT const char* ncnn_blob_get_name(const ncnn_blob_t blob);
|
|
149
|
+
#endif /* NCNN_STRING */
|
|
150
|
+
|
|
151
|
+
NCNN_EXPORT int ncnn_blob_get_producer(const ncnn_blob_t blob);
|
|
152
|
+
NCNN_EXPORT int ncnn_blob_get_consumer(const ncnn_blob_t blob);
|
|
153
|
+
|
|
154
|
+
NCNN_EXPORT void ncnn_blob_get_shape(const ncnn_blob_t blob, int* dims, int* w, int* h, int* c);
|
|
155
|
+
|
|
156
|
+
/* paramdict api */
|
|
157
|
+
typedef struct __ncnn_paramdict_t* ncnn_paramdict_t;
|
|
158
|
+
|
|
159
|
+
NCNN_EXPORT ncnn_paramdict_t ncnn_paramdict_create(void);
|
|
160
|
+
NCNN_EXPORT void ncnn_paramdict_destroy(ncnn_paramdict_t pd);
|
|
161
|
+
|
|
162
|
+
NCNN_EXPORT int ncnn_paramdict_get_type(const ncnn_paramdict_t pd, int id);
|
|
163
|
+
|
|
164
|
+
NCNN_EXPORT int ncnn_paramdict_get_int(const ncnn_paramdict_t pd, int id, int def);
|
|
165
|
+
NCNN_EXPORT float ncnn_paramdict_get_float(const ncnn_paramdict_t pd, int id, float def);
|
|
166
|
+
NCNN_EXPORT ncnn_mat_t ncnn_paramdict_get_array(const ncnn_paramdict_t pd, int id, const ncnn_mat_t def);
|
|
167
|
+
|
|
168
|
+
NCNN_EXPORT void ncnn_paramdict_set_int(ncnn_paramdict_t pd, int id, int i);
|
|
169
|
+
NCNN_EXPORT void ncnn_paramdict_set_float(ncnn_paramdict_t pd, int id, float f);
|
|
170
|
+
NCNN_EXPORT void ncnn_paramdict_set_array(ncnn_paramdict_t pd, int id, const ncnn_mat_t v);
|
|
171
|
+
|
|
172
|
+
/* datareader api */
|
|
173
|
+
typedef struct __ncnn_datareader_t* ncnn_datareader_t;
|
|
174
|
+
struct NCNN_EXPORT __ncnn_datareader_t
|
|
175
|
+
{
|
|
176
|
+
void* pthis;
|
|
177
|
+
|
|
178
|
+
#if NCNN_STRING
|
|
179
|
+
int (*scan)(ncnn_datareader_t dr, const char* format, void* p);
|
|
180
|
+
#endif /* NCNN_STRING */
|
|
181
|
+
size_t (*read)(ncnn_datareader_t dr, void* buf, size_t size);
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
NCNN_EXPORT ncnn_datareader_t ncnn_datareader_create(void);
|
|
185
|
+
#if NCNN_STDIO
|
|
186
|
+
NCNN_EXPORT ncnn_datareader_t ncnn_datareader_create_from_stdio(FILE* fp);
|
|
187
|
+
#endif /* NCNN_STDIO */
|
|
188
|
+
NCNN_EXPORT ncnn_datareader_t ncnn_datareader_create_from_memory(const unsigned char** mem);
|
|
189
|
+
NCNN_EXPORT void ncnn_datareader_destroy(ncnn_datareader_t dr);
|
|
190
|
+
|
|
191
|
+
/* modelbin api */
|
|
192
|
+
typedef struct __ncnn_modelbin_t* ncnn_modelbin_t;
|
|
193
|
+
struct NCNN_EXPORT __ncnn_modelbin_t
|
|
194
|
+
{
|
|
195
|
+
void* pthis;
|
|
196
|
+
|
|
197
|
+
ncnn_mat_t (*load_1d)(const ncnn_modelbin_t mb, int w, int type);
|
|
198
|
+
ncnn_mat_t (*load_2d)(const ncnn_modelbin_t mb, int w, int h, int type);
|
|
199
|
+
ncnn_mat_t (*load_3d)(const ncnn_modelbin_t mb, int w, int h, int c, int type);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
NCNN_EXPORT ncnn_modelbin_t ncnn_modelbin_create_from_datareader(const ncnn_datareader_t dr);
|
|
203
|
+
NCNN_EXPORT ncnn_modelbin_t ncnn_modelbin_create_from_mat_array(const ncnn_mat_t* weights, int n);
|
|
204
|
+
NCNN_EXPORT void ncnn_modelbin_destroy(ncnn_modelbin_t mb);
|
|
205
|
+
|
|
206
|
+
/* layer api */
|
|
207
|
+
typedef struct __ncnn_layer_t* ncnn_layer_t;
|
|
208
|
+
struct NCNN_EXPORT __ncnn_layer_t
|
|
209
|
+
{
|
|
210
|
+
void* pthis;
|
|
211
|
+
|
|
212
|
+
int (*load_param)(ncnn_layer_t layer, const ncnn_paramdict_t pd);
|
|
213
|
+
int (*load_model)(ncnn_layer_t layer, const ncnn_modelbin_t mb);
|
|
214
|
+
|
|
215
|
+
int (*create_pipeline)(ncnn_layer_t layer, const ncnn_option_t opt);
|
|
216
|
+
int (*destroy_pipeline)(ncnn_layer_t layer, const ncnn_option_t opt);
|
|
217
|
+
|
|
218
|
+
int (*forward_1)(const ncnn_layer_t layer, const ncnn_mat_t bottom_blob, ncnn_mat_t* top_blob, const ncnn_option_t opt);
|
|
219
|
+
int (*forward_n)(const ncnn_layer_t layer, const ncnn_mat_t* bottom_blobs, int n, ncnn_mat_t* top_blobs, int n2, const ncnn_option_t opt);
|
|
220
|
+
|
|
221
|
+
int (*forward_inplace_1)(const ncnn_layer_t layer, ncnn_mat_t bottom_top_blob, const ncnn_option_t opt);
|
|
222
|
+
int (*forward_inplace_n)(const ncnn_layer_t layer, ncnn_mat_t* bottom_top_blobs, int n, const ncnn_option_t opt);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
NCNN_EXPORT ncnn_layer_t ncnn_layer_create(void);
|
|
226
|
+
NCNN_EXPORT ncnn_layer_t ncnn_layer_create_by_typeindex(int typeindex);
|
|
227
|
+
#if NCNN_STRING
|
|
228
|
+
NCNN_EXPORT ncnn_layer_t ncnn_layer_create_by_type(const char* type);
|
|
229
|
+
NCNN_EXPORT int ncnn_layer_type_to_index(const char* type);
|
|
230
|
+
#endif /* NCNN_STRING */
|
|
231
|
+
NCNN_EXPORT void ncnn_layer_destroy(ncnn_layer_t layer);
|
|
232
|
+
|
|
233
|
+
#if NCNN_STRING
|
|
234
|
+
NCNN_EXPORT const char* ncnn_layer_get_name(const ncnn_layer_t layer);
|
|
235
|
+
#endif /* NCNN_STRING */
|
|
236
|
+
|
|
237
|
+
NCNN_EXPORT int ncnn_layer_get_typeindex(const ncnn_layer_t layer);
|
|
238
|
+
#if NCNN_STRING
|
|
239
|
+
NCNN_EXPORT const char* ncnn_layer_get_type(const ncnn_layer_t layer);
|
|
240
|
+
#endif /* NCNN_STRING */
|
|
241
|
+
|
|
242
|
+
NCNN_EXPORT int ncnn_layer_get_one_blob_only(const ncnn_layer_t layer);
|
|
243
|
+
NCNN_EXPORT int ncnn_layer_get_support_inplace(const ncnn_layer_t layer);
|
|
244
|
+
NCNN_EXPORT int ncnn_layer_get_support_vulkan(const ncnn_layer_t layer);
|
|
245
|
+
NCNN_EXPORT int ncnn_layer_get_support_packing(const ncnn_layer_t layer);
|
|
246
|
+
NCNN_EXPORT int ncnn_layer_get_support_bf16_storage(const ncnn_layer_t layer);
|
|
247
|
+
NCNN_EXPORT int ncnn_layer_get_support_fp16_storage(const ncnn_layer_t layer);
|
|
248
|
+
NCNN_EXPORT int ncnn_layer_get_support_vulkan_packing(const ncnn_layer_t layer);
|
|
249
|
+
NCNN_EXPORT int ncnn_layer_get_support_any_packing(const ncnn_layer_t layer);
|
|
250
|
+
NCNN_EXPORT int ncnn_layer_get_support_vulkan_any_packing(const ncnn_layer_t layer);
|
|
251
|
+
|
|
252
|
+
NCNN_EXPORT void ncnn_layer_set_one_blob_only(ncnn_layer_t layer, int enable);
|
|
253
|
+
NCNN_EXPORT void ncnn_layer_set_support_inplace(ncnn_layer_t layer, int enable);
|
|
254
|
+
NCNN_EXPORT void ncnn_layer_set_support_vulkan(ncnn_layer_t layer, int enable);
|
|
255
|
+
NCNN_EXPORT void ncnn_layer_set_support_packing(ncnn_layer_t layer, int enable);
|
|
256
|
+
NCNN_EXPORT void ncnn_layer_set_support_bf16_storage(ncnn_layer_t layer, int enable);
|
|
257
|
+
NCNN_EXPORT void ncnn_layer_set_support_fp16_storage(ncnn_layer_t layer, int enable);
|
|
258
|
+
NCNN_EXPORT void ncnn_layer_set_support_vulkan_packing(ncnn_layer_t layer, int enable);
|
|
259
|
+
NCNN_EXPORT void ncnn_layer_set_support_any_packing(ncnn_layer_t layer, int enable);
|
|
260
|
+
NCNN_EXPORT void ncnn_layer_set_support_vulkan_any_packing(ncnn_layer_t layer, int enable);
|
|
261
|
+
|
|
262
|
+
NCNN_EXPORT int ncnn_layer_get_bottom_count(const ncnn_layer_t layer);
|
|
263
|
+
NCNN_EXPORT int ncnn_layer_get_bottom(const ncnn_layer_t layer, int i);
|
|
264
|
+
NCNN_EXPORT int ncnn_layer_get_top_count(const ncnn_layer_t layer);
|
|
265
|
+
NCNN_EXPORT int ncnn_layer_get_top(const ncnn_layer_t layer, int i);
|
|
266
|
+
|
|
267
|
+
NCNN_EXPORT void ncnn_blob_get_bottom_shape(const ncnn_layer_t layer, int i, int* dims, int* w, int* h, int* c);
|
|
268
|
+
NCNN_EXPORT void ncnn_blob_get_top_shape(const ncnn_layer_t layer, int i, int* dims, int* w, int* h, int* c);
|
|
269
|
+
|
|
270
|
+
/* layer factory function */
|
|
271
|
+
typedef ncnn_layer_t (*ncnn_layer_creator_t)(void* userdata);
|
|
272
|
+
typedef void (*ncnn_layer_destroyer_t)(ncnn_layer_t layer, void* userdata);
|
|
273
|
+
|
|
274
|
+
typedef struct __ncnn_net_custom_layer_factory_t* ncnn_net_custom_layer_factory_t;
|
|
275
|
+
struct __ncnn_net_custom_layer_factory_t
|
|
276
|
+
{
|
|
277
|
+
ncnn_layer_creator_t creator;
|
|
278
|
+
ncnn_layer_destroyer_t destroyer;
|
|
279
|
+
void* userdata;
|
|
280
|
+
ncnn_net_custom_layer_factory_t next;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
/* net api */
|
|
284
|
+
typedef struct __ncnn_net_t* ncnn_net_t;
|
|
285
|
+
struct __ncnn_net_t
|
|
286
|
+
{
|
|
287
|
+
void* pthis;
|
|
288
|
+
|
|
289
|
+
ncnn_net_custom_layer_factory_t custom_layer_factory;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
NCNN_EXPORT ncnn_net_t ncnn_net_create(void);
|
|
293
|
+
NCNN_EXPORT void ncnn_net_destroy(ncnn_net_t net);
|
|
294
|
+
|
|
295
|
+
NCNN_EXPORT ncnn_option_t ncnn_net_get_option(ncnn_net_t net);
|
|
296
|
+
NCNN_EXPORT void ncnn_net_set_option(ncnn_net_t net, ncnn_option_t opt);
|
|
297
|
+
|
|
298
|
+
#if NCNN_VULKAN
|
|
299
|
+
NCNN_EXPORT void ncnn_net_set_vulkan_device(ncnn_net_t net, int device_index);
|
|
300
|
+
#endif
|
|
301
|
+
|
|
302
|
+
#if NCNN_STRING
|
|
303
|
+
NCNN_EXPORT void ncnn_net_register_custom_layer_by_type(ncnn_net_t net, const char* type, ncnn_layer_creator_t creator, ncnn_layer_destroyer_t destroyer, void* userdata);
|
|
304
|
+
#endif /* NCNN_STRING */
|
|
305
|
+
NCNN_EXPORT void ncnn_net_register_custom_layer_by_typeindex(ncnn_net_t net, int typeindex, ncnn_layer_creator_t creator, ncnn_layer_destroyer_t destroyer, void* userdata);
|
|
306
|
+
|
|
307
|
+
#if NCNN_STDIO
|
|
308
|
+
#if NCNN_STRING
|
|
309
|
+
NCNN_EXPORT int ncnn_net_load_param(ncnn_net_t net, const char* path);
|
|
310
|
+
#endif /* NCNN_STRING */
|
|
311
|
+
NCNN_EXPORT int ncnn_net_load_param_bin(ncnn_net_t net, const char* path);
|
|
312
|
+
NCNN_EXPORT int ncnn_net_load_model(ncnn_net_t net, const char* path);
|
|
313
|
+
#if _WIN32
|
|
314
|
+
#if NCNN_STRING
|
|
315
|
+
NCNN_EXPORT int ncnn_net_load_param_w(ncnn_net_t net, const wchar_t* path);
|
|
316
|
+
#endif /* NCNN_STRING */
|
|
317
|
+
NCNN_EXPORT int ncnn_net_load_param_bin_w(ncnn_net_t net, const wchar_t* path);
|
|
318
|
+
NCNN_EXPORT int ncnn_net_load_model_w(ncnn_net_t net, const wchar_t* path);
|
|
319
|
+
#endif /* _WIN32 */
|
|
320
|
+
#endif /* NCNN_STDIO */
|
|
321
|
+
|
|
322
|
+
#if NCNN_STDIO
|
|
323
|
+
#if NCNN_STRING
|
|
324
|
+
NCNN_EXPORT int ncnn_net_load_param_memory(ncnn_net_t net, const char* mem);
|
|
325
|
+
#endif /* NCNN_STRING */
|
|
326
|
+
#endif /* NCNN_STDIO */
|
|
327
|
+
NCNN_EXPORT int ncnn_net_load_param_bin_memory(ncnn_net_t net, const unsigned char* mem);
|
|
328
|
+
NCNN_EXPORT int ncnn_net_load_model_memory(ncnn_net_t net, const unsigned char* mem);
|
|
329
|
+
|
|
330
|
+
#if NCNN_STRING
|
|
331
|
+
NCNN_EXPORT int ncnn_net_load_param_datareader(ncnn_net_t net, const ncnn_datareader_t dr);
|
|
332
|
+
#endif /* NCNN_STRING */
|
|
333
|
+
NCNN_EXPORT int ncnn_net_load_param_bin_datareader(ncnn_net_t net, const ncnn_datareader_t dr);
|
|
334
|
+
NCNN_EXPORT int ncnn_net_load_model_datareader(ncnn_net_t net, const ncnn_datareader_t dr);
|
|
335
|
+
|
|
336
|
+
NCNN_EXPORT void ncnn_net_clear(ncnn_net_t net);
|
|
337
|
+
|
|
338
|
+
NCNN_EXPORT int ncnn_net_get_input_count(const ncnn_net_t net);
|
|
339
|
+
NCNN_EXPORT int ncnn_net_get_output_count(const ncnn_net_t net);
|
|
340
|
+
#if NCNN_STRING
|
|
341
|
+
NCNN_EXPORT const char* ncnn_net_get_input_name(const ncnn_net_t net, int i);
|
|
342
|
+
NCNN_EXPORT const char* ncnn_net_get_output_name(const ncnn_net_t net, int i);
|
|
343
|
+
#endif /* NCNN_STRING */
|
|
344
|
+
NCNN_EXPORT int ncnn_net_get_input_index(const ncnn_net_t net, int i);
|
|
345
|
+
NCNN_EXPORT int ncnn_net_get_output_index(const ncnn_net_t net, int i);
|
|
346
|
+
|
|
347
|
+
/* extractor api */
|
|
348
|
+
typedef struct __ncnn_extractor_t* ncnn_extractor_t;
|
|
349
|
+
|
|
350
|
+
NCNN_EXPORT ncnn_extractor_t ncnn_extractor_create(ncnn_net_t net);
|
|
351
|
+
NCNN_EXPORT void ncnn_extractor_destroy(ncnn_extractor_t ex);
|
|
352
|
+
|
|
353
|
+
NCNN_EXPORT void ncnn_extractor_set_option(ncnn_extractor_t ex, const ncnn_option_t opt);
|
|
354
|
+
|
|
355
|
+
#if NCNN_STRING
|
|
356
|
+
NCNN_EXPORT int ncnn_extractor_input(ncnn_extractor_t ex, const char* name, const ncnn_mat_t mat);
|
|
357
|
+
NCNN_EXPORT int ncnn_extractor_extract(ncnn_extractor_t ex, const char* name, ncnn_mat_t* mat);
|
|
358
|
+
#endif /* NCNN_STRING */
|
|
359
|
+
NCNN_EXPORT int ncnn_extractor_input_index(ncnn_extractor_t ex, int index, const ncnn_mat_t mat);
|
|
360
|
+
NCNN_EXPORT int ncnn_extractor_extract_index(ncnn_extractor_t ex, int index, ncnn_mat_t* mat);
|
|
361
|
+
|
|
362
|
+
/* mat process api */
|
|
363
|
+
#define NCNN_BORDER_CONSTANT 0
|
|
364
|
+
#define NCNN_BORDER_REPLICATE 1
|
|
365
|
+
#define NCNN_BORDER_REFLECT 2
|
|
366
|
+
#define NCNN_BORDER_TRANSPARENT -233
|
|
367
|
+
NCNN_EXPORT void ncnn_copy_make_border(const ncnn_mat_t src, ncnn_mat_t dst, int top, int bottom, int left, int right, int type, float v, const ncnn_option_t opt);
|
|
368
|
+
NCNN_EXPORT void ncnn_copy_make_border_3d(const ncnn_mat_t src, ncnn_mat_t dst, int top, int bottom, int left, int right, int front, int behind, int type, float v, const ncnn_option_t opt);
|
|
369
|
+
NCNN_EXPORT void ncnn_copy_cut_border(const ncnn_mat_t src, ncnn_mat_t dst, int top, int bottom, int left, int right, const ncnn_option_t opt);
|
|
370
|
+
NCNN_EXPORT void ncnn_copy_cut_border_3d(const ncnn_mat_t src, ncnn_mat_t dst, int top, int bottom, int left, int right, int front, int behind, const ncnn_option_t opt);
|
|
371
|
+
|
|
372
|
+
#if NCNN_PIXEL_DRAWING
|
|
373
|
+
/* mat pixel drawing api*/
|
|
374
|
+
NCNN_EXPORT void ncnn_draw_rectangle_c1(unsigned char* pixels, int w, int h, int rx, int ry, int rw, int rh, unsigned int color, int thickness);
|
|
375
|
+
NCNN_EXPORT void ncnn_draw_rectangle_c2(unsigned char* pixels, int w, int h, int rx, int ry, int rw, int rh, unsigned int color, int thickness);
|
|
376
|
+
NCNN_EXPORT void ncnn_draw_rectangle_c3(unsigned char* pixels, int w, int h, int rx, int ry, int rw, int rh, unsigned int color, int thickness);
|
|
377
|
+
NCNN_EXPORT void ncnn_draw_rectangle_c4(unsigned char* pixels, int w, int h, int rx, int ry, int rw, int rh, unsigned int color, int thickness);
|
|
378
|
+
|
|
379
|
+
NCNN_EXPORT void ncnn_draw_text_c1(unsigned char* pixels, int w, int h, const char* text, int x, int y, int fontpixelsize, unsigned int color);
|
|
380
|
+
NCNN_EXPORT void ncnn_draw_text_c2(unsigned char* pixels, int w, int h, const char* text, int x, int y, int fontpixelsize, unsigned int color);
|
|
381
|
+
NCNN_EXPORT void ncnn_draw_text_c3(unsigned char* pixels, int w, int h, const char* text, int x, int y, int fontpixelsize, unsigned int color);
|
|
382
|
+
NCNN_EXPORT void ncnn_draw_text_c4(unsigned char* pixels, int w, int h, const char* text, int x, int y, int fontpixelsize, unsigned int color);
|
|
383
|
+
|
|
384
|
+
NCNN_EXPORT void ncnn_draw_circle_c1(unsigned char* pixels, int w, int h, int cx, int cy, int radius, unsigned int color, int thickness);
|
|
385
|
+
NCNN_EXPORT void ncnn_draw_circle_c2(unsigned char* pixels, int w, int h, int cx, int cy, int radius, unsigned int color, int thickness);
|
|
386
|
+
NCNN_EXPORT void ncnn_draw_circle_c3(unsigned char* pixels, int w, int h, int cx, int cy, int radius, unsigned int color, int thickness);
|
|
387
|
+
NCNN_EXPORT void ncnn_draw_circle_c4(unsigned char* pixels, int w, int h, int cx, int cy, int radius, unsigned int color, int thickness);
|
|
388
|
+
|
|
389
|
+
NCNN_EXPORT void ncnn_draw_line_c1(unsigned char* pixels, int w, int h, int x0, int y0, int x1, int y1, unsigned int color, int thickness);
|
|
390
|
+
NCNN_EXPORT void ncnn_draw_line_c2(unsigned char* pixels, int w, int h, int x0, int y0, int x1, int y1, unsigned int color, int thickness);
|
|
391
|
+
NCNN_EXPORT void ncnn_draw_line_c3(unsigned char* pixels, int w, int h, int x0, int y0, int x1, int y1, unsigned int color, int thickness);
|
|
392
|
+
NCNN_EXPORT void ncnn_draw_line_c4(unsigned char* pixels, int w, int h, int x0, int y0, int x1, int y1, unsigned int color, int thickness);
|
|
393
|
+
#endif /* NCNN_PIXEL_DRAWING */
|
|
394
|
+
|
|
395
|
+
#ifdef __cplusplus
|
|
396
|
+
} /* extern "C" */
|
|
397
|
+
#endif
|
|
398
|
+
|
|
399
|
+
#endif /* NCNN_C_API */
|
|
400
|
+
|
|
401
|
+
#endif /* NCNN_C_API_H */
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Copyright 2020 Tencent
|
|
2
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
3
|
+
|
|
4
|
+
#ifndef NCNN_COMMAND_H
|
|
5
|
+
#define NCNN_COMMAND_H
|
|
6
|
+
|
|
7
|
+
#include "platform.h"
|
|
8
|
+
|
|
9
|
+
#if NCNN_VULKAN
|
|
10
|
+
|
|
11
|
+
#include "mat.h"
|
|
12
|
+
|
|
13
|
+
namespace ncnn {
|
|
14
|
+
|
|
15
|
+
class Pipeline;
|
|
16
|
+
#if NCNN_PLATFORM_API
|
|
17
|
+
#if __ANDROID_API__ >= 26
|
|
18
|
+
class ImportAndroidHardwareBufferPipeline;
|
|
19
|
+
#endif // __ANDROID_API__ >= 26
|
|
20
|
+
#endif // NCNN_PLATFORM_API
|
|
21
|
+
class VkComputePrivate;
|
|
22
|
+
class NCNN_EXPORT VkCompute
|
|
23
|
+
{
|
|
24
|
+
public:
|
|
25
|
+
explicit VkCompute(const VulkanDevice* vkdev);
|
|
26
|
+
virtual ~VkCompute();
|
|
27
|
+
|
|
28
|
+
public:
|
|
29
|
+
void record_upload(const Mat& src, VkMat& dst, const Option& opt);
|
|
30
|
+
|
|
31
|
+
void record_download(const VkMat& src, Mat& dst, const Option& opt);
|
|
32
|
+
|
|
33
|
+
void record_clone(const Mat& src, VkMat& dst, const Option& opt);
|
|
34
|
+
|
|
35
|
+
void record_clone(const Mat& src, VkImageMat& dst, const Option& opt);
|
|
36
|
+
|
|
37
|
+
void record_clone(const VkMat& src, Mat& dst, const Option& opt);
|
|
38
|
+
|
|
39
|
+
void record_clone(const VkImageMat& src, Mat& dst, const Option& opt);
|
|
40
|
+
|
|
41
|
+
void record_clone(const VkMat& src, VkMat& dst, const Option& opt);
|
|
42
|
+
|
|
43
|
+
void record_clone(const VkImageMat& src, VkImageMat& dst, const Option& opt);
|
|
44
|
+
|
|
45
|
+
void record_clone(const VkMat& src, VkImageMat& dst, const Option& opt);
|
|
46
|
+
|
|
47
|
+
void record_clone(const VkImageMat& src, VkMat& dst, const Option& opt);
|
|
48
|
+
|
|
49
|
+
void record_pipeline(const Pipeline* pipeline, const std::vector<VkMat>& bindings, const std::vector<vk_constant_type>& constants, const VkMat& dispatcher);
|
|
50
|
+
|
|
51
|
+
void record_pipeline(const Pipeline* pipeline, const std::vector<VkImageMat>& bindings, const std::vector<vk_constant_type>& constants, const VkImageMat& dispatcher);
|
|
52
|
+
|
|
53
|
+
void record_pipeline(const Pipeline* pipeline, const std::vector<VkMat>& buffer_bindings, const std::vector<VkImageMat>& image_bindings, const std::vector<vk_constant_type>& constants, const VkMat& dispatcher);
|
|
54
|
+
void record_pipeline(const Pipeline* pipeline, const std::vector<VkMat>& buffer_bindings, const std::vector<VkImageMat>& image_bindings, const std::vector<vk_constant_type>& constants, const VkImageMat& dispatcher);
|
|
55
|
+
void record_pipeline(const Pipeline* pipeline, const std::vector<VkMat>& buffer_bindings, const std::vector<VkImageMat>& image_bindings, const std::vector<vk_constant_type>& constants, const Mat& dispatcher);
|
|
56
|
+
|
|
57
|
+
#if NCNN_BENCHMARK
|
|
58
|
+
void record_write_timestamp(uint32_t query);
|
|
59
|
+
#endif // NCNN_BENCHMARK
|
|
60
|
+
|
|
61
|
+
#if NCNN_PLATFORM_API
|
|
62
|
+
#if __ANDROID_API__ >= 26
|
|
63
|
+
void record_import_android_hardware_buffer(const ImportAndroidHardwareBufferPipeline* pipeline, const VkImageMat& src, const VkMat& dst);
|
|
64
|
+
#endif // __ANDROID_API__ >= 26
|
|
65
|
+
#endif // NCNN_PLATFORM_API
|
|
66
|
+
|
|
67
|
+
int submit_and_wait();
|
|
68
|
+
|
|
69
|
+
int reset();
|
|
70
|
+
|
|
71
|
+
#if NCNN_BENCHMARK
|
|
72
|
+
int create_query_pool(uint32_t query_count);
|
|
73
|
+
|
|
74
|
+
int get_query_pool_results(uint32_t first_query, uint32_t query_count, std::vector<uint64_t>& results);
|
|
75
|
+
#endif // NCNN_BENCHMARK
|
|
76
|
+
|
|
77
|
+
protected:
|
|
78
|
+
const VulkanDevice* vkdev;
|
|
79
|
+
|
|
80
|
+
void barrier_readwrite(const VkMat& binding);
|
|
81
|
+
void barrier_readwrite(const VkImageMat& binding);
|
|
82
|
+
void barrier_readonly(const VkImageMat& binding);
|
|
83
|
+
|
|
84
|
+
private:
|
|
85
|
+
VkComputePrivate* const d;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
class VkTransferPrivate;
|
|
89
|
+
class NCNN_EXPORT VkTransfer
|
|
90
|
+
{
|
|
91
|
+
public:
|
|
92
|
+
explicit VkTransfer(const VulkanDevice* vkdev);
|
|
93
|
+
virtual ~VkTransfer();
|
|
94
|
+
|
|
95
|
+
public:
|
|
96
|
+
void record_upload(const Mat& src, VkMat& dst, const Option& opt, bool flatten = true);
|
|
97
|
+
|
|
98
|
+
int submit_and_wait();
|
|
99
|
+
|
|
100
|
+
protected:
|
|
101
|
+
const VulkanDevice* vkdev;
|
|
102
|
+
|
|
103
|
+
private:
|
|
104
|
+
VkTransferPrivate* const d;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
} // namespace ncnn
|
|
108
|
+
|
|
109
|
+
#endif // NCNN_VULKAN
|
|
110
|
+
|
|
111
|
+
#endif // NCNN_COMMAND_H
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// Copyright 2017 Tencent
|
|
2
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
3
|
+
|
|
4
|
+
#ifndef NCNN_CPU_H
|
|
5
|
+
#define NCNN_CPU_H
|
|
6
|
+
|
|
7
|
+
#include <stddef.h>
|
|
8
|
+
|
|
9
|
+
#if defined _WIN32
|
|
10
|
+
#define WIN32_LEAN_AND_MEAN
|
|
11
|
+
#include <windows.h>
|
|
12
|
+
#endif
|
|
13
|
+
#if defined __ANDROID__ || defined __linux__
|
|
14
|
+
#include <sched.h> // cpu_set_t
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#include "platform.h"
|
|
18
|
+
|
|
19
|
+
namespace ncnn {
|
|
20
|
+
|
|
21
|
+
class NCNN_EXPORT CpuSet
|
|
22
|
+
{
|
|
23
|
+
public:
|
|
24
|
+
CpuSet();
|
|
25
|
+
void enable(int cpu);
|
|
26
|
+
void disable(int cpu);
|
|
27
|
+
void disable_all();
|
|
28
|
+
bool is_enabled(int cpu) const;
|
|
29
|
+
int num_enabled() const;
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
#if defined _WIN32
|
|
33
|
+
ULONG_PTR mask;
|
|
34
|
+
#endif
|
|
35
|
+
#if defined __ANDROID__ || defined __linux__
|
|
36
|
+
cpu_set_t cpu_set;
|
|
37
|
+
#endif
|
|
38
|
+
#if __APPLE__
|
|
39
|
+
unsigned int policy;
|
|
40
|
+
#endif
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// test optional cpu features
|
|
44
|
+
// edsp = armv7 edsp
|
|
45
|
+
NCNN_EXPORT int cpu_support_arm_edsp();
|
|
46
|
+
// neon = armv7 neon or aarch64 asimd
|
|
47
|
+
NCNN_EXPORT int cpu_support_arm_neon();
|
|
48
|
+
// vfpv4 = armv7 fp16 + fma
|
|
49
|
+
NCNN_EXPORT int cpu_support_arm_vfpv4();
|
|
50
|
+
// asimdhp = aarch64 asimd half precision
|
|
51
|
+
NCNN_EXPORT int cpu_support_arm_asimdhp();
|
|
52
|
+
// cpuid = aarch64 cpuid info
|
|
53
|
+
NCNN_EXPORT int cpu_support_arm_cpuid();
|
|
54
|
+
// asimddp = aarch64 asimd dot product
|
|
55
|
+
NCNN_EXPORT int cpu_support_arm_asimddp();
|
|
56
|
+
// asimdfhm = aarch64 asimd fhm
|
|
57
|
+
NCNN_EXPORT int cpu_support_arm_asimdfhm();
|
|
58
|
+
// bf16 = aarch64 bf16
|
|
59
|
+
NCNN_EXPORT int cpu_support_arm_bf16();
|
|
60
|
+
// i8mm = aarch64 i8mm
|
|
61
|
+
NCNN_EXPORT int cpu_support_arm_i8mm();
|
|
62
|
+
// sve = aarch64 sve
|
|
63
|
+
NCNN_EXPORT int cpu_support_arm_sve();
|
|
64
|
+
// sve2 = aarch64 sve2
|
|
65
|
+
NCNN_EXPORT int cpu_support_arm_sve2();
|
|
66
|
+
// svebf16 = aarch64 svebf16
|
|
67
|
+
NCNN_EXPORT int cpu_support_arm_svebf16();
|
|
68
|
+
// svei8mm = aarch64 svei8mm
|
|
69
|
+
NCNN_EXPORT int cpu_support_arm_svei8mm();
|
|
70
|
+
// svef32mm = aarch64 svef32mm
|
|
71
|
+
NCNN_EXPORT int cpu_support_arm_svef32mm();
|
|
72
|
+
|
|
73
|
+
// avx = x86 avx
|
|
74
|
+
NCNN_EXPORT int cpu_support_x86_avx();
|
|
75
|
+
// fma = x86 fma
|
|
76
|
+
NCNN_EXPORT int cpu_support_x86_fma();
|
|
77
|
+
// xop = x86 xop
|
|
78
|
+
NCNN_EXPORT int cpu_support_x86_xop();
|
|
79
|
+
// f16c = x86 f16c
|
|
80
|
+
NCNN_EXPORT int cpu_support_x86_f16c();
|
|
81
|
+
// avx2 = x86 avx2 + fma + f16c
|
|
82
|
+
NCNN_EXPORT int cpu_support_x86_avx2();
|
|
83
|
+
// avx_vnni = x86 avx vnni
|
|
84
|
+
NCNN_EXPORT int cpu_support_x86_avx_vnni();
|
|
85
|
+
// avx_vnni_int8 = x86 avx vnni int8
|
|
86
|
+
NCNN_EXPORT int cpu_support_x86_avx_vnni_int8();
|
|
87
|
+
// avx_vnni_int16 = x86 avx vnni int16
|
|
88
|
+
NCNN_EXPORT int cpu_support_x86_avx_vnni_int16();
|
|
89
|
+
// avx_ne_convert = x86 avx ne convert
|
|
90
|
+
NCNN_EXPORT int cpu_support_x86_avx_ne_convert();
|
|
91
|
+
// avx512 = x86 avx512f + avx512cd + avx512bw + avx512dq + avx512vl
|
|
92
|
+
NCNN_EXPORT int cpu_support_x86_avx512();
|
|
93
|
+
// avx512_vnni = x86 avx512 vnni
|
|
94
|
+
NCNN_EXPORT int cpu_support_x86_avx512_vnni();
|
|
95
|
+
// avx512_bf16 = x86 avx512 bf16
|
|
96
|
+
NCNN_EXPORT int cpu_support_x86_avx512_bf16();
|
|
97
|
+
// avx512_fp16 = x86 avx512 fp16
|
|
98
|
+
NCNN_EXPORT int cpu_support_x86_avx512_fp16();
|
|
99
|
+
|
|
100
|
+
// lsx = loongarch lsx
|
|
101
|
+
NCNN_EXPORT int cpu_support_loongarch_lsx();
|
|
102
|
+
// lasx = loongarch lasx
|
|
103
|
+
NCNN_EXPORT int cpu_support_loongarch_lasx();
|
|
104
|
+
|
|
105
|
+
// msa = mips mas
|
|
106
|
+
NCNN_EXPORT int cpu_support_mips_msa();
|
|
107
|
+
// mmi = loongson mmi
|
|
108
|
+
NCNN_EXPORT int cpu_support_loongson_mmi();
|
|
109
|
+
|
|
110
|
+
// v = riscv vector
|
|
111
|
+
NCNN_EXPORT int cpu_support_riscv_v();
|
|
112
|
+
// zfh = riscv half-precision float
|
|
113
|
+
NCNN_EXPORT int cpu_support_riscv_zfh();
|
|
114
|
+
// zvfh = riscv vector half-precision float
|
|
115
|
+
NCNN_EXPORT int cpu_support_riscv_zvfh();
|
|
116
|
+
// xtheadvector = riscv xtheadvector
|
|
117
|
+
NCNN_EXPORT int cpu_support_riscv_xtheadvector();
|
|
118
|
+
// vlenb = riscv vector length in bytes
|
|
119
|
+
NCNN_EXPORT int cpu_riscv_vlenb();
|
|
120
|
+
|
|
121
|
+
// cpu info
|
|
122
|
+
NCNN_EXPORT int get_cpu_count();
|
|
123
|
+
NCNN_EXPORT int get_little_cpu_count();
|
|
124
|
+
NCNN_EXPORT int get_big_cpu_count();
|
|
125
|
+
|
|
126
|
+
NCNN_EXPORT int get_physical_cpu_count();
|
|
127
|
+
NCNN_EXPORT int get_physical_little_cpu_count();
|
|
128
|
+
NCNN_EXPORT int get_physical_big_cpu_count();
|
|
129
|
+
|
|
130
|
+
// cpu l2 varies from 64k to 1M, but l3 can be zero
|
|
131
|
+
NCNN_EXPORT int get_cpu_level2_cache_size();
|
|
132
|
+
NCNN_EXPORT int get_cpu_level3_cache_size();
|
|
133
|
+
|
|
134
|
+
// bind all threads on little clusters if powersave enabled
|
|
135
|
+
// affects HMP arch cpu like ARM big.LITTLE
|
|
136
|
+
// only implemented on android at the moment
|
|
137
|
+
// switching powersave is expensive and not thread-safe
|
|
138
|
+
// 0 = all cores enabled(default)
|
|
139
|
+
// 1 = only little clusters enabled
|
|
140
|
+
// 2 = only big clusters enabled
|
|
141
|
+
// return 0 if success for setter function
|
|
142
|
+
NCNN_EXPORT int get_cpu_powersave();
|
|
143
|
+
NCNN_EXPORT int set_cpu_powersave(int powersave);
|
|
144
|
+
|
|
145
|
+
// convenient wrapper
|
|
146
|
+
NCNN_EXPORT const CpuSet& get_cpu_thread_affinity_mask(int powersave);
|
|
147
|
+
|
|
148
|
+
// set explicit thread affinity
|
|
149
|
+
NCNN_EXPORT int set_cpu_thread_affinity(const CpuSet& thread_affinity_mask);
|
|
150
|
+
|
|
151
|
+
// runtime thread affinity info
|
|
152
|
+
NCNN_EXPORT int is_current_thread_running_on_a53_a55();
|
|
153
|
+
|
|
154
|
+
// misc function wrapper for openmp routines
|
|
155
|
+
NCNN_EXPORT int get_omp_num_threads();
|
|
156
|
+
NCNN_EXPORT void set_omp_num_threads(int num_threads);
|
|
157
|
+
|
|
158
|
+
NCNN_EXPORT int get_omp_dynamic();
|
|
159
|
+
NCNN_EXPORT void set_omp_dynamic(int dynamic);
|
|
160
|
+
|
|
161
|
+
NCNN_EXPORT int get_omp_thread_num();
|
|
162
|
+
|
|
163
|
+
NCNN_EXPORT int get_kmp_blocktime();
|
|
164
|
+
NCNN_EXPORT void set_kmp_blocktime(int time_ms);
|
|
165
|
+
|
|
166
|
+
// need to flush denormals on Intel Chipset.
|
|
167
|
+
// Other architectures such as ARM can be added as needed.
|
|
168
|
+
// 0 = DAZ OFF, FTZ OFF
|
|
169
|
+
// 1 = DAZ ON , FTZ OFF
|
|
170
|
+
// 2 = DAZ OFF, FTZ ON
|
|
171
|
+
// 3 = DAZ ON, FTZ ON
|
|
172
|
+
NCNN_EXPORT int get_flush_denormals();
|
|
173
|
+
NCNN_EXPORT int set_flush_denormals(int flush_denormals);
|
|
174
|
+
|
|
175
|
+
} // namespace ncnn
|
|
176
|
+
|
|
177
|
+
#endif // NCNN_CPU_H
|