@@ -0,0 +1,1144 @@
+package edu.uchicago.cs.encsel.ndnn;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport org.nd4j.linalg.api.ndarray.INDArray;%0Aimport org.nd4j.linalg.factory.Nd4j;%0A%0Apublic class Slow %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09int hiddenDim = 200;%0A%09%09int numChar = 100;%0A%09%09int length = 500;%0A%09%09int batchSize = 50;%0A%0A%09%09// INDArray c2v = xavier(new int%5B%5D %7B numChar, hiddenDim %7D);%0A%09%09INDArray c2v = Nd4j.zeros(numChar, hiddenDim);%0A%09%09INDArray h0 = Nd4j.zeros(batchSize, hiddenDim);%0A%09%09INDArray c0 = Nd4j.zeros(batchSize, hiddenDim);%0A%0A%09%09INDArray fwdmap = Nd4j.zeros(batchSize, numChar);%0A%0A%09%09INDArray embed = fwdmap.mmul(c2v);%0A%0A%09%09List%3CINDArray%3E embeds = new ArrayList%3C%3E();%0A%09%09List%3CINDArray%3E h0s = new ArrayList%3C%3E();%0A%09%09for (int x = 0; x %3C 10000; x++) %7B%0A%09%09%09embeds.add(Nd4j.createUninitialized(embed.shape()));%0A%09%09%09h0s.add(Nd4j.createUninitialized(h0.shape()));%0A%09%09%7D%0A%0A%09%09for (int x = 0; x %3C embeds.size(); x++) %7B%0A%09%09%09long time1 = System.nanoTime();%0A%09%09%09INDArray concat = Nd4j.concat(1, embeds.get(x), h0s.get(x));%0A%09%09%09long time2 = System.nanoTime();%0A%0A%09%09%09if (x %25 10 == 0)%0A%09%09%09%09System.out.println(%22Concat time: %22 + ((time2 - time1) / 1000) + %22 us%22);%0A%09%09%7D%0A%09%7D%0A%7D%0A

test performance