Today we are announcing the release of ArrayFire version 3.6. The official binary installers can be downloaded here:

https://sandbox.arrayfire.com/downloads

We added several new features that improve the performance and usability of the ArrayFire library. The main features are:
<ul>
 	<li>Support for batched matrix multiply</li>
 	<li>Added the topk function</li>
 	<li>Added the anisotropic diffusion filter</li>
</ul>
The new batch functionality allows you to perform several matrix multiplication operations in one call of matmul. You might want to call this function if you are performing multiple smaller matrix multiplication operations. Here is an example:
<pre class="lang:c++ decode:true" title="Batched matrix multiply">// Create a 3x3x2 matrix
array a = randu(3, 3, 2);
array b = randu(3, 3, 2);

array c = matmul(a, b);
</pre>
The example above is creating 2 3 by 3 matrices as a 3x3x2 volume for a and b. The matmul function then multiplies the slice of the a volume with the corresponding slice in b. Which this approach you can reach higher efficiencies with smaller matrices. Here is a benchmark for batched matmul on the NVIDIA Tesla V100.

[caption id="attachment_9793" align="aligncenter" width="646"]<a href="https://sandbox.arrayfire.com/wp-content/uploads/2018/05/chart-1.png"><img class="size-full wp-image-9793" src="https://sandbox.arrayfire.com/wp-content/uploads/2018/05/chart-1.png" alt="Batched Matrix Multiplication Performance" width="646" height="430" /></a> Batched Matrix Multiplication Performance[/caption]

The batched matrix multiplication allows you to reach the maximum performance of your GPU with smaller matrix sizes. Larger matrices do not necessarily need to be batched to fully utilize the GPU.

Topk is another exciting function that was added in this release. This function returns the top k maximum or minimum values in a vector or matrix along with their indices. Here is an example:
<pre class="lang:c++ decode:true" title="Topk Example">array a = randu(10, 10); // Create a 10x10 matrix

array idx, vals;
topk(vals, idx, a, 3); // Get the top 3 values of a</pre>
Here we create a 10x10 matrix then call the topk function on it. Topk will return the top 3 indices and values. The indices are based on the values position in the given column. Here is a sample output:
<pre class="lang:default decode:true ">a
[10 10 1 1]
    0.6010     0.1583     0.6755     0.5143     0.7917     0.9092     0.5970     0.9048     0.3967     0.8891
    0.0278     0.3712     0.6105     0.3670     0.1654     0.8865     0.9594     0.0198     0.8055     0.3434
    0.9806     0.3543     0.5232     0.3336     0.8657     0.9676     0.2323     0.4436     0.5147     0.8040
    0.2126     0.6450     0.5567     0.0363     0.3766     0.1425     0.9623     0.6808     0.3210     0.2986
    0.0655     0.9675     0.7896     0.5349     0.7331     0.5137     0.8578     0.6636     0.7831     0.0438
    0.5497     0.3636     0.8966     0.0123     0.2522     0.6484     0.0192     0.8738     0.4784     0.6108
    0.2864     0.4165     0.0536     0.3988     0.9644     0.6353     0.7191     0.3954     0.5770     0.9033
    0.3410     0.5814     0.5775     0.9787     0.4711     0.7449     0.4035     0.5277     0.8173     0.5131
    0.7509     0.8962     0.2908     0.2308     0.3637     0.4391     0.4692     0.3592     0.5207     0.5784
    0.4105     0.3712     0.9941     0.6244     0.9643     0.6982     0.3353     0.8567     0.4341     0.6910

idx
[3 10 1 1]
         2          4          9          7          6          2          3          0          7          6
         8          8          5          9          9          0          1          5          1          0
         0          3          4          4          2          1          4          9          4          2

vals
[3 10 1 1]
    0.9806     0.9675     0.9941     0.9787     0.9644     0.9676     0.9623     0.9048     0.8173     0.9033
    0.7509     0.8962     0.8966     0.6244     0.9643     0.9092     0.9594     0.8738     0.8055     0.8891
    0.6010     0.6450     0.7896     0.5349     0.8657     0.8865     0.8578     0.8567     0.7831     0.8040</pre>
&nbsp;