$darkmode
A high-performance general-purpose compute library
defines.h
Go to the documentation of this file.
1 /*******************************************************
2  * Copyright (c) 2014, ArrayFire
3  * All rights reserved.
4  *
5  * This file is distributed under 3-clause BSD license.
6  * The complete license agreement can be obtained at:
7  * http://arrayfire.com/licenses/BSD-3-Clause
8  ********************************************************/
9 
10 #pragma once
11 
12 #ifndef __CUDACC_RTC__
13 #include <af/compilers.h>
14 #endif
15 
16 #if defined(_WIN32) || defined(_MSC_VER)
17  // http://msdn.microsoft.com/en-us/library/b0084kay(v=VS.80).aspx
18  // http://msdn.microsoft.com/en-us/library/3y1sfaz2%28v=VS.80%29.aspx
19  #ifdef AFDLL // libaf
20  #define AFAPI __declspec(dllexport)
21  #else
22  #define AFAPI __declspec(dllimport)
23  #endif
24 
25  // bool
26  #ifndef __cplusplus
27  #define bool unsigned char
28  #define false 0
29  #define true 1
30  #endif
31  #define __PRETTY_FUNCTION__ __FUNCSIG__
32  #define SIZE_T_FRMT_SPECIFIER "%Iu"
33  #define AF_DEPRECATED(msg) __declspec(deprecated( msg ))
34  #if _MSC_VER >= 1800
35  #define AF_HAS_VARIADIC_TEMPLATES
36  #endif
37 #else
38  #define AFAPI __attribute__((visibility("default")))
39  #include <stdbool.h>
40  #define SIZE_T_FRMT_SPECIFIER "%zu"
41 #if __GNUC__ >= 4 && __GNUC_MINOR > 4
42  #define AF_DEPRECATED(msg) __attribute__((deprecated( msg )))
43 #else
44  #define AF_DEPRECATED(msg) __attribute__((deprecated))
45 #endif
46 #endif
47 
48 // Known 64-bit x86 and ARM architectures use long long
49 #if defined(__x86_64__) || defined(_M_X64) || defined(_WIN64) || defined(__aarch64__) || defined(__LP64__) // 64-bit Architectures
50  typedef long long dim_t;
51 // Known 32-bit x86 and ARM architectures use int
52 #elif defined(__i386__) || defined(_M_IX86) || defined(__arm__) || defined(_M_ARM) // 32-bit x86 Architecture
53  typedef int dim_t;
54 // All other platforms use long long
55 #else
56  typedef long long dim_t;
57 #endif
58 
59 #include <stdlib.h>
60 
61 #ifndef AFDLL // prevents the use of these types internally
62 typedef AF_DEPRECATED("intl is deprecated. Use long long instead.") long long intl;
63 typedef AF_DEPRECATED("uintl is deprecated. Use unsigned long long instead.") unsigned long long uintl;
64 #endif
65 
66 #include <af/version.h>
67 #ifndef AF_API_VERSION
68 #define AF_API_VERSION AF_API_VERSION_CURRENT
69 #endif
70 
71 typedef enum {
76 
77  // 100-199 Errors in environment
78 
82  , AF_ERR_NO_MEM = 101
83 
87  , AF_ERR_DRIVER = 102
88 
93 
94  // 200-299 Errors in input parameters
95 
100 
104  , AF_ERR_ARG = 202
105 
109  , AF_ERR_SIZE = 203
110 
114  , AF_ERR_TYPE = 204
115 
120 
124  , AF_ERR_BATCH = 207
125 
126 
127 #if AF_API_VERSION >= 33
128  , AF_ERR_DEVICE = 208
132 #endif
133 
134  // 300-399 Errors for missing software features
135 
140 
145 
146 #if AF_API_VERSION >= 32
147  , AF_ERR_NONFREE = 303
151 #endif
152 
153  // 400-499 Errors for missing hardware features
154 
159 
165 
166 #if AF_API_VERSION >= 37
167  , AF_ERR_NO_HALF = 403
171 #endif
172 
173  // 500-599 Errors specific to heterogenous API
174 
175 #if AF_API_VERSION >= 32
176  , AF_ERR_LOAD_LIB = 501
180 #endif
181 
182 #if AF_API_VERSION >= 32
183  , AF_ERR_LOAD_SYM = 502
187 #endif
188 
189 #if AF_API_VERSION >= 32
194 #endif
195 
196  // 900-999 Errors from upstream libraries and runtimes
197 
203 
208 } af_err;
209 
210 typedef enum {
211  f32,
212  c32,
213  f64,
214  c64,
215  b8 ,
216  s32,
217  u32,
218  u8 ,
219  s64,
221 #if AF_API_VERSION >= 32
222  , s16
223 #endif
224 #if AF_API_VERSION >= 32
225  , u16
226 #endif
227 #if AF_API_VERSION >= 37
228  , f16
229 #endif
230 } af_dtype;
231 
232 typedef enum {
235 } af_source;
236 
237 #define AF_MAX_DIMS 4
238 
239 // A handle for an internal array object
240 typedef void * af_array;
241 
242 typedef enum {
248 #if AF_API_VERSION >= 34
250 #endif
251 #if AF_API_VERSION >= 34
253 #endif
254 #if AF_API_VERSION >= 34
256 #endif
257 #if AF_API_VERSION >= 34
259 #endif
260 #if AF_API_VERSION >= 34
262 #endif
263 
265 
266 typedef enum {
271 
276 
281 
287 
288 typedef enum {
293 
299 
300 typedef enum {
301 
306 
311 } af_conv_mode;
312 
313 typedef enum {
318 
319 typedef enum {
320  AF_SAD = 0,
329 } af_match_type;
330 
331 #if AF_API_VERSION >= 31
332 typedef enum {
333  AF_YCC_601 = 601,
334  AF_YCC_709 = 709,
335  AF_YCC_2020 = 2020
336 } af_ycc_std;
337 #endif
338 
339 typedef enum {
340  AF_GRAY = 0,
343 #if AF_API_VERSION >= 31
345 #endif
346 } af_cspace_t;
347 
348 typedef enum {
356  AF_MAT_SYM = 512,
357  AF_MAT_POSDEF = 1024,
358  AF_MAT_ORTHOG = 2048,
361 } af_mat_prop;
362 
363 typedef enum {
372 
374 } af_norm_type;
375 
376 #if AF_API_VERSION >= 31
377 typedef enum {
382  AF_FIF_PNG = 13,
383  AF_FIF_PPM = 14,
385  AF_FIF_TIFF = 18,
386  AF_FIF_PSD = 20,
387  AF_FIF_HDR = 26,
388  AF_FIF_EXR = 29,
389  AF_FIF_JP2 = 31,
392 #endif
393 
394 #if AF_API_VERSION >=34
395 typedef enum {
402 #endif
403 
404 #if AF_API_VERSION >= 32
405 typedef enum {
409 #endif
410 
411 #if AF_API_VERSION >= 32
412 // These enums should be 2^x
413 typedef enum {
419 } af_backend;
420 #endif
421 
422 // Below enum is purely added for example purposes
423 // it doesn't and shoudn't be used anywhere in the
424 // code. No Guarantee's provided if it is used.
425 typedef enum {
426  AF_ID = 0
427 } af_someenum_t;
428 
429 #if AF_API_VERSION >=34
430 typedef enum {
435 } af_binary_op;
436 #endif
437 
438 #if AF_API_VERSION >=34
439 typedef enum {
440  AF_RANDOM_ENGINE_PHILOX_4X32_10 = 100, //Philox variant with N = 4, W = 32 and Rounds = 10
441  AF_RANDOM_ENGINE_THREEFRY_2X32_16 = 200, //Threefry variant with N = 2, W = 32 and Rounds = 16
442  AF_RANDOM_ENGINE_MERSENNE_GP11213 = 300, //Mersenne variant with MEXP = 11213
448 #endif
449 
451 // FORGE / Graphics Related Enums
452 // These enums have values corresponsding to Forge enums in forge defines.h
454 typedef enum {
466 } af_colormap;
467 
468 #if AF_API_VERSION >= 32
469 typedef enum {
479 #endif
480 
482 #if AF_API_VERSION >= 35
483 typedef enum {
487 #endif
488 
489 #if AF_API_VERSION >= 34
490 typedef enum {
495 } af_storage;
496 #endif
497 
498 #if AF_API_VERSION >= 36
499 typedef enum {
504 
505 typedef enum {
510 
511 typedef enum {
519 #endif
520 
521 #if AF_API_VERSION >= 37
522 typedef enum {
526 } af_var_bias;
527 
528 typedef enum {
533 
534 typedef enum {
538 
539 #endif
540 
541 #if AF_API_VERSION >= 37
542 typedef enum {
548 #endif
549 
550 #ifdef __cplusplus
551 namespace af
552 {
553  typedef af_dtype dtype;
554  typedef af_source source;
560  typedef af_someenum_t SomeEnum; // Purpose of Addition: How to add Function example
567 #if AF_API_VERSION >= 31
569 #endif
570 #if AF_API_VERSION >= 31
572 #endif
573 #if AF_API_VERSION >= 32
575 #endif
576 #if AF_API_VERSION >= 32
578 #endif
579 #if AF_API_VERSION >= 34
581 #endif
582 #if AF_API_VERSION >= 34
584 #endif
585 #if AF_API_VERSION >= 34
587 #endif
588 #if AF_API_VERSION >= 34
590 #endif
591 #if AF_API_VERSION >= 35
593 #endif
594 #if AF_API_VERSION >= 36
598 #endif
599 #if AF_API_VERSION >= 37
604 #endif
605 }
606 
607 #endif
af_canny_threshold
Definition: defines.h:483
af_source source
Definition: defines.h:554
af_random_engine_type
Definition: defines.h:439
Determine canny algorithm thresholds using Otsu algorithm.
Definition: defines.h:485
Gradient diffusion equation.
Definition: defines.h:506
Top k min with stable indices.
Definition: defines.h:515
af_flux_function
Definition: defines.h:499
af_ycc_std
Definition: defines.h:332
Matrix is symmetric.
Definition: defines.h:356
returns the max singular value). Currently NOT SUPPORTED
Definition: defines.h:370
Match based on Sum of Squared Differences (SSD)
Definition: defines.h:323
af_someenum_t SomeEnum
Definition: defines.h:560
af_backend
Definition: defines.h:413
af_colormap ColorMap
Definition: defines.h:565
Cubic Interpolation.
Definition: defines.h:246
Matrix is orthogonal.
Definition: defines.h:358
Linear Interpolation.
Definition: defines.h:244
Definition: algorithm.h:14
Out of bound values are clamped to the edge.
Definition: defines.h:280
Definition: defines.h:426
Device pointer.
Definition: defines.h:233
FreeImage Enum for RAW Camera Image File.
Definition: defines.h:390
Out of bound values are mapped to range of the dimension in cyclic fashion.
Definition: defines.h:285
Perceptually uniform shades of black-red-yellow.
Definition: defines.h:462
FreeImage Enum for JPEG Network Graphics File.
Definition: defines.h:381
CPU a.k.a sequential algorithms.
Definition: defines.h:415
af_topk_function topkFunction
Definition: defines.h:597
The function returned successfully.
Definition: defines.h:75
af_norm_type
Definition: defines.h:363
af_border_type
Definition: defines.h:266
ITU-R BT.709 standard.
Definition: defines.h:334
af_iterative_deconv_algo
Definition: defines.h:528
af_inverse_deconv_algo
Definition: defines.h:534
Output of the convolution is signal_len + filter_len - 1.
Definition: defines.h:310
af_canny_threshold cannyThreshold
Definition: defines.h:592
FreeImage Enum for Bitmap File.
Definition: defines.h:378
Blue hue map.
Definition: defines.h:461
Matrix is upper triangular.
Definition: defines.h:353
Bilinear Interpolation with cosine smoothing.
Definition: defines.h:252
3-channel YCbCr
Definition: defines.h:344
#define AF_DEPRECATED(msg)
Definition: defines.h:44
Matrix diagonal contains unitary values.
Definition: defines.h:355
af_inverse_deconv_algo inverseDeconvAlgo
Definition: defines.h:602
Landweber Deconvolution.
Definition: defines.h:529
Output of the convolution is the same size as input.
Definition: defines.h:305
Mood map.
Definition: defines.h:459
32-bit signed integral values
Definition: defines.h:216
af_ycc_std YCCStd
Definition: defines.h:568
af_diffusion_eq diffusionEq
Definition: defines.h:596
Matrix is positive definite.
Definition: defines.h:357
FreeImage Enum for Windows Icon File.
Definition: defines.h:379
Default backend order: OpenCL -> CUDA -> CPU.
Definition: defines.h:414
CUDA Compute Backend.
Definition: defines.h:416
Match based on Zero mean SAD.
Definition: defines.h:321
User has to define canny thresholds manually.
Definition: defines.h:484
64-bit signed integral values
Definition: defines.h:219
af_var_bias varBias
Definition: defines.h:600
16-bit signed integral values
Definition: defines.h:222
Match based on Zero mean SSD.
Definition: defines.h:324
Grayscale.
Definition: defines.h:340
Bicubic Interpolation with Catmull-Rom splines.
Definition: defines.h:261
Match based on Zero mean NCC.
Definition: defines.h:327
16-bit unsigned integral values
Definition: defines.h:225
af_backend Backend
Definition: defines.h:574
Default.
Definition: defines.h:349
af_interp_type
Definition: defines.h:242
Match based on Locally scaled SSD.
Definition: defines.h:325
Perceptually uniform shades of blue-red-yellow.
Definition: defines.h:464
af_binary_op binaryOp
Definition: defines.h:586
Bicubic Interpolation.
Definition: defines.h:255
af_random_engine_type randomEngineType
Definition: defines.h:589
FreeImage Enum for JPEG File.
Definition: defines.h:380
Data needs to be conjugate tansposed.
Definition: defines.h:351
64-bit floating point values
Definition: defines.h:213
Match based on Normalized Cross Correlation (NCC)
Definition: defines.h:326
treats the input as a vector and returns the p-norm
Definition: defines.h:367
af_storage
Definition: defines.h:490
af_image_format imageFormat
Definition: defines.h:571
af_homography_type
Definition: defines.h:405
af_conv_domain
Definition: defines.h:313
FreeImage Enum for Adobe Photoshop File.
Definition: defines.h:386
af_colormap
Definition: defines.h:454
Computes homography using Least Median of Squares.
Definition: defines.h:407
Data needs to be conjugate.
Definition: defines.h:352
Sample variance.
Definition: defines.h:524
return the max of row sums
Definition: defines.h:369
FreeImage Enum for Portable Pixelmap (ASCII) File.
Definition: defines.h:383
Out of bound values are symmetric over the edge.
Definition: defines.h:275
Storage type is CSC.
Definition: defines.h:493
Spectrum map (390nm-830nm, in sRGB colorspace)
Definition: defines.h:456
3-channel HSV
Definition: defines.h:342
af_connectivity
Definition: defines.h:288
Computes homography using RANSAC.
Definition: defines.h:406
returns Lpq-norm
Definition: defines.h:371
af_iterative_deconv_algo iterativeDeconvAlgo
Definition: defines.h:601
FreeImage Enum for JPEG-2000 File.
Definition: defines.h:389
af_err
Definition: defines.h:71
Match based on Locally scaled SAD.
Definition: defines.h:322
af_source
Definition: defines.h:232
Connectivity includes neighbors, North, East, South and West of current pixel.
Definition: defines.h:292
64-bit unsigned integral values
Definition: defines.h:220
af_someenum_t
Definition: defines.h:425
af_conv_gradient_type
Definition: defines.h:542
af_conv_mode
Definition: defines.h:300
Storage type is CSR.
Definition: defines.h:492
af_storage storage
Definition: defines.h:583
ITU-R BT.601 (formerly CCIR 601) standard.
Definition: defines.h:333
Out of bound values are 0.
Definition: defines.h:270
Bilinear Interpolation.
Definition: defines.h:245
Storage type is COO.
Definition: defines.h:494
Population variance.
Definition: defines.h:525
64-bit complex floating point values
Definition: defines.h:214
long long dim_t
Definition: defines.h:56
af_conv_gradient_type convGradientType
Definition: defines.h:603
OpenCL Compute Backend.
Definition: defines.h:417
af_marker_type
Definition: defines.h:469
af_diffusion_eq
Definition: defines.h:505
Cubic Interpolation with Catmull-Rom splines.
Definition: defines.h:258
FreeImage Enum for Tagged Image File Format File.
Definition: defines.h:385
ArrayFire automatically picks the right convolution algorithm.
Definition: defines.h:314
32-bit complex floating point values
Definition: defines.h:212
af_mat_prop matProp
Definition: defines.h:564
af_var_bias
Definition: defines.h:522
af_norm_type normType
Definition: defines.h:566
treats the input as a vector and returns the max of absolute values
Definition: defines.h:365
Matrix is block diagonal.
Definition: defines.h:360
OneAPI Compute Backend.
Definition: defines.h:418
Connectivity includes 4-connectivity neigbors and also those on Northeast, Northwest, Southeast and Southwest.
Definition: defines.h:297
af_conv_domain convDomain
Definition: defines.h:563
af_topk_function
Definition: defines.h:511
Default (Population) variance.
Definition: defines.h:523
The default. Same as AF_NORM_VECTOR_2.
Definition: defines.h:373
Modified curvature diffusion equation.
Definition: defines.h:507
Top k max values.
Definition: defines.h:513
8-bit unsigned integral values
Definition: defines.h:218
af_border_type borderType
Definition: defines.h:556
FreeImage Enum for ILM OpenEXR File.
Definition: defines.h:388
Perform convolution in spatial domain.
Definition: defines.h:315
af_binary_op
Definition: defines.h:430
Top k max with stable indices.
Definition: defines.h:516
Perform convolution in frequency domain.
Definition: defines.h:316
Match based on Sum of Hamming Distances (SHD)
Definition: defines.h:328
Match based on Sum of Absolute Differences (SAD)
Definition: defines.h:320
Tikhonov Inverse deconvolution.
Definition: defines.h:535
Data needs to be transposed.
Definition: defines.h:350
return the max of column sums
Definition: defines.h:368
af_mat_prop trans
Definition: defines.h:561
Default is Tikhonov deconvolution.
Definition: defines.h:536
Nearest Interpolation.
Definition: defines.h:243
unsigned long long uintl
Definition: defines.h:63
Perceptually uniform shades of blue-green-yellow.
Definition: defines.h:465
3-channel RGB
Definition: defines.h:341
af_mat_prop
Definition: defines.h:348
16-bit floating point value
Definition: defines.h:228
Linear Interpolation with cosine smoothing.
Definition: defines.h:249
Exponential flux function.
Definition: defines.h:501
32-bit unsigned integral values
Definition: defines.h:217
FreeImage Enum for High Dynamic Range File.
Definition: defines.h:387
af_cspace_t
Definition: defines.h:339
Default grayscale map.
Definition: defines.h:455
Default option is same as AF_DIFFUSION_GRAD.
Definition: defines.h:508
Matrix is lower triangular.
Definition: defines.h:354
FreeImage Enum for Portable Network Graphics File.
Definition: defines.h:382
FreeImage Enum for Portable Pixelmap (Binary) File.
Definition: defines.h:384
void * af_array
Definition: defines.h:240
Perceptually uniform shades of black-red-white.
Definition: defines.h:463
af_image_format
Definition: defines.h:377
af_match_type matchType
Definition: defines.h:558
af_moment_type
Definition: defines.h:395
Matrix is tri diagonal.
Definition: defines.h:359
Top k min values.
Definition: defines.h:512
af_cspace_t CSpace
Definition: defines.h:559
32-bit floating point values
Definition: defines.h:211
treats the input as a vector and returns euclidean norm
Definition: defines.h:366
Heat map.
Definition: defines.h:460
Preserve order of indices for equal values.
Definition: defines.h:514
af_flux_function fluxFunction
Definition: defines.h:595
treats the input as a vector and returns the sum of absolute values
Definition: defines.h:364
8-bit boolean values
Definition: defines.h:215
Default option (max)
Definition: defines.h:517
Floor Indexed.
Definition: defines.h:247
Storage type is dense.
Definition: defines.h:491
Host pointer.
Definition: defines.h:234
Quadratic flux function.
Definition: defines.h:500
af_marker_type markerType
Definition: defines.h:577
af_dtype
Definition: defines.h:210
af_interp_type interpType
Definition: defines.h:555
af_match_type
Definition: defines.h:319
Red hue map.
Definition: defines.h:458
af_moment_type momentType
Definition: defines.h:580
af_conv_mode convMode
Definition: defines.h:562
af_dtype dtype
Definition: defines.h:553
long long intl
Definition: defines.h:62
Default is Landweber deconvolution.
Definition: defines.h:531
Colors, aka. Rainbow.
Definition: defines.h:457
Richardson-Lucy Deconvolution.
Definition: defines.h:530
Default flux function is exponential.
Definition: defines.h:502
af_connectivity connectivity
Definition: defines.h:557
ITU-R BT.2020 standard.
Definition: defines.h:335