Skip to content
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ GPATH
docs/details/examples.dox
/TAGS
external/
extern/
compile_commands.json
venv
test/gtest
src/backend/cuda/cub
2 changes: 1 addition & 1 deletion include/af/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace af
~features();

/// Copy assignment operator
features& operator= (const features& f);
features& operator= (const features& other);

/// Returns the number of features represented by this object
size_t getNumFeatures() const;
Expand Down
5 changes: 3 additions & 2 deletions include/af/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@ class AFAPI Window {
Creates a window object with default width
and height with title set to "ArrayFire"

\param[in] wnd is an \ref af_window handle which can be retrieved by
\param[in] window is an \ref af_window handle which can be retrieved
by
doing a get call on any \ref Window object

\ingroup gfx_func_window
*/
Window(const af_window wnd);
Window(const af_window window);

/**
Destroys the window handle
Expand Down
8 changes: 4 additions & 4 deletions include/af/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ namespace af
/**
Copy constructor for \ref af::randomEngine.

\param[in] in The input random engine object
\param[in] other The input random engine object
*/
randomEngine(const randomEngine &in);
randomEngine(const randomEngine &other);

/**
Creates a copy of the random engine object from a \ref
Expand All @@ -73,11 +73,11 @@ namespace af
/**
\brief Assigns the internal state of randome engine

\param[in] in The object to be assigned to the random engine
\param[in] other The object to be assigned to the random engine

\returns the reference to this
*/
randomEngine &operator=(const randomEngine &in);
randomEngine &operator=(const randomEngine &other);

/**
\brief Sets the random type of the random engine
Expand Down
4 changes: 2 additions & 2 deletions include/af/seq.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ class AFAPI seq

Creates a copy seq from another sequence.

\param[in] afs seqence to be copies
\param[in] other seqence to be copies
\param[in] is_gfor is the gfor flag
*/
seq(seq afs, bool is_gfor);
seq(seq other, bool is_gfor);

/**
\brief Create a seq object from an \ref af_seq struct
Expand Down
391 changes: 391 additions & 0 deletions src/.clang-tidy

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions src/api/c/anisotropic_diffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@
#include <gradient.hpp>
#include <handle.hpp>
#include <reduce.hpp>

#include <af/dim4.hpp>
#include <af/image.h>

#include <type_traits>

using af::dim4;
using namespace detail;

template<typename T>
af_array diffusion(const Array<float> in, const float dt, const float K,
af_array diffusion(const Array<float>& in, const float dt, const float K,
const unsigned iterations, const af_flux_function fftype,
const af::diffusionEq eq) {
auto out = copyArray(in);
auto dims = out.dims();
auto g0 = createEmptyArray<float>(dims);
auto g1 = createEmptyArray<float>(dims);
float cnst = -2.0f * K * K / dims.elements();
auto out = copyArray(in);
auto dims = out.dims();
auto g0 = createEmptyArray<float>(dims);
auto g1 = createEmptyArray<float>(dims);
float cnst =
-2.0f * K * K / dims.elements(); // NOLINT(readability-magic-numbers)

for (unsigned i = 0; i < iterations; ++i) {
gradient<float>(g0, g1, out);
Expand Down Expand Up @@ -71,7 +72,7 @@ af_err af_anisotropic_diffusion(af_array* out, const af_array in,

auto input = castArray<float>(in);

af_array output = 0;
af_array output = nullptr;
switch (inputType) {
case f64:
output = diffusion<double>(input, dt, K, iterations, F, eq);
Expand Down
19 changes: 12 additions & 7 deletions src/api/c/approx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
#include <af/signal.h>

using af::dim4;
using namespace detail;
using detail::approx1;
using detail::approx2;
using detail::cdouble;
using detail::cfloat;

namespace {
template<typename Ty, typename Tp>
Expand Down Expand Up @@ -53,10 +56,10 @@ void af_approx1_common(af_array *yo, const af_array yi, const af_array xo,
const ArrayInfo &yi_info = getInfo(yi);
const ArrayInfo &xo_info = getInfo(xo);

const dim4 yi_dims = yi_info.dims();
const dim4 xo_dims = xo_info.dims();
dim4 yo_dims = yi_dims;
yo_dims[xdim] = xo_dims[xdim];
const dim4 &yi_dims = yi_info.dims();
const dim4 &xo_dims = xo_info.dims();
dim4 yo_dims = yi_dims;
yo_dims[xdim] = xo_dims[xdim];

ARG_ASSERT(1, yi_info.isFloating()); // Only floating and complex types
ARG_ASSERT(2, xo_info.isRealFloating()); // Only floating types
Expand All @@ -70,7 +73,7 @@ void af_approx1_common(af_array *yo, const af_array yi, const af_array xo,
// yi_dims[3])
if (xo_dims[xdim] != xo_dims.elements()) {
for (int i = 0; i < 4; i++) {
if (xdim != i) DIM_ASSERT(2, xo_dims[i] == yi_dims[i]);
if (xdim != i) { DIM_ASSERT(2, xo_dims[i] == yi_dims[i]); }
}
}

Expand Down Expand Up @@ -196,7 +199,9 @@ void af_approx2_common(af_array *zo, const af_array zi, const af_array xo,
// POS should either be (x, y, 1, 1) or (x, y, zi_dims[2], zi_dims[3])
if (xo_dims[xdim] * xo_dims[ydim] != xo_dims.elements()) {
for (int i = 0; i < 4; i++) {
if (xdim != i && ydim != i) DIM_ASSERT(2, xo_dims[i] == zi_dims[i]);
if (xdim != i && ydim != i) {
DIM_ASSERT(2, xo_dims[i] == zi_dims[i]);
}
}
}

Expand Down
76 changes: 38 additions & 38 deletions src/api/c/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
#include <sparse_handle.hpp>
#include <af/sparse.h>

using namespace detail;

using af::dim4;
using common::half;
using common::SparseArrayBase;

af_array createHandle(const af::dim4 &d, af_dtype dtype) {
using namespace detail;

using detail::cdouble;
using detail::cfloat;
using detail::intl;
using detail::uchar;
using detail::uint;
using detail::uintl;
using detail::ushort;

af_array createHandle(const dim4 &d, af_dtype dtype) {
// clang-format off
switch (dtype) {
case f32: return createHandle<float >(d);
Expand All @@ -44,9 +48,7 @@ af_array createHandle(const af::dim4 &d, af_dtype dtype) {
// clang-format on
}

af_array createHandleFromValue(const af::dim4 &d, double val, af_dtype dtype) {
using namespace detail;

af_array createHandleFromValue(const dim4 &d, double val, af_dtype dtype) {
// clang-format off
switch (dtype) {
case f32: return createHandleFromValue<float >(d, val);
Expand Down Expand Up @@ -161,7 +163,7 @@ af_err af_create_handle(af_array *result, const unsigned ndims,
try {
AF_CHECK(af_init());

if (ndims > 0) ARG_ASSERT(2, ndims > 0 && dims != NULL);
if (ndims > 0) { ARG_ASSERT(2, ndims > 0 && dims != NULL); }

dim4 d(0);
for (unsigned i = 0; i < ndims; i++) { d[i] = dims[i]; }
Expand All @@ -181,40 +183,39 @@ af_err af_copy_array(af_array *out, const af_array in) {

af_array res = 0;
if (info.isSparse()) {
SparseArrayBase sbase = getSparseArrayBase(in);
const SparseArrayBase sbase = getSparseArrayBase(in);
if (info.ndims() == 0) {
return af_create_sparse_array_from_ptr(
out, info.dims()[0], info.dims()[1], 0, nullptr, nullptr,
nullptr, type, sbase.getStorage(), afDevice);
} else {
switch (type) {
case f32: res = copySparseArray<float>(in); break;
case f64: res = copySparseArray<double>(in); break;
case c32: res = copySparseArray<cfloat>(in); break;
case c64: res = copySparseArray<cdouble>(in); break;
default: TYPE_ERROR(0, type);
}
}
switch (type) {
case f32: res = copySparseArray<float>(in); break;
case f64: res = copySparseArray<double>(in); break;
case c32: res = copySparseArray<cfloat>(in); break;
case c64: res = copySparseArray<cdouble>(in); break;
default: TYPE_ERROR(0, type);
}

} else {
if (info.ndims() == 0) {
return af_create_handle(out, 0, nullptr, type);
} else {
switch (type) {
case f32: res = copyArray<float>(in); break;
case c32: res = copyArray<cfloat>(in); break;
case f64: res = copyArray<double>(in); break;
case c64: res = copyArray<cdouble>(in); break;
case b8: res = copyArray<char>(in); break;
case s32: res = copyArray<int>(in); break;
case u32: res = copyArray<uint>(in); break;
case u8: res = copyArray<uchar>(in); break;
case s64: res = copyArray<intl>(in); break;
case u64: res = copyArray<uintl>(in); break;
case s16: res = copyArray<short>(in); break;
case u16: res = copyArray<ushort>(in); break;
case f16: res = copyArray<half>(in); break;
default: TYPE_ERROR(1, type);
}
}
switch (type) {
case f32: res = copyArray<float>(in); break;
case c32: res = copyArray<cfloat>(in); break;
case f64: res = copyArray<double>(in); break;
case c64: res = copyArray<cdouble>(in); break;
case b8: res = copyArray<char>(in); break;
case s32: res = copyArray<int>(in); break;
case u32: res = copyArray<uint>(in); break;
case u8: res = copyArray<uchar>(in); break;
case s64: res = copyArray<intl>(in); break;
case u64: res = copyArray<uintl>(in); break;
case s16: res = copyArray<short>(in); break;
case u16: res = copyArray<ushort>(in); break;
case f16: res = copyArray<half>(in); break;
default: TYPE_ERROR(1, type);
}
}
std::swap(*out, res);
Expand Down Expand Up @@ -254,7 +255,7 @@ af_err af_get_data_ref_count(int *use_count, const af_array in) {

af_err af_release_array(af_array arr) {
try {
if (arr == 0) return AF_SUCCESS;
if (arr == 0) { return AF_SUCCESS; }
const ArrayInfo &info = getInfo(arr, false, false);
af_dtype type = info.getType();

Expand Down Expand Up @@ -338,7 +339,6 @@ void write_array(af_array arr, const T *const data, const size_t bytes,
} else {
writeDeviceDataArray(getArray<T>(arr), data, bytes);
}
return;
}

af_err af_write_array(af_array arr, const void *data, const size_t bytes,
Expand Down
Loading