Code Monkey home page Code Monkey logo

arrayfire's Introduction

ArrayFire is a general-purpose tensor library that simplifies the software development process for the parallel architectures found in CPUs, GPUs, and other hardware acceleration devices. The library serves users in every technical computing market.

Several of ArrayFire's benefits include:

  • Hundreds of accelerated tensor computing functions, in the following areas:
    • Array handling
    • Computer vision
    • Image processing
    • Linear algebra
    • Machine learning
    • Standard math
    • Signal Processing
    • Statistics
    • Vector algorithms
  • Easy to use, stable, well-documented API
  • Rigorous benchmarks and tests ensuring top performance and numerical accuracy
  • Cross-platform compatibility with support for CUDA, oneAPI, OpenCL, and native CPU on Windows, Mac, and Linux
  • Built-in visualization functions through Forge
  • Commercially friendly open-source licensing
  • Enterprise support from ArrayFire

ArrayFire provides software developers with a high-level abstraction of data that resides on the accelerator, the af::array object. Developers write code that performs operations on ArrayFire arrays, which, in turn, are automatically translated into near-optimal kernels that execute on the computational device.

ArrayFire runs on devices ranging from low-power mobile phones to high-power GPU-enabled supercomputers. ArrayFire runs on CPUs from all major vendors (Intel, AMD, ARM), GPUs from the prominent manufacturers (AMD, Intel, NVIDIA, and Qualcomm), as well as a variety of other accelerator devices on Windows, Mac, and Linux.

Getting ArrayFire

Instructions to install or to build ArrayFire from source can be found on the wiki.

Conway's Game of Life Using ArrayFire

Visit the Wikipedia page for a description of Conway's Game of Life.

Conway's Game of Life

static const float h_kernel[] = { 1, 1, 1, 1, 0, 1, 1, 1, 1 };
static const array kernel(3, 3, h_kernel, afHost);

array state = (randu(128, 128, f32) > 0.5).as(f32); // Init state
Window myWindow(256, 256);
while(!myWindow.close()) {
    array nHood = convolve(state, kernel); // Obtain neighbors
    array C0 = (nHood == 2);  // Generate conditions for life
    array C1 = (nHood == 3);
    state = state * C0 + C1;  // Update state
    myWindow.image(state);    // Display
}

The complete source code can be found here.

Perceptron

Perceptron

array predict(const array &X, const array &W) {
    return sigmoid(matmul(X, W));
}

array train(const array &X, const array &Y,
        double alpha = 0.1, double maxerr = 0.05,
        int maxiter = 1000, bool verbose = false) {
    array Weights = constant(0, X.dims(1), Y.dims(1));

    for (int i = 0; i < maxiter; i++) {
        array P   = predict(X, Weights);
        array err = Y - P;
        if (mean<float>(abs(err) < maxerr) break;
        Weights += alpha * matmulTN(X, err);
    }
    return Weights;
}
...

array Weights = train(train_feats, train_targets);
array test_outputs  = predict(test_feats, Weights);
display_results<true>(test_images, test_outputs,
                      test_targets, 20);

The complete source code can be found here.

For more code examples, visit the examples/ directory.

Documentation

You can find the complete documentation here.

Quick links:

Language support

ArrayFire has several official and community maintained language API's:

C++ Python Rust Julia Nim

  Community maintained wrappers

In-Progress Wrappers

.NET Fortran Go Java Lua NodeJS R Ruby

Contributing

The community of ArrayFire developers invites you to build with us if you are interested and able to write top-performing tensor functions. Together we can fulfill The ArrayFire Mission for fast scientific computing for all.

Contributions of any kind are welcome! Please refer to the wiki and our Code of Conduct to learn more about how you can get involved with the ArrayFire Community through Sponsorship, Developer Commits, or Governance.

Citations and Acknowledgements

If you redistribute ArrayFire, please follow the terms established in the license. If you wish to cite ArrayFire in an academic publication, please use the following citation document.

ArrayFire development is funded by AccelerEyes LLC and several third parties, please see the list of acknowledgements for an expression of our gratitude.

Support and Contact Info

Trademark Policy

The literal mark "ArrayFire" and ArrayFire logos are trademarks of AccelerEyes LLC (dba ArrayFire). If you wish to use either of these marks in your own project, please consult ArrayFire's Trademark Policy

arrayfire's People

Contributors

9prady9 avatar bkloppenborg avatar cnugteren avatar filipemaia avatar floopcz avatar fzimmermann89 avatar ghisvail avatar glehmann avatar godisemo avatar jacobkahn avatar keno avatar klemmster avatar kylelutz avatar marbre avatar mark-poscablo avatar mcclanahoochie avatar melonakos avatar mlloreda avatar nevion avatar pavanky avatar pentschev avatar pv-pterab-s avatar r-barnes avatar schuhschuh avatar shadyboukhary avatar shehzan10 avatar syurkevi avatar umar456 avatar williamtambellini avatar willyborn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arrayfire's Issues

Reorganize header files

  • Move constant / randu / randn to data.h
  • Move reductions / scan / sort etc into algorithm.h
  • Move approx1, approx2 to signal.h

Add additional cpp interfaces for moddims

Adding below new interfaces

  • moddims(af::array const& input, af::dim4 const& dims)
  • moddims(af::array const& input, dim_type d0, dim_type d1=1, dim_type d2=1, dim_type d3=1)

Changes and additions to convolve API

  • Change separable convolution to be convolve instead of convolve2
  • Add a new function convolve that calls the appropriate function based on number of dimensions.

Build on OSX

Fix compile errors and get it to build on OSX.

Make arrayfire_data a subomdule

  • Make arrayfire_data a submodule
  • Move test data directory from build/data/src/arrayfire_data to build/test/arrayfire_data.
  • Change TEST_DIR to be relative

Linear Algebra functions

Possible libraries for CPU:

  • netlib's LAPACK
  • netlib's PLASMA
  • Intel's MKL

Possible libraries for CUDA:

  • MAGMA
  • CULA

Possible libraries for OpenCL:

  • clMAGMA
  • ViennaCL

CUDA randu is broken.

CUDA random number generator values are not same from run to run. Expected behavior is that it generates same values across runs.

Unfinished functions in C++ wrapper

#if 0 // FIXME: Add these functions to C++ wrapper                                                                                                                                                                   
        void unlock() const;

        template<typename T> T scalar() const;
        template<typename T> T* device() const;

        template<typename T> static T* alloc(size_t elements);
        static void *alloc(size_t elements, af_dtype type);

        template<typename T> static T* pinned(size_t elements);
        static void *pinned(size_t elements, af_dtype type);

        static void free(const void *);
#endif

Add af/compatible.h

Write inline wrappers for the following to not break older API

- deviceset --> setDevice
- devicecount --> getDeviceCount
- deviceget --> getDevice
- loadimage --> loadImage
- saveimage --> saveImage

Make cuda compute architecture a cmake option.

The following lines of cuda/CMakeLists.txt depend on the architecture

Line 33:

FILE(GLOB cuda_ptx "ptx/PTX64/sm_20/*.ptx")

Line 55:

CUDA_ADD_LIBRARY(afcuda SHARED ${cuda_src} OPTIONS "-arch=sm_20")

Make af_print prettier

  • Fixed width formatting
  • Make sure positive and negative numbers have same width
  • Display dims and strides only in debug mode.

Sort the OpenCL devices in a consistent manner.

Some options to consider:

  • Sort based on platform
  • Sort based on type (GPU, Accelerator, CPU)
  • Hardcoded order of preference ?
  • Sort based on amount of memory available
  • Sort based on OpenCL compute capability

Add additional device functions

void af::sync(int device = -1);
int af::getDevice();

af_err af_get_device(const int *device);
af_err af_sync(const int device);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.