Skip to content

Instantly share code, notes, and snippets.

View harperjiang's full-sized avatar

Hao Jiang harperjiang

  • Databricks
  • United States
View GitHub Profile
@harperjiang
harperjiang / log
Last active March 6, 2017 20:01
log
2017-03-06 13:53:13,431 INFO [main] o.n.l.f.Nd4jBackend [Nd4jBackend.java:194] Loaded [CpuBackend] backend
2017-03-06 13:53:13,547 INFO [main] o.n.n.NativeOpsHolder [NativeOpsHolder.java:38] Number of threads used for NativeOps: 4
2017-03-06 13:53:13,802 INFO [main] o.r.Reflections [Reflections.java:229] Reflections took 202 ms to scan 11 urls, producing 29 keys and 176 values
2017-03-06 13:53:14,055 INFO [main] o.n.n.Nd4jBlas [Nd4jBlas.java:38] Number of threads used for BLAS: 4
2017-03-06 13:53:14,520 INFO [main] e.u.c.e.n.Slow [Slow.java:117] GEMM tests:
2017-03-06 13:53:14,534 INFO [main] e.u.c.e.n.Slow [Slow.java:125] Concat time: 7586 us
2017-03-06 13:53:14,556 INFO [main] e.u.c.e.n.Slow [Slow.java:125] Concat time: 138 us
2017-03-06 13:53:14,571 INFO [main] e.u.c.e.n.Slow [Slow.java:125] Concat time: 88 us
2017-03-06 13:53:14,602 INFO [main] e.u.c.e.n.Slow [Slow.java:125] Concat time: 65 us
2017-03-06 13:53:14,637 INFO [main] e.u.c.e.n.Slow [Slow.java:125] Concat time: 101 us
public static void main(String[] args) {
fast();
slow();
}
static void fast() {
int hiddenDim = 200;
int numChar = 100;
int length = 500;
int batchSize = 50;
@harperjiang
harperjiang / concat.log
Created March 6, 2017 15:05
ND4J Performance test
Concat time: 24630 us
Concat time: 147 us
Concat time: 208 us
Concat time: 136 us
Concat time: 125 us
Concat time: 130 us
Concat time: 123 us
Concat time: 118 us
Concat time: 119 us
Concat time: 115 us
@harperjiang
harperjiang / Slow.java
Last active March 5, 2017 23:14
ND4j concat takes considerable long time
public class Slow {
public static void main(String[] args) {
int hiddenDim = 200;
int numChar = 100;
int length = 500;
int batchSize = 50;
int[] pshape = new int[]{numChar, hiddenDim};
INDArray c2v = xavier(pshape);
@harperjiang
harperjiang / Nd4j_lstm.scala
Last active June 21, 2019 08:28
Performance comparison of numpy vs nd4j on LSTM implementation
import org.nd4j.linalg.api.ndarray.INDArray
import org.nd4j.linalg.api.ops.impl.broadcast.BroadcastAddOp
import org.nd4j.linalg.api.rng.distribution.impl.UniformDistribution
import org.nd4j.linalg.factory.Nd4j
import scala.util.Random
object Xavier {
def init(shape: Array[Int]): INDArray = {
var n = shape.dropRight(1).product