Last active
May 31, 2019 00:03
-
-
Save pintowar/5728372a4eda5569b7ba to your computer and use it in GitHub Desktop.
A nd4j benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab("org.nd4j:nd4j-jblas:0.4-rc3.6") | |
@Grab("org.nd4j:nd4j-java:0.4-rc3.6") | |
@Grab("org.ejml:simple:0.27") | |
@Grab("org.gperfutils:gbench:0.4.3-groovy-2.4") | |
import gbench.* | |
import org.ejml.simple.SimpleMatrix | |
import org.nd4j.linalg.jblas.NDArray | |
import org.nd4j.linalg.java.JavaNDArray | |
benchmark { | |
def rand = new Random() | |
def n = 100 | |
def max = 100 | |
def data1 = (1..(n**2)).collect{ rand.nextInt(max) }.collate(n, n) as double[][] | |
def data2 = (1..(n**2)).collect{ rand.nextInt(max) }.collate(n, n) as double[][] | |
'ND4J blas ops' { | |
def blas = new NDArray(data1) | |
def blas2 = new NDArray(data2) | |
blas.mul(blas2) | |
} | |
'ND4J java ops' { | |
def blas = new JavaNDArray(data1) | |
def blas2 = new JavaNDArray(data2) | |
blas.mul(blas2) | |
} | |
'EJM ops' { | |
def java = new SimpleMatrix(data1) | |
def java2 = new SimpleMatrix(data2) | |
java.mult(java2) | |
} | |
}.prettyPrint() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment