Elffuss BraidHub

kikocis/ncnn public

master · 4.5 KiBRawPermalink
1// Tencent is pleased to support the open source community by making ncnn available.
2//
3// Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
4//
5// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6// in compliance with the License. You may obtain a copy of the License at
7//
8// https://opensource.org/licenses/BSD-3-Clause
9//
10// Unless required by applicable law or agreed to in writing, software distributed
11// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12// CONDITIONS OF ANY KIND, either express or implied. See the License for the
13// specific language governing permissions and limitations under the License.
14
15#ifndef NCNN_OPTION_H
16#define NCNN_OPTION_H
17
18#include "platform.h"
19
20namespace ncnn {
21
22#if NCNN_VULKAN
23class VkAllocator;
24class PipelineCache;
25#endif // NCNN_VULKAN
26
27class Allocator;
28class NCNN_EXPORT Option
29{
30public:
31 // default option
32 Option();
33
34public:
35 // light mode
36 // intermediate blob will be recycled when enabled
37 // enabled by default
38 bool lightmode;
39
40 // thread count
41 // default value is the one returned by get_cpu_count()
42 int num_threads;
43
44 // blob memory allocator
45 Allocator* blob_allocator;
46
47 // workspace memory allocator
48 Allocator* workspace_allocator;
49
50#if NCNN_VULKAN
51 // blob memory allocator
52 VkAllocator* blob_vkallocator;
53
54 // workspace memory allocator
55 VkAllocator* workspace_vkallocator;
56
57 // staging memory allocator
58 VkAllocator* staging_vkallocator;
59
60 // pipeline cache
61 PipelineCache* pipeline_cache;
62#endif // NCNN_VULKAN
63
64 // the time openmp threads busy-wait for more work before going to sleep
65 // default value is 20ms to keep the cores enabled
66 // without too much extra power consumption afterwards
67 int openmp_blocktime;
68
69 // enable winograd convolution optimization
70 // improve convolution 3x3 stride1 performance, may consume more memory
71 // changes should be applied before loading network structure and weight
72 // enabled by default
73 bool use_winograd_convolution;
74
75 // enable sgemm convolution optimization
76 // improve convolution 1x1 stride1 performance, may consume more memory
77 // changes should be applied before loading network structure and weight
78 // enabled by default
79 bool use_sgemm_convolution;
80
81 // enable quantized int8 inference
82 // use low-precision int8 path for quantized model
83 // changes should be applied before loading network structure and weight
84 // enabled by default
85 bool use_int8_inference;
86
87 // enable vulkan compute
88 bool use_vulkan_compute;
89
90 // enable bf16 data type for storage
91 // improve most operator performance on all arm devices, may consume more memory
92 bool use_bf16_storage;
93
94 // enable options for gpu inference
95 bool use_fp16_packed;
96 bool use_fp16_storage;
97 bool use_fp16_arithmetic;
98 bool use_int8_packed;
99 bool use_int8_storage;
100 bool use_int8_arithmetic;
101
102 // enable simd-friendly packed memory layout
103 // improve all operator performance on all arm devices, will consume more memory
104 // changes should be applied before loading network structure and weight
105 // enabled by default
106 bool use_packing_layout;
107
108 bool use_shader_pack8;
109
110 // subgroup option
111 bool use_subgroup_basic;
112 bool use_subgroup_vote;
113 bool use_subgroup_ballot;
114 bool use_subgroup_shuffle;
115
116 // turn on for adreno
117 bool use_image_storage;
118 bool use_tensor_storage;
119
120 bool use_reserved_0;
121
122 // enable DAZ(Denormals-Are-Zero) and FTZ(Flush-To-Zero)
123 // default value is 3
124 // 0 = DAZ OFF, FTZ OFF
125 // 1 = DAZ ON , FTZ OFF
126 // 2 = DAZ OFF, FTZ ON
127 // 3 = DAZ ON, FTZ ON
128 int flush_denormals;
129
130 bool use_local_pool_allocator;
131
132 // enable local memory optimization for gpu inference
133 bool use_shader_local_memory;
134
135 // enable cooperative matrix optimization for gpu inference
136 bool use_cooperative_matrix;
137
138 // more fine-grained control of winograd convolution
139 bool use_winograd23_convolution;
140 bool use_winograd43_convolution;
141 bool use_winograd63_convolution;
142
143 // this option is turned on for A53/A55 automatically
144 // but you can force this on/off if you wish
145 bool use_a53_a55_optimized_kernel;
146
147 // enable options for shared variables in gpu shader
148 bool use_fp16_uniform;
149 bool use_int8_uniform;
150
151 bool use_reserved_9;
152 bool use_reserved_10;
153 bool use_reserved_11;
154};
155
156} // namespace ncnn
157
158#endif // NCNN_OPTION_H