react-native-vision-camera-spoof-detector 1.5.0 → 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 +33 -24
- package/VisionCameraSpoofDetector.podspec +12 -2
- package/ios/HybridSpoofDetectorOutput.swift +72 -157
- 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/package.json +1 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Copyright 2020 Tencent
|
|
2
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
3
|
+
|
|
4
|
+
#ifndef NCNN_PIPELINECACHE_H
|
|
5
|
+
#define NCNN_PIPELINECACHE_H
|
|
6
|
+
|
|
7
|
+
#include "platform.h"
|
|
8
|
+
|
|
9
|
+
#include "mat.h"
|
|
10
|
+
#include "gpu.h"
|
|
11
|
+
|
|
12
|
+
namespace ncnn {
|
|
13
|
+
|
|
14
|
+
#if NCNN_VULKAN
|
|
15
|
+
|
|
16
|
+
class VulkanDevice;
|
|
17
|
+
class PipelineCachePrivate;
|
|
18
|
+
class NCNN_EXPORT PipelineCache
|
|
19
|
+
{
|
|
20
|
+
public:
|
|
21
|
+
explicit PipelineCache(const VulkanDevice* _vkdev);
|
|
22
|
+
|
|
23
|
+
virtual ~PipelineCache();
|
|
24
|
+
|
|
25
|
+
void clear();
|
|
26
|
+
|
|
27
|
+
int get_pipeline(const uint32_t* spv_data, size_t spv_data_size, const std::vector<vk_specialization_type>& specializations,
|
|
28
|
+
uint32_t local_size_x, uint32_t local_size_y, uint32_t local_size_z, uint32_t subgroup_size,
|
|
29
|
+
VkShaderModule* shader_module,
|
|
30
|
+
VkDescriptorSetLayout* descriptorset_layout,
|
|
31
|
+
VkPipelineLayout* pipeline_layout,
|
|
32
|
+
VkPipeline* pipeline,
|
|
33
|
+
VkDescriptorUpdateTemplateKHR* descriptor_update_template,
|
|
34
|
+
ShaderInfo& shader_info) const;
|
|
35
|
+
|
|
36
|
+
int get_pipeline(int shader_type_index, const Option& opt, const std::vector<vk_specialization_type>& specializations,
|
|
37
|
+
uint32_t local_size_x, uint32_t local_size_y, uint32_t local_size_z, uint32_t subgroup_size,
|
|
38
|
+
VkShaderModule* shader_module,
|
|
39
|
+
VkDescriptorSetLayout* descriptorset_layout,
|
|
40
|
+
VkPipelineLayout* pipeline_layout,
|
|
41
|
+
VkPipeline* pipeline,
|
|
42
|
+
VkDescriptorUpdateTemplateKHR* descriptor_update_template,
|
|
43
|
+
ShaderInfo& shader_info) const;
|
|
44
|
+
|
|
45
|
+
protected:
|
|
46
|
+
int create_shader_module(int shader_type_index, const Option& opt,
|
|
47
|
+
uint32_t local_size_x, uint32_t local_size_y, uint32_t local_size_z,
|
|
48
|
+
VkShaderModule* _shader_module, ShaderInfo& si) const;
|
|
49
|
+
|
|
50
|
+
int new_pipeline(VkShaderModule shader_module, const ShaderInfo& shader_info, const std::vector<vk_specialization_type>& specializations, uint32_t subgroup_size,
|
|
51
|
+
VkDescriptorSetLayout* descriptorset_layout,
|
|
52
|
+
VkPipelineLayout* pipeline_layout,
|
|
53
|
+
VkPipeline* pipeline,
|
|
54
|
+
VkDescriptorUpdateTemplateKHR* descriptor_update_template) const;
|
|
55
|
+
|
|
56
|
+
protected:
|
|
57
|
+
const VulkanDevice* vkdev;
|
|
58
|
+
|
|
59
|
+
private:
|
|
60
|
+
PipelineCache(const PipelineCache&);
|
|
61
|
+
PipelineCache& operator=(const PipelineCache&);
|
|
62
|
+
|
|
63
|
+
private:
|
|
64
|
+
PipelineCachePrivate* const d;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
#endif // NCNN_VULKAN
|
|
68
|
+
|
|
69
|
+
} // namespace ncnn
|
|
70
|
+
|
|
71
|
+
#endif // NCNN_PIPELINECACHE_H
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
// Copyright 2017 Tencent
|
|
2
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
3
|
+
|
|
4
|
+
#ifndef NCNN_PLATFORM_H
|
|
5
|
+
#define NCNN_PLATFORM_H
|
|
6
|
+
|
|
7
|
+
#define NCNN_STDIO 1
|
|
8
|
+
#define NCNN_STRING 1
|
|
9
|
+
#define NCNN_SIMPLEOCV 0
|
|
10
|
+
#define NCNN_SIMPLEOMP 0
|
|
11
|
+
#define NCNN_SIMPLESTL 0
|
|
12
|
+
#define NCNN_SIMPLEMATH 0
|
|
13
|
+
#define NCNN_THREADS 1
|
|
14
|
+
#define NCNN_BENCHMARK 0
|
|
15
|
+
#define NCNN_C_API 1
|
|
16
|
+
#define NCNN_PLATFORM_API 1
|
|
17
|
+
#define NCNN_WINXP 0
|
|
18
|
+
#define NCNN_PIXEL 1
|
|
19
|
+
#define NCNN_PIXEL_ROTATE 1
|
|
20
|
+
#define NCNN_PIXEL_AFFINE 1
|
|
21
|
+
#define NCNN_PIXEL_DRAWING 1
|
|
22
|
+
#define NCNN_VULKAN 0
|
|
23
|
+
#define NCNN_SIMPLEVK 1
|
|
24
|
+
#define NCNN_SYSTEM_GLSLANG 0
|
|
25
|
+
#define NCNN_RUNTIME_CPU 1
|
|
26
|
+
#define NCNN_GNU_INLINE_ASM 1
|
|
27
|
+
#define NCNN_AVX 0
|
|
28
|
+
#define NCNN_XOP 0
|
|
29
|
+
#define NCNN_FMA 0
|
|
30
|
+
#define NCNN_F16C 0
|
|
31
|
+
#define NCNN_AVX2 0
|
|
32
|
+
#define NCNN_AVXVNNI 0
|
|
33
|
+
#define NCNN_AVXVNNIINT8 0
|
|
34
|
+
#define NCNN_AVXVNNIINT16 0
|
|
35
|
+
#define NCNN_AVXNECONVERT 0
|
|
36
|
+
#define NCNN_AVX512 0
|
|
37
|
+
#define NCNN_AVX512VNNI 0
|
|
38
|
+
#define NCNN_AVX512BF16 0
|
|
39
|
+
#define NCNN_AVX512FP16 0
|
|
40
|
+
#define NCNN_VFPV4 1
|
|
41
|
+
#define NCNN_ARM82 1
|
|
42
|
+
#define NCNN_ARM82DOT 1
|
|
43
|
+
#define NCNN_ARM82FP16FML 1
|
|
44
|
+
#define NCNN_ARM84BF16 1
|
|
45
|
+
#define NCNN_ARM84I8MM 1
|
|
46
|
+
#define NCNN_ARM86SVE 1
|
|
47
|
+
#define NCNN_ARM86SVE2 1
|
|
48
|
+
#define NCNN_ARM86SVEBF16 1
|
|
49
|
+
#define NCNN_ARM86SVEI8MM 1
|
|
50
|
+
#define NCNN_ARM86SVEF32MM 1
|
|
51
|
+
#define NCNN_MSA 0
|
|
52
|
+
#define NCNN_LSX 0
|
|
53
|
+
#define NCNN_MMI 0
|
|
54
|
+
#define NCNN_RVV 0
|
|
55
|
+
#define NCNN_ZFH 0
|
|
56
|
+
#define NCNN_ZVFH 0
|
|
57
|
+
#define NCNN_XTHEADVECTOR 0
|
|
58
|
+
#define NCNN_INT8 1
|
|
59
|
+
#define NCNN_BF16 1
|
|
60
|
+
#define NCNN_FORCE_INLINE 1
|
|
61
|
+
|
|
62
|
+
#define NCNN_VERSION_STRING "1.0.20260113"
|
|
63
|
+
#define NCNN_VERSION_NUMBER 20260113
|
|
64
|
+
|
|
65
|
+
#include "ncnn_export.h"
|
|
66
|
+
|
|
67
|
+
#ifdef __cplusplus
|
|
68
|
+
|
|
69
|
+
#if NCNN_THREADS
|
|
70
|
+
#if defined _WIN32
|
|
71
|
+
#define WIN32_LEAN_AND_MEAN
|
|
72
|
+
#include <windows.h>
|
|
73
|
+
#include <process.h>
|
|
74
|
+
#else
|
|
75
|
+
#include <pthread.h>
|
|
76
|
+
#endif
|
|
77
|
+
#endif // NCNN_THREADS
|
|
78
|
+
|
|
79
|
+
#if __ANDROID_API__ >= 26
|
|
80
|
+
#ifndef VK_USE_PLATFORM_ANDROID_KHR
|
|
81
|
+
#define VK_USE_PLATFORM_ANDROID_KHR
|
|
82
|
+
#endif
|
|
83
|
+
#endif // __ANDROID_API__ >= 26
|
|
84
|
+
|
|
85
|
+
namespace ncnn {
|
|
86
|
+
|
|
87
|
+
#if NCNN_THREADS
|
|
88
|
+
#if defined _WIN32
|
|
89
|
+
#if NCNN_WINXP
|
|
90
|
+
class NCNN_EXPORT Mutex
|
|
91
|
+
{
|
|
92
|
+
public:
|
|
93
|
+
Mutex() { InitializeCriticalSection(&cs); }
|
|
94
|
+
~Mutex() { DeleteCriticalSection(&cs); }
|
|
95
|
+
void lock() { EnterCriticalSection(&cs); }
|
|
96
|
+
void unlock() { LeaveCriticalSection(&cs); }
|
|
97
|
+
private:
|
|
98
|
+
friend class ConditionVariable;
|
|
99
|
+
CRITICAL_SECTION cs;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
class NCNN_EXPORT ConditionVariable
|
|
103
|
+
{
|
|
104
|
+
public:
|
|
105
|
+
ConditionVariable()
|
|
106
|
+
{
|
|
107
|
+
signal_event = CreateEvent(0, FALSE, FALSE, 0); // Auto-reset event for signal()
|
|
108
|
+
broadcast_event = CreateEvent(0, TRUE, FALSE, 0); // Manual-reset event for broadcast()
|
|
109
|
+
}
|
|
110
|
+
~ConditionVariable()
|
|
111
|
+
{
|
|
112
|
+
CloseHandle(signal_event);
|
|
113
|
+
CloseHandle(broadcast_event);
|
|
114
|
+
}
|
|
115
|
+
void wait(Mutex& mutex)
|
|
116
|
+
{
|
|
117
|
+
mutex.unlock();
|
|
118
|
+
HANDLE events[2] = { signal_event, broadcast_event };
|
|
119
|
+
WaitForMultipleObjects(2, events, FALSE, INFINITE); // Wait for either signal or broadcast
|
|
120
|
+
mutex.lock();
|
|
121
|
+
}
|
|
122
|
+
void broadcast()
|
|
123
|
+
{
|
|
124
|
+
SetEvent(broadcast_event); // Wake all threads
|
|
125
|
+
ResetEvent(broadcast_event); // Reset after waking all threads
|
|
126
|
+
}
|
|
127
|
+
void signal()
|
|
128
|
+
{
|
|
129
|
+
SetEvent(signal_event); // Wake one thread
|
|
130
|
+
}
|
|
131
|
+
private:
|
|
132
|
+
HANDLE signal_event;
|
|
133
|
+
HANDLE broadcast_event;
|
|
134
|
+
};
|
|
135
|
+
#else // NCNN_WINXP
|
|
136
|
+
class NCNN_EXPORT Mutex
|
|
137
|
+
{
|
|
138
|
+
public:
|
|
139
|
+
Mutex() { InitializeSRWLock(&srwlock); }
|
|
140
|
+
~Mutex() {}
|
|
141
|
+
void lock() { AcquireSRWLockExclusive(&srwlock); }
|
|
142
|
+
void unlock() { ReleaseSRWLockExclusive(&srwlock); }
|
|
143
|
+
private:
|
|
144
|
+
friend class ConditionVariable;
|
|
145
|
+
SRWLOCK srwlock;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
class NCNN_EXPORT ConditionVariable
|
|
149
|
+
{
|
|
150
|
+
public:
|
|
151
|
+
ConditionVariable() { InitializeConditionVariable(&condvar); }
|
|
152
|
+
~ConditionVariable() {}
|
|
153
|
+
void wait(Mutex& mutex) { SleepConditionVariableSRW(&condvar, &mutex.srwlock, INFINITE, 0); }
|
|
154
|
+
void broadcast() { WakeAllConditionVariable(&condvar); }
|
|
155
|
+
void signal() { WakeConditionVariable(&condvar); }
|
|
156
|
+
private:
|
|
157
|
+
CONDITION_VARIABLE condvar;
|
|
158
|
+
};
|
|
159
|
+
#endif // NCNN_WINXP
|
|
160
|
+
|
|
161
|
+
static unsigned __stdcall start_wrapper(void* args);
|
|
162
|
+
class NCNN_EXPORT Thread
|
|
163
|
+
{
|
|
164
|
+
public:
|
|
165
|
+
Thread(void* (*start)(void*), void* args = 0) { _start = start; _args = args; handle = (HANDLE)_beginthreadex(0, 0, start_wrapper, this, 0, 0); }
|
|
166
|
+
~Thread() {}
|
|
167
|
+
void join() { WaitForSingleObject(handle, INFINITE); CloseHandle(handle); }
|
|
168
|
+
private:
|
|
169
|
+
friend unsigned __stdcall start_wrapper(void* args)
|
|
170
|
+
{
|
|
171
|
+
Thread* t = (Thread*)args;
|
|
172
|
+
t->_start(t->_args);
|
|
173
|
+
return 0;
|
|
174
|
+
}
|
|
175
|
+
HANDLE handle;
|
|
176
|
+
void* (*_start)(void*);
|
|
177
|
+
void* _args;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
class NCNN_EXPORT ThreadLocalStorage
|
|
181
|
+
{
|
|
182
|
+
public:
|
|
183
|
+
ThreadLocalStorage() { key = TlsAlloc(); }
|
|
184
|
+
~ThreadLocalStorage() { TlsFree(key); }
|
|
185
|
+
void set(void* value) { TlsSetValue(key, (LPVOID)value); }
|
|
186
|
+
void* get() { return (void*)TlsGetValue(key); }
|
|
187
|
+
private:
|
|
188
|
+
DWORD key;
|
|
189
|
+
};
|
|
190
|
+
#else // defined _WIN32
|
|
191
|
+
class NCNN_EXPORT Mutex
|
|
192
|
+
{
|
|
193
|
+
public:
|
|
194
|
+
Mutex() { pthread_mutex_init(&mutex, 0); }
|
|
195
|
+
~Mutex() { pthread_mutex_destroy(&mutex); }
|
|
196
|
+
void lock() { pthread_mutex_lock(&mutex); }
|
|
197
|
+
void unlock() { pthread_mutex_unlock(&mutex); }
|
|
198
|
+
private:
|
|
199
|
+
friend class ConditionVariable;
|
|
200
|
+
pthread_mutex_t mutex;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
class NCNN_EXPORT ConditionVariable
|
|
204
|
+
{
|
|
205
|
+
public:
|
|
206
|
+
ConditionVariable() { pthread_cond_init(&cond, 0); }
|
|
207
|
+
~ConditionVariable() { pthread_cond_destroy(&cond); }
|
|
208
|
+
void wait(Mutex& mutex) { pthread_cond_wait(&cond, &mutex.mutex); }
|
|
209
|
+
void broadcast() { pthread_cond_broadcast(&cond); }
|
|
210
|
+
void signal() { pthread_cond_signal(&cond); }
|
|
211
|
+
private:
|
|
212
|
+
pthread_cond_t cond;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
class NCNN_EXPORT Thread
|
|
216
|
+
{
|
|
217
|
+
public:
|
|
218
|
+
Thread(void* (*start)(void*), void* args = 0) { pthread_create(&t, 0, start, args); }
|
|
219
|
+
~Thread() {}
|
|
220
|
+
void join() { pthread_join(t, 0); }
|
|
221
|
+
private:
|
|
222
|
+
pthread_t t;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
class NCNN_EXPORT ThreadLocalStorage
|
|
226
|
+
{
|
|
227
|
+
public:
|
|
228
|
+
ThreadLocalStorage() { pthread_key_create(&key, 0); }
|
|
229
|
+
~ThreadLocalStorage() { pthread_key_delete(key); }
|
|
230
|
+
void set(void* value) { pthread_setspecific(key, value); }
|
|
231
|
+
void* get() { return pthread_getspecific(key); }
|
|
232
|
+
private:
|
|
233
|
+
pthread_key_t key;
|
|
234
|
+
};
|
|
235
|
+
#endif // defined _WIN32
|
|
236
|
+
#else // NCNN_THREADS
|
|
237
|
+
class NCNN_EXPORT Mutex
|
|
238
|
+
{
|
|
239
|
+
public:
|
|
240
|
+
Mutex() {}
|
|
241
|
+
~Mutex() {}
|
|
242
|
+
void lock() {}
|
|
243
|
+
void unlock() {}
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
class NCNN_EXPORT ConditionVariable
|
|
247
|
+
{
|
|
248
|
+
public:
|
|
249
|
+
ConditionVariable() {}
|
|
250
|
+
~ConditionVariable() {}
|
|
251
|
+
void wait(Mutex& /*mutex*/) {}
|
|
252
|
+
void broadcast() {}
|
|
253
|
+
void signal() {}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
class NCNN_EXPORT Thread
|
|
257
|
+
{
|
|
258
|
+
public:
|
|
259
|
+
Thread(void* (*/*start*/)(void*), void* /*args*/ = 0) {}
|
|
260
|
+
~Thread() {}
|
|
261
|
+
void join() {}
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
class NCNN_EXPORT ThreadLocalStorage
|
|
265
|
+
{
|
|
266
|
+
public:
|
|
267
|
+
ThreadLocalStorage() { data = 0; }
|
|
268
|
+
~ThreadLocalStorage() {}
|
|
269
|
+
void set(void* value) { data = value; }
|
|
270
|
+
void* get() { return data; }
|
|
271
|
+
private:
|
|
272
|
+
void* data;
|
|
273
|
+
};
|
|
274
|
+
#endif // NCNN_THREADS
|
|
275
|
+
|
|
276
|
+
class NCNN_EXPORT MutexLockGuard
|
|
277
|
+
{
|
|
278
|
+
public:
|
|
279
|
+
MutexLockGuard(Mutex& _mutex) : mutex(_mutex) { mutex.lock(); }
|
|
280
|
+
~MutexLockGuard() { mutex.unlock(); }
|
|
281
|
+
private:
|
|
282
|
+
Mutex& mutex;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
static inline void swap_endianness_16(void* x)
|
|
286
|
+
{
|
|
287
|
+
unsigned char* xx = (unsigned char*)x;
|
|
288
|
+
unsigned char x0 = xx[0];
|
|
289
|
+
unsigned char x1 = xx[1];
|
|
290
|
+
xx[0] = x1;
|
|
291
|
+
xx[1] = x0;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
static inline void swap_endianness_32(void* x)
|
|
295
|
+
{
|
|
296
|
+
unsigned char* xx = (unsigned char*)x;
|
|
297
|
+
unsigned char x0 = xx[0];
|
|
298
|
+
unsigned char x1 = xx[1];
|
|
299
|
+
unsigned char x2 = xx[2];
|
|
300
|
+
unsigned char x3 = xx[3];
|
|
301
|
+
xx[0] = x3;
|
|
302
|
+
xx[1] = x2;
|
|
303
|
+
xx[2] = x1;
|
|
304
|
+
xx[3] = x0;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
} // namespace ncnn
|
|
308
|
+
|
|
309
|
+
#if NCNN_SIMPLESTL
|
|
310
|
+
#include "simplestl.h"
|
|
311
|
+
#else
|
|
312
|
+
#include <algorithm>
|
|
313
|
+
#include <list>
|
|
314
|
+
#include <vector>
|
|
315
|
+
#include <stack>
|
|
316
|
+
#include <string>
|
|
317
|
+
#endif
|
|
318
|
+
|
|
319
|
+
// simplemath
|
|
320
|
+
#if NCNN_SIMPLEMATH
|
|
321
|
+
#include "simplemath.h"
|
|
322
|
+
#else
|
|
323
|
+
#include <math.h>
|
|
324
|
+
#include <fenv.h>
|
|
325
|
+
#endif
|
|
326
|
+
|
|
327
|
+
#if NCNN_VULKAN
|
|
328
|
+
#if NCNN_SIMPLEVK
|
|
329
|
+
#include "simplevk.h"
|
|
330
|
+
#else
|
|
331
|
+
#include <vulkan/vulkan.h>
|
|
332
|
+
#endif
|
|
333
|
+
#include "vulkan_header_fix.h"
|
|
334
|
+
#endif // NCNN_VULKAN
|
|
335
|
+
|
|
336
|
+
#endif // __cplusplus
|
|
337
|
+
|
|
338
|
+
#if NCNN_STDIO
|
|
339
|
+
#if NCNN_PLATFORM_API && __ANDROID_API__ >= 8
|
|
340
|
+
#include <android/log.h>
|
|
341
|
+
#define NCNN_LOGE(...) do { \
|
|
342
|
+
fprintf(stderr, ##__VA_ARGS__); fprintf(stderr, "\n"); \
|
|
343
|
+
__android_log_print(ANDROID_LOG_WARN, "ncnn", ##__VA_ARGS__); } while(0)
|
|
344
|
+
#else // NCNN_PLATFORM_API && __ANDROID_API__ >= 8
|
|
345
|
+
#include <stdio.h>
|
|
346
|
+
#define NCNN_LOGE(...) do { \
|
|
347
|
+
fprintf(stderr, ##__VA_ARGS__); fprintf(stderr, "\n"); } while(0)
|
|
348
|
+
#endif // NCNN_PLATFORM_API && __ANDROID_API__ >= 8
|
|
349
|
+
#else
|
|
350
|
+
#define NCNN_LOGE(...)
|
|
351
|
+
#endif
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
#if NCNN_FORCE_INLINE
|
|
355
|
+
#ifdef _MSC_VER
|
|
356
|
+
#define NCNN_FORCEINLINE __forceinline
|
|
357
|
+
#elif defined(__GNUC__)
|
|
358
|
+
#define NCNN_FORCEINLINE inline __attribute__((__always_inline__))
|
|
359
|
+
#elif defined(__CLANG__)
|
|
360
|
+
#if __has_attribute(__always_inline__)
|
|
361
|
+
#define NCNN_FORCEINLINE inline __attribute__((__always_inline__))
|
|
362
|
+
#else
|
|
363
|
+
#define NCNN_FORCEINLINE inline
|
|
364
|
+
#endif
|
|
365
|
+
#else
|
|
366
|
+
#define NCNN_FORCEINLINE inline
|
|
367
|
+
#endif
|
|
368
|
+
#else
|
|
369
|
+
#define NCNN_FORCEINLINE inline
|
|
370
|
+
#endif
|
|
371
|
+
|
|
372
|
+
#endif // NCNN_PLATFORM_H
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Copyright 2017 Tencent
|
|
2
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
3
|
+
|
|
4
|
+
#ifndef NCNN_SIMPLEMATH_H
|
|
5
|
+
#define NCNN_SIMPLEMATH_H
|
|
6
|
+
|
|
7
|
+
#include "platform.h"
|
|
8
|
+
|
|
9
|
+
#if NCNN_SIMPLEMATH
|
|
10
|
+
|
|
11
|
+
#ifdef __cplusplus
|
|
12
|
+
extern "C" {
|
|
13
|
+
#endif
|
|
14
|
+
/*
|
|
15
|
+
* ====================================================
|
|
16
|
+
* discrete functions
|
|
17
|
+
* ====================================================
|
|
18
|
+
*/
|
|
19
|
+
NCNN_EXPORT float fabs(float);
|
|
20
|
+
NCNN_EXPORT float fabsf(float);
|
|
21
|
+
NCNN_EXPORT float fmod(float, float);
|
|
22
|
+
NCNN_EXPORT float floor(float);
|
|
23
|
+
NCNN_EXPORT float floorf(float);
|
|
24
|
+
NCNN_EXPORT float round(float);
|
|
25
|
+
NCNN_EXPORT float roundf(float);
|
|
26
|
+
NCNN_EXPORT float ceil(float);
|
|
27
|
+
NCNN_EXPORT float ceilf(float);
|
|
28
|
+
NCNN_EXPORT float fmaxf(float, float);
|
|
29
|
+
NCNN_EXPORT float truncf(float);
|
|
30
|
+
NCNN_EXPORT float frac(float);
|
|
31
|
+
NCNN_EXPORT float fmodf(float, float);
|
|
32
|
+
/*
|
|
33
|
+
* ====================================================
|
|
34
|
+
* trigonometric functions
|
|
35
|
+
* ====================================================
|
|
36
|
+
*/
|
|
37
|
+
NCNN_EXPORT float sinf(float);
|
|
38
|
+
NCNN_EXPORT float cosf(float);
|
|
39
|
+
NCNN_EXPORT float tanf(float);
|
|
40
|
+
NCNN_EXPORT float asinf(float);
|
|
41
|
+
NCNN_EXPORT float acosf(float);
|
|
42
|
+
NCNN_EXPORT float atanf(float);
|
|
43
|
+
NCNN_EXPORT float atan2f(float, float);
|
|
44
|
+
NCNN_EXPORT float sinhf(float);
|
|
45
|
+
NCNN_EXPORT float coshf(float);
|
|
46
|
+
NCNN_EXPORT float tanhf(float);
|
|
47
|
+
NCNN_EXPORT float asinhf(float);
|
|
48
|
+
NCNN_EXPORT float acoshf(float);
|
|
49
|
+
NCNN_EXPORT float atanhf(float);
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
* ====================================================
|
|
53
|
+
* power functions
|
|
54
|
+
* ====================================================
|
|
55
|
+
*/
|
|
56
|
+
NCNN_EXPORT float sqrtf(float);
|
|
57
|
+
NCNN_EXPORT float sqrt(float);
|
|
58
|
+
NCNN_EXPORT float powf(float, float);
|
|
59
|
+
|
|
60
|
+
/*
|
|
61
|
+
* ====================================================
|
|
62
|
+
* exponential and logarithm functions
|
|
63
|
+
* ====================================================
|
|
64
|
+
*/
|
|
65
|
+
NCNN_EXPORT float expf(float);
|
|
66
|
+
NCNN_EXPORT float frexp(float, int*);
|
|
67
|
+
NCNN_EXPORT float logf(float);
|
|
68
|
+
NCNN_EXPORT float log(float);
|
|
69
|
+
NCNN_EXPORT float log10f(float);
|
|
70
|
+
|
|
71
|
+
/*
|
|
72
|
+
* ====================================================
|
|
73
|
+
* probability functions
|
|
74
|
+
* ====================================================
|
|
75
|
+
*/
|
|
76
|
+
NCNN_EXPORT float erf(float);
|
|
77
|
+
NCNN_EXPORT float erff(float);
|
|
78
|
+
NCNN_EXPORT float erfcf(float);
|
|
79
|
+
|
|
80
|
+
/*
|
|
81
|
+
* ====================================================
|
|
82
|
+
* other functions
|
|
83
|
+
* ====================================================
|
|
84
|
+
*/
|
|
85
|
+
NCNN_EXPORT int msb(unsigned int);
|
|
86
|
+
NCNN_EXPORT float fmaf(float, float, float);
|
|
87
|
+
NCNN_EXPORT float copysignf(float, float);
|
|
88
|
+
NCNN_EXPORT void fesetround(int);
|
|
89
|
+
NCNN_EXPORT int fegetround();
|
|
90
|
+
NCNN_EXPORT float nearbyintf(float);
|
|
91
|
+
|
|
92
|
+
#ifdef __cplusplus
|
|
93
|
+
} // extern "C"
|
|
94
|
+
#endif
|
|
95
|
+
|
|
96
|
+
#endif // NCNN_SIMPLEMATH
|
|
97
|
+
|
|
98
|
+
#endif // NCNN_SIMPLEMATH_H
|