Get information about the array object. More...

Functions

const array as (dtype type) const
 Converts the array into another type. More...
 
array T () const
 Get the transposed the array. More...
 
array H () const
 Get the conjugate-transpose of the current array. More...
 
AFAPI af_err af_copy_array (af_array *arr, const af_array in)
 
AFAPI af_err af_get_data_ref_count (int *use_count, const af_array in)
 
AFAPI af_err af_write_array (af_array arr, const void *data, const size_t bytes, af_source src)
 Copy data from a C pointer (host/device) to an existing array. More...
 
AFAPI af_err af_get_data_ptr (void *data, const af_array arr)
 Copy data from an af_array to a C pointer. More...
 
AFAPI af_err af_release_array (af_array arr)
 Reduce the reference count of the af_array. More...
 
AFAPI af_err af_retain_array (af_array *out, const af_array in)
 Increments an af_array reference count. More...
 
AFAPI af_err af_eval (af_array in)
 Evaluate any expressions in the Array. More...
 
AFAPI af_err af_get_elements (dim_t *elems, const af_array arr)
 Get the total number of elements across all dimensions of the array. More...
 
AFAPI af_err af_get_type (af_dtype *type, const af_array arr)
 Gets the type of an array. More...
 
AFAPI af_err af_get_dims (dim_t *d0, dim_t *d1, dim_t *d2, dim_t *d3, const af_array arr)
 Gets the dimensions of an array. More...
 
AFAPI af_err af_get_numdims (unsigned *result, const af_array arr)
 Gets the number of dimensions of an array. More...
 
AFAPI af_err af_is_empty (bool *result, const af_array arr)
 Check if an array is empty. More...
 
AFAPI af_err af_is_scalar (bool *result, const af_array arr)
 Check if an array is scalar, ie. More...
 
AFAPI af_err af_is_row (bool *result, const af_array arr)
 Check if an array is row vector. More...
 
AFAPI af_err af_is_column (bool *result, const af_array arr)
 Check if an array is a column vector. More...
 
AFAPI af_err af_is_vector (bool *result, const af_array arr)
 Check if an array is a vector. More...
 
AFAPI af_err af_is_complex (bool *result, const af_array arr)
 Check if an array is complex type. More...
 
AFAPI af_err af_is_real (bool *result, const af_array arr)
 Check if an array is real type. More...
 
AFAPI af_err af_is_double (bool *result, const af_array arr)
 Check if an array is double precision type. More...
 
AFAPI af_err af_is_single (bool *result, const af_array arr)
 Check if an array is single precision type. More...
 
AFAPI af_err af_is_half (bool *result, const af_array arr)
 Check if an array is 16 bit floating point type. More...
 
AFAPI af_err af_is_realfloating (bool *result, const af_array arr)
 Check if an array is real floating point type. More...
 
AFAPI af_err af_is_floating (bool *result, const af_array arr)
 Check if an array is floating precision type. More...
 
AFAPI af_err af_is_integer (bool *result, const af_array arr)
 Check if an array is integer type. More...
 
AFAPI af_err af_is_bool (bool *result, const af_array arr)
 Check if an array is bool type. More...
 
AFAPI af_err af_is_sparse (bool *result, const af_array arr)
 Check if an array is sparse. More...
 
AFAPI af_err af_get_scalar (void *output_value, const af_array arr)
 Get first element from an array. More...
 
arrayeval (array &a)
 Evaluate an expression (nonblocking). More...
 
const arrayeval (const array &a)
 Evaluate an expression (nonblocking). More...
 
AFAPI void eval (int num, array **arrays)
 Evaluate multiple arrays simultaneously. More...
 
void eval (array &a, array &b)
 
void eval (array &a, array &b, array &c)
 
void eval (array &a, array &b, array &c, array &d)
 
void eval (array &a, array &b, array &c, array &d, array &e)
 
void eval (array &a, array &b, array &c, array &d, array &e, array &f)
 
void eval (const array &a, const array &b)
 
void eval (const array &a, const array &b, const array &c)
 
void eval (const array &a, const array &b, const array &c, const array &d)
 
void eval (const array &a, const array &b, const array &c, const array &d, const array &e)
 
void eval (const array &a, const array &b, const array &c, const array &d, const array &e, const array &f)
 
AFAPI void setManualEvalFlag (bool flag)
 Turn the manual eval flag on or off. More...
 
AFAPI bool getManualEvalFlag ()
 Get the manual eval flag. More...
 
af_array get ()
 get the af_array handle More...
 
af_array get () const
 get the af_array handle More...
 
dim_t elements () const
 Get the total number of elements across all dimensions of the array. More...
 
template<typename T >
Thost () const
 Copy array data to host and return host pointer. More...
 
void host (void *ptr) const
 Copy array data to existing host pointer. More...
 
template<typename T >
void write (const T *ptr, const size_t bytes, af::source src=afHost)
 Perform deep copy from host/device pointer to an existing array. More...
 
dtype type () const
 Get array data type. More...
 
dim4 dims () const
 Get dimensions of the array. More...
 
dim_t dims (unsigned dim) const
 Get dimensions of the array. More...
 
unsigned numdims () const
 Get the number of dimensions of the array. More...
 
size_t bytes () const
 Get the size of the array in bytes. More...
 
size_t allocated () const
 Get the size of the array in memory. More...
 
array copy () const
 Perform deep copy of the array. More...
 
bool isempty () const
 Returns true of the array is empty. More...
 
bool isscalar () const
 Returns true of the array contains only one value. More...
 
bool isvector () const
 Returns true if only one of the array dimensions has more than one element. More...
 
bool isrow () const
 Returns true if only the second dimension has more than one element. More...
 
bool iscolumn () const
 Returns true if only the first dimension has more than one element. More...
 
bool iscomplex () const
 Returns true if the array type is c32 or c64. More...
 
bool isreal () const
 Returns true if the array type is neither c32 nor c64. More...
 
bool isdouble () const
 Returns true if the array type is f64 or c64. More...
 
bool issingle () const
 Returns true if the array type is either f32 nor c32. More...
 
bool ishalf () const
 Returns true if the array type is f16. More...
 
bool isrealfloating () const
 Returns true if the array type is f16 f32 or f64. More...
 
bool isfloating () const
 Returns true if the array type is f16 f32, f64, c32 or c64. More...
 
bool isinteger () const
 Returns true if the array type is u8, b8, s32 u32, s64, u64, s16, u16. More...
 
bool isbool () const
 Returns true if the array type is b8. More...
 
bool issparse () const
 Returns true if the array is a sparse array. More...
 
void eval () const
 Evaluate any JIT expressions to generate data for the array. More...
 
template<typename T >
T scalar () const
 Get the first element of the array as a scalar. More...
 

Detailed Description

Get information about the array object.

Function Documentation

◆ af_copy_array()

AFAPI af_err af_copy_array ( af_array arr,
const af_array  in 
)

Deep copy an array to another

◆ af_eval()

AFAPI af_err af_eval ( af_array  in)

Evaluate any expressions in the Array.

◆ af_get_data_ptr()

AFAPI af_err af_get_data_ptr ( void *  data,
const af_array  arr 
)

Copy data from an af_array to a C pointer.

Needs to used in conjunction with the two functions above

◆ af_get_data_ref_count()

AFAPI af_err af_get_data_ref_count ( int *  use_count,
const af_array  in 
)

Get the reference count of af_array

◆ af_get_dims()

AFAPI af_err af_get_dims ( dim_t d0,
dim_t d1,
dim_t d2,
dim_t d3,
const af_array  arr 
)

Gets the dimensions of an array.

Parameters
[out]d0is the output that contains the size of first dimension of arr
[out]d1is the output that contains the size of second dimension of arr
[out]d2is the output that contains the size of third dimension of arr
[out]d3is the output that contains the size of fourth dimension of arr
[in]arris the input array
Returns
error codes

◆ af_get_elements()

AFAPI af_err af_get_elements ( dim_t elems,
const af_array  arr 
)

Get the total number of elements across all dimensions of the array.

Parameters
[out]elemsis the output that contains number of elements of arr
[in]arris the input array
Returns
error codes

◆ af_get_numdims()

AFAPI af_err af_get_numdims ( unsigned *  result,
const af_array  arr 
)

Gets the number of dimensions of an array.

Parameters
[out]resultis the output that contains the number of dims of arr
[in]arris the input array
Returns
error codes

◆ af_get_scalar()

AFAPI af_err af_get_scalar ( void *  output_value,
const af_array  arr 
)

Get first element from an array.

Parameters
[out]output_valueis the element requested
[in]arris the input array
Returns
AF_SUCCESS if the execution completes properly

◆ af_get_type()

AFAPI af_err af_get_type ( af_dtype type,
const af_array  arr 
)

Gets the type of an array.

Parameters
[out]typeis the output that contains the type of arr
[in]arris the input array
Returns
error codes

◆ af_is_bool()

AFAPI af_err af_is_bool ( bool *  result,
const af_array  arr 
)

Check if an array is bool type.

Parameters
[out]resultis true if arr is of b8 type, otherwise false
[in]arris the input array
Returns
error codes

◆ af_is_column()

AFAPI af_err af_is_column ( bool *  result,
const af_array  arr 
)

Check if an array is a column vector.

Parameters
[out]resultis true if arr has dims [x 1 1 1], false otherwise
[in]arris the input array
Returns
error codes

◆ af_is_complex()

AFAPI af_err af_is_complex ( bool *  result,
const af_array  arr 
)

Check if an array is complex type.

Parameters
[out]resultis true if arr is of type c32 or c64, otherwise false
[in]arris the input array
Returns
error codes

◆ af_is_double()

AFAPI af_err af_is_double ( bool *  result,
const af_array  arr 
)

Check if an array is double precision type.

Parameters
[out]resultis true if arr is of type f64 or c64, otherwise false
[in]arris the input array
Returns
error codes

◆ af_is_empty()

AFAPI af_err af_is_empty ( bool *  result,
const af_array  arr 
)

Check if an array is empty.

Parameters
[out]resultis true if elements of arr is 0, otherwise false
[in]arris the input array
Returns
error codes

◆ af_is_floating()

AFAPI af_err af_is_floating ( bool *  result,
const af_array  arr 
)

Check if an array is floating precision type.

This is a combination of af_is_realfloating and af_is_complex

Parameters
[out]resultis true if arr is of type f16 f32, f64, c32 or c64, otherwise false
[in]arris the input array
Returns
error codes

◆ af_is_half()

AFAPI af_err af_is_half ( bool *  result,
const af_array  arr 
)

Check if an array is 16 bit floating point type.

Parameters
[out]resultis true if arr is of type f16 otherwise false
[in]arris the input array
Returns
error codes

◆ af_is_integer()

AFAPI af_err af_is_integer ( bool *  result,
const af_array  arr 
)

Check if an array is integer type.

Parameters
[out]resultis true if arr is of integer types, otherwise false
[in]arris the input array
Returns
error codes

◆ af_is_real()

AFAPI af_err af_is_real ( bool *  result,
const af_array  arr 
)

Check if an array is real type.

This is mutually exclusive to af_is_complex

Parameters
[out]resultis true if arr is NOT c32 or c64, otherwise false
[in]arris the input array
Returns
error codes

◆ af_is_realfloating()

AFAPI af_err af_is_realfloating ( bool *  result,
const af_array  arr 
)

Check if an array is real floating point type.

Parameters
[out]resultis true if arr is of type f32 or f64, otherwise false
[in]arris the input array
Returns
error codes

◆ af_is_row()

AFAPI af_err af_is_row ( bool *  result,
const af_array  arr 
)

Check if an array is row vector.

Parameters
[out]resultis true if arr has dims [1 x 1 1], false otherwise
[in]arris the input array
Returns
error codes

◆ af_is_scalar()

AFAPI af_err af_is_scalar ( bool *  result,
const af_array  arr 
)

Check if an array is scalar, ie.

single element.

Parameters
[out]resultis true if elements of arr is 1, otherwise false
[in]arris the input array
Returns
error codes

◆ af_is_single()

AFAPI af_err af_is_single ( bool *  result,
const af_array  arr 
)

Check if an array is single precision type.

Parameters
[out]resultis true if arr is of type f32 or c32, otherwise false
[in]arris the input array
Returns
error codes

◆ af_is_sparse()

AFAPI af_err af_is_sparse ( bool *  result,
const af_array  arr 
)

Check if an array is sparse.

Parameters
[out]resultis true if arr is sparse, otherwise false
[in]arris the input array
Returns
error codes

◆ af_is_vector()

AFAPI af_err af_is_vector ( bool *  result,
const af_array  arr 
)

Check if an array is a vector.

A vector is any array that has exactly 1 dimension not equal to 1.

Parameters
[out]resultis true if arr is a vector, false otherwise
[in]arris the input array
Returns
error codes

◆ af_release_array()

AFAPI af_err af_release_array ( af_array  arr)

Reduce the reference count of the af_array.

Note
Zero initialized af_arrays can be accepted after version 3.7

◆ af_retain_array()

AFAPI af_err af_retain_array ( af_array out,
const af_array  in 
)

Increments an af_array reference count.

◆ af_write_array()

AFAPI af_err af_write_array ( af_array  arr,
const void *  data,
const size_t  bytes,
af_source  src 
)

Copy data from a C pointer (host/device) to an existing array.

◆ allocated()

size_t allocated ( ) const

Get the size of the array in memory.

This will return the parent's bytes() if the array is indexed.

◆ as()

◆ bytes()

size_t bytes ( ) const

Get the size of the array in bytes.

Examples
benchmarks/cg.cpp.

◆ copy()

◆ dims() [1/2]

◆ dims() [2/2]

dim_t dims ( unsigned  dim) const

Get dimensions of the array.

◆ elements()

◆ eval() [1/14]

◆ eval() [2/14]

array& af::eval ( array a)
inline

Evaluate an expression (nonblocking).

Examples
financial/black_scholes_options.cpp, graphics/fractal.cpp, and pde/swe.cpp.

Definition at line 1379 of file array.h.

1382 {

◆ eval() [3/14]

void af::eval ( array a,
array b 
)
inline

Definition at line 1388 of file array.h.

1392  {
1393 #if AF_API_VERSION >= 34
1394  array *arrays[] = {&a, &b, &c};
1395  return eval(3, arrays);
1396 #else

◆ eval() [4/14]

void af::eval ( array a,
array b,
array c 
)
inline

Definition at line 1398 of file array.h.

1402  {
1403 #if AF_API_VERSION >= 34
1404  array *arrays[] = {&a, &b, &c, &d};
1405  return eval(4, arrays);
1406 #else

◆ eval() [5/14]

void af::eval ( array a,
array b,
array c,
array d 
)
inline

Definition at line 1408 of file array.h.

1413  {
1414 #if AF_API_VERSION >= 34
1415  array *arrays[] = {&a, &b, &c, &d, &e};
1416  return eval(5, arrays);
1417 #else

◆ eval() [6/14]

void af::eval ( array a,
array b,
array c,
array d,
array e 
)
inline

Definition at line 1419 of file array.h.

1423  {
1424 #if AF_API_VERSION >= 34
1425  array *arrays[] = {&a, &b, &c, &d, &e, &f};
1426  return eval(6, arrays);
1427 #else

◆ eval() [7/14]

void af::eval ( array a,
array b,
array c,
array d,
array e,
array f 
)
inline

Definition at line 1429 of file array.h.

1439  { a.eval(); return a; }

◆ eval() [8/14]

const array& af::eval ( const array a)
inline

Evaluate an expression (nonblocking).

Definition at line 1446 of file array.h.

1451 {

◆ eval() [9/14]

void af::eval ( const array a,
const array b 
)
inline

Definition at line 1457 of file array.h.

1457  {
1458  const array *arrays[] = {&a, &b, &c};
1459  return eval(3, const_cast<array **>(arrays));
1460  }
1461 

◆ eval() [10/14]

void af::eval ( const array a,
const array b,
const array c 
)
inline

Definition at line 1463 of file array.h.

1464  {
1465  const array *arrays[] = {&a, &b, &c, &d};
1466  return eval(4, const_cast<array **>(arrays));
1467  }

◆ eval() [11/14]

void af::eval ( const array a,
const array b,
const array c,
const array d 
)
inline

Definition at line 1469 of file array.h.

1471  {
1472  const array *arrays[] = {&a, &b, &c, &d, &e};
1473  return eval(5, const_cast<array **>(arrays));
1474  }

◆ eval() [12/14]

void af::eval ( const array a,
const array b,
const array c,
const array d,
const array e 
)
inline

Definition at line 1476 of file array.h.

1478  {
1479  const array *arrays[] = {&a, &b, &c, &d, &e, &f};
1480  return eval(6, const_cast<array **>(arrays));
1481  }

◆ eval() [13/14]

void af::eval ( const array a,
const array b,
const array c,
const array d,
const array e,
const array f 
)
inline

Definition at line 1483 of file array.h.

1505  {

◆ eval() [14/14]

AFAPI void af::eval ( int  num,
array **  arrays 
)

Evaluate multiple arrays simultaneously.

◆ get() [1/2]

af_array get ( )

get the af_array handle

◆ get() [2/2]

af_array get ( ) const

get the af_array handle

◆ getManualEvalFlag()

AFAPI bool af::getManualEvalFlag ( )

Get the manual eval flag.

◆ H()

array H ( ) const

Get the conjugate-transpose of the current array.

Returns
conjugate-transpose matrix

◆ host() [1/2]

T* host ( ) const

◆ host() [2/2]

void host ( void *  ptr) const

Copy array data to existing host pointer.

◆ isbool()

bool isbool ( ) const

Returns true if the array type is b8.

◆ iscolumn()

bool iscolumn ( ) const

Returns true if only the first dimension has more than one element.

◆ iscomplex()

bool iscomplex ( ) const

Returns true if the array type is c32 or c64.

◆ isdouble()

bool isdouble ( ) const

Returns true if the array type is f64 or c64.

◆ isempty()

bool isempty ( ) const

Returns true of the array is empty.

◆ isfloating()

bool isfloating ( ) const

Returns true if the array type is f16 f32, f64, c32 or c64.

◆ ishalf()

bool ishalf ( ) const

Returns true if the array type is f16.

◆ isinteger()

bool isinteger ( ) const

Returns true if the array type is u8, b8, s32 u32, s64, u64, s16, u16.

◆ isreal()

bool isreal ( ) const
inline

Returns true if the array type is neither c32 nor c64.

Definition at line 671 of file array.h.

◆ isrealfloating()

bool isrealfloating ( ) const

Returns true if the array type is f16 f32 or f64.

◆ isrow()

bool isrow ( ) const

Returns true if only the second dimension has more than one element.

◆ isscalar()

bool isscalar ( ) const

Returns true of the array contains only one value.

◆ issingle()

bool issingle ( ) const

Returns true if the array type is either f32 nor c32.

◆ issparse()

bool issparse ( ) const

Returns true if the array is a sparse array.

◆ isvector()

bool isvector ( ) const

Returns true if only one of the array dimensions has more than one element.

◆ numdims()

unsigned numdims ( ) const

Get the number of dimensions of the array.

◆ scalar()

T scalar ( ) const

Get the first element of the array as a scalar.

Note
This is recommended for use while debugging. Calling this method constantly reduces performance.
Examples
image_processing/binary_thresholding.cpp, and machine_learning/kmeans.cpp.

◆ setManualEvalFlag()

AFAPI void af::setManualEvalFlag ( bool  flag)

Turn the manual eval flag on or off.

◆ T()

◆ type()

dtype type ( ) const

◆ write()

void write ( const T ptr,
const size_t  bytes,
af::source  src = afHost 
)

Perform deep copy from host/device pointer to an existing array.

afcl::array
static af::array array(af::dim4 idims, cl_mem buf, af::dtype type, bool retain=false)
Create an af::array object from an OpenCL cl_mem buffer.
Definition: opencl.h:327
af::eval
void eval(const array &a, const array &b, const array &c, const array &d, const array &e, const array &f)
Definition: array.h:1483