#array #gpu #ndarray #tensor #arrayfire

afarray

Convenience methods for working with ArrayFire arrays in Rust

24 releases (9 breaking)

new 0.10.4 Nov 27, 2021
0.10.1 Oct 15, 2021
0.6.9 Jul 12, 2021
0.1.1 Jan 18, 2021

#270 in Algorithms

Download history 54/week @ 2021-08-10 1/week @ 2021-08-17 7/week @ 2021-08-24 15/week @ 2021-08-31 7/week @ 2021-09-07 41/week @ 2021-09-14 99/week @ 2021-09-21 68/week @ 2021-09-28 36/week @ 2021-10-05 67/week @ 2021-10-12 40/week @ 2021-10-19 20/week @ 2021-10-26 31/week @ 2021-11-02 57/week @ 2021-11-09 35/week @ 2021-11-16 67/week @ 2021-11-23

191 downloads per month
Used in 4 crates (3 directly)

Apache-2.0

160KB
4K SLoC

afarray

Convenience methods for working with ArrayFire arrays in Rust, compatible with number-general.

Usage example:

use std::iter::FromIterator;
use afarray::Array;
use number_general::Number;

let a = [1, 2, 3];
let b = [5];

let product = &Array::from(&a[..]) * &Array::from(&b[..]);
assert_eq!(product, Array::from_iter(vec![5, 10, 15]));
assert_eq!(product.sum(), Number::from(30))

Note that you must have ArrayFire installed in order to build this crate. The installation instructions are at http://arrayfire.org/docs/installing.htm.

You can find detailed instructions for building the Rust arrayfire crate from crates.io at: https://crates.io/crates/arrayfire.


lib.rs:

Provides a generic one-dimensional [Array] which wraps [arrayfire::Array] and supports all [number_general::NumberType] variants. Array and ArrayExt support basic math like Add, Sub, Mul, Div, and Rem, with hardware acceleration on systems which support CUDA or OpenCL. ArrayExt<bool> supports common logical operations and, not, or, and xor.

N-dimensional array functionality can be implemented using Coords and Offsets, which provide methods for indexing a one-dimensional Array or ArrayExt as an n-dimensional tensor.

Array supports (de)serialization without type hinting. ArrayExt<T> supports serialization for T: Serialize and deserialization for T: Deserialize.

Example usage:

# use std::iter::FromIterator;
# use afarray::Array;
# use number_general::Number;
let a = [1, 2, 3];
let b = [5];

let product = &Array::from(&a[..]) * &Array::from(&b[..]);
assert_eq!(product, Array::from_iter(vec![5, 10, 15]));
assert_eq!(product.sum(), Number::from(30))

This crate depends on ArrayFire version 3.8. You will have to install ArrayFire separately by following the instructions at https://arrayfire.org/docs/installing.htm in order to build this crate.

You can find detailed instructions for building the Rust arrayfire crate from crates.io at https://crates.io/crates/arrayfire.

Dependencies

~4MB
~81K SLoC