Skip to content

Commit

Permalink
Move Accelerate backend elsewhere (#110)
Browse files Browse the repository at this point in the history
* Remove Accelerate backend code

* Modify CMake and README

* Apply clang-format

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
jatinchowdhury18 and github-actions[bot] committed Aug 17, 2023
1 parent e802121 commit 841be0a
Show file tree
Hide file tree
Showing 33 changed files with 51 additions and 1,333 deletions.
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,6 @@ backends that are available on your target platform
to ensure optimal performance. For more information see the
[benchmark results](https://github.com/jatinchowdhury18/RTNeural/actions?query=workflow%3ABench).

RTNeural also has experimental support for Apple's
[`Accelerate`](https://developer.apple.com/documentation/accelerate) framework (`-DRTNEURAL_ACCELERATE=ON`).
Please note that the `Accelerate` backend can only be
used when compiling for Apple devices, and does not
currently support defining [compile-time inferencing
engines](#compile-time-api).

Note that you must abide by the licensing rules of whichever backend library you choose.

### Other configuration flags
Expand Down
4 changes: 0 additions & 4 deletions RTNeural/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
add_library(RTNeural STATIC
activation/activation.h
activation/activation_accelerate.h
activation/activation_eigen.h
activation/activation_xsimd.h
Model.h
Expand All @@ -16,13 +15,10 @@ add_library(RTNeural STATIC
conv2d/conv2d_eigen.h
conv2d/conv2d_eigen.tpp
dense/dense.h
dense/dense_accelerate.h
dense/dense_eigen.h
dense/dense_xsimd.h
gru/gru.h
gru/gru.tpp
gru/gru_accelerate.h
gru/gru_accelerate.tpp
gru/gru_eigen.h
gru/gru_eigen.tpp
gru/gru_xsimd.h
Expand Down
9 changes: 0 additions & 9 deletions RTNeural/Layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@
#include <cstddef>
#include <string>

#if RTNEURAL_USE_ACCELERATE
// Dummy defines to make this include safe for JUCE and other libraries
#define Point CarbonDummyPointName
#define Component CarbonDummyCompName
#include <Accelerate/Accelerate.h>
#undef Point
#undef Component
#endif

namespace RTNeural
{

Expand Down
6 changes: 0 additions & 6 deletions RTNeural/ModelT.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

#include "model_loader.h"

#define MODELT_AVAILABLE (!RTNEURAL_USE_ACCELERATE)

#if MODELT_AVAILABLE

namespace RTNeural
{

Expand Down Expand Up @@ -580,5 +576,3 @@ class ModelT2D
};
#endif // RTNEURAL_USE_XSIMD
} // namespace RTNeural

#endif // MODELT_AVAILABLE
3 changes: 0 additions & 3 deletions RTNeural/activation/activation.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ class Activation : public Layer<T>
#elif RTNEURAL_USE_XSIMD
#include "activation_xsimd.h"

#elif RTNEURAL_USE_ACCELERATE
#include "activation_accelerate.h"

#else
#include "../common.h"
#include <cmath>
Expand Down
138 changes: 0 additions & 138 deletions RTNeural/activation/activation_accelerate.h

This file was deleted.

2 changes: 1 addition & 1 deletion RTNeural/batchnorm/batchnorm.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace RTNeural
{
#if !RTNEURAL_USE_EIGEN && !RTNEURAL_USE_XSIMD && !RTNEURAL_USE_ACCELERATE
#if !RTNEURAL_USE_EIGEN && !RTNEURAL_USE_XSIMD

template <typename T>
BatchNorm1DLayer<T>::BatchNorm1DLayer(int size)
Expand Down
2 changes: 1 addition & 1 deletion RTNeural/batchnorm/batchnorm2d.tpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "batchnorm2d.h"

#if !RTNEURAL_USE_EIGEN && !RTNEURAL_USE_XSIMD && !RTNEURAL_USE_ACCELERATE
#if !RTNEURAL_USE_EIGEN && !RTNEURAL_USE_XSIMD

namespace RTNeural
{
Expand Down
52 changes: 0 additions & 52 deletions RTNeural/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,58 +322,6 @@ static inline void fast_tanh(const T* in, T* out, int dim) noexcept

} // namespace RTNeural

#elif RTNEURAL_USE_ACCELERATE
#include <Accelerate/Accelerate.h>

namespace RTNeural
{

static inline void sigmoid(const float* in, float* out, int dim) noexcept
{
constexpr float one = 1.0f;
constexpr float neg_one = -1.0f;
const auto dim_int = static_cast<int>(dim);

vDSP_vsmul(in, 1, &neg_one, out, 1, dim);
vvexpf(out, out, &dim_int);
vDSP_vsadd(out, 1, &one, out, 1, dim);
vvrecf(out, out, &dim_int);
}

static inline void sigmoid(const double* in, double* out, int dim) noexcept
{
constexpr double one = 1.0;
constexpr double neg_one = -1.0;
const auto dim_int = static_cast<int>(dim);

vDSP_vsmulD(in, 1, &neg_one, out, 1, dim);
vvexp(out, out, &dim_int);
vDSP_vsaddD(out, 1, &one, out, 1, dim);
vvrec(out, out, &dim_int);
}

static inline void softmax(const float* in, float* out, int dim) noexcept
{
const auto dim_int = static_cast<int>(dim);
float exp_sum;

vvexpf(out, in, &dim_int);
vDSP_sve(out, 1, &exp_sum, dim);
vDSP_vsdiv(out, 1, &exp_sum, out, 1, dim);
}

static inline void softmax(const double* in, double* out, int dim) noexcept
{
const auto dim_int = static_cast<int>(dim);
double exp_sum;

vvexp(out, in, &dim_int);
vDSP_sveD(out, 1, &exp_sum, dim);
vDSP_vsdivD(out, 1, &exp_sum, out, 1, dim);
}

} // namespace RTNeural

#else // STL backend
#include <algorithm>
#include <cmath>
Expand Down
3 changes: 0 additions & 3 deletions RTNeural/conv1d/conv1d.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
#elif RTNEURAL_USE_XSIMD
#include "conv1d_xsimd.h"
#include "conv1d_xsimd.tpp"
#elif RTNEURAL_USE_ACCELERATE
#include "conv1d_accelerate.h"
#include "conv1d_accelerate.tpp"
#else
#include "../Layer.h"
#include "../common.h"
Expand Down
2 changes: 1 addition & 1 deletion RTNeural/conv1d/conv1d.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace RTNeural
{

#if !RTNEURAL_USE_EIGEN && !RTNEURAL_USE_XSIMD && !RTNEURAL_USE_ACCELERATE
#if !RTNEURAL_USE_EIGEN && !RTNEURAL_USE_XSIMD

template <typename T>
Conv1D<T>::Conv1D(int in_size, int out_size, int kernel_size, int dilation)
Expand Down
Loading

0 comments on commit 841be0a

Please sign in to comment.