Skip to content

Commit

Permalink
Ag fix9060 (#519)
Browse files Browse the repository at this point in the history
* Development updates (deeplearning4j#9053)

* RL4J: Add generic update rule (#502)

Signed-off-by: Alexandre Boulanger <aboulang2002@yahoo.com>

* Shyrma reduce (#481)

* - start working on improving of cpu legacy code for reduce ops

Signed-off-by: Yurii <iuriish@yahoo.com>

* - further work on improving legacy loops

Signed-off-by: Yurii <iuriish@yahoo.com>

* - still working on improving reduce ops

Signed-off-by: Yurii <iuriish@yahoo.com>

* - further work on improving reduce ops

Signed-off-by: Yurii <iuriish@yahoo.com>

* - testing speed run of new reduce op

Signed-off-by: Yurii <iuriish@yahoo.com>

* - working on improvement of default loop for reduce op

Signed-off-by: Yurii <iuriish@yahoo.com>

* - update signatures of stuff which calls reduce ops

Signed-off-by: Yurii <iuriish@yahoo.com>

* - make corrections in cuda reduce kernels

Signed-off-by: Yurii <iuriish@yahoo.com>

* - change loop for default case in broadcast legacy ops

Signed-off-by: Yurii <iuriish@yahoo.com>

* - comment some shape stuff

Signed-off-by: Yurii <iuriish@yahoo.com>

* - comment unnecessary prints in RNGtests

Signed-off-by: Yurii <iuriish@yahoo.com>

* - finish to resolve conflicts after master has been merged

Signed-off-by: Yurii <iuriish@yahoo.com>

* - get rid of some compilation mistakes of cuda stuff

Signed-off-by: Yurii <iuriish@yahoo.com>

* - minor changes

Signed-off-by: Yurii <iuriish@yahoo.com>

* - further search for bug causing crash on java test

Signed-off-by: Yurii <iuriish@yahoo.com>

* - add scalar case in reduce_ ... exec stuff

Signed-off-by: Yurii <iuriish@yahoo.com>

* - minor corrections in NAtiveOps.cu

Signed-off-by: Yurii <iuriish@yahoo.com>

* - add switch to scalar case execReduceXD functions

Signed-off-by: Yurii <iuriish@yahoo.com>

* - add support for vectors old shape in ConstantShapeHelper::createShapeInfoWithNoUnitiesForReduce

Signed-off-by: Yurii <iuriish@yahoo.com>

* - correct cuda mirrorPad

Signed-off-by: Yurii <iuriish@yahoo.com>

* - add support for vectors old shape in cuda createShapeInfoWithNoUnitiesForReduce

Signed-off-by: Yurii <iuriish@yahoo.com>

Co-authored-by: raver119 <raver119@gmail.com>

* Add support for CUDA 11.0 (#492)

* Add support for CUDA 11.0

* libnd4j tweaks for CUDA 11

Signed-off-by: raver119@gmail.com <raver119@gmail.com>

* bindings update, again?

Signed-off-by: raver119@gmail.com <raver119@gmail.com>

* * Update versions of JavaCPP Presets for FFmpeg, OpenBLAS, and NumPy

* update API to match CUDA 8

Signed-off-by: raver119@gmail.com <raver119@gmail.com>

* * Update version of JavaCPP Presets for CPython

* C++ updated for cuDNN 8.0

Signed-off-by: raver119@gmail.com <raver119@gmail.com>

* one more test

Signed-off-by: raver119@gmail.com <raver119@gmail.com>

* one more test

Signed-off-by: raver119@gmail.com <raver119@gmail.com>

* one more test

Signed-off-by: raver119@gmail.com <raver119@gmail.com>

* 128-bit alignment for workspaces

Signed-off-by: raver119@gmail.com <raver119@gmail.com>

* change seed in 1 test

Signed-off-by: raver119@gmail.com <raver119@gmail.com>

* Fix dependecy duplication in python4j-parent pom

* Fix group id for in python4j-numpy

* few tests tweaked

Signed-off-by: raver119@gmail.com <raver119@gmail.com>

* Remove macosx-x86_64-gpu from nd4j-tests-tensorflow

* few minor tweaks for IndexReduce

Signed-off-by: raver119@gmail.com <raver119@gmail.com>

* one test removed

Signed-off-by: raver119@gmail.com <raver119@gmail.com>

Co-authored-by: raver119@gmail.com <raver119@gmail.com>
Co-authored-by: Serhii Shepel <9946053+sshepel@users.noreply.github.com>

* RL4J: Add SyncTrainer and AgentLearnerBuilder for a few algorithms (#504)

Signed-off-by: Alexandre Boulanger <aboulang2002@yahoo.com>

Co-authored-by: Alexandre Boulanger <44292157+aboulang2002@users.noreply.github.com>
Co-authored-by: Yurii Shyrma <iuriish@yahoo.com>
Co-authored-by: raver119 <raver119@gmail.com>
Co-authored-by: Serhii Shepel <9946053+sshepel@users.noreply.github.com>

* Removed dead code (deeplearning4j#9057)

Signed-off-by: Dariusz Zbyrad <dariusz.zbyrad@gmail.com>

* performance improvement (deeplearning4j#9055)

* performance improvement

Signed-off-by: Dariusz Zbyrad <dariusz.zbyrad@gmail.com>

* revert some changes

Signed-off-by: Dariusz Zbyrad <dariusz.zbyrad@gmail.com>

* Development updates (deeplearning4j#9064)

 * Update versions of JavaCPP Presets for OpenCV, FFmpeg, and MKL

Signed-off-by: Samuel Audet <samuel.audet@gmail.com>

* Added support for the archunit (deeplearning4j#9062)

* Added support for the archunit

Signed-off-by: Dariusz Zbyrad <dariusz.zbyrad@gmail.com>

* Updated pom files

Signed-off-by: Dariusz Zbyrad <dariusz.zbyrad@gmail.com>

* Datavec code cleaup (deeplearning4j#9071)

* removed unnecessary semicolons

Signed-off-by: Dariusz Zbyrad <dariusz.zbyrad@gmail.com>

* Use standard charset object

Signed-off-by: Dariusz Zbyrad <dariusz.zbyrad@gmail.com>

* Removed unused imports

Signed-off-by: Dariusz Zbyrad <dariusz.zbyrad@gmail.com>

* WIP: Fix Conv1d causal case

* Add inital tests

* Update Conv1d tests to be a bit more robust

* Remove redundant test

* Reset from master

* Remove cuda definition (left over)

* Update rl4j again

* Update pom.xml

Co-authored-by: Samuel Audet <samuel.audet@gmail.com>
Co-authored-by: Alexandre Boulanger <44292157+aboulang2002@users.noreply.github.com>
Co-authored-by: Yurii Shyrma <iuriish@yahoo.com>
Co-authored-by: raver119 <raver119@gmail.com>
Co-authored-by: Serhii Shepel <9946053+sshepel@users.noreply.github.com>
Co-authored-by: dariuszzbyrad <dariusz.zbyrad@gmail.com>
  • Loading branch information
7 people committed Sep 2, 2020
1 parent faea1f7 commit be4628e
Show file tree
Hide file tree
Showing 92 changed files with 5,016 additions and 15,914 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.deeplearning4j.nn.conf.inputs.InputType;
import org.deeplearning4j.nn.conf.layers.*;
import org.deeplearning4j.nn.conf.layers.convolutional.Cropping1D;
import org.deeplearning4j.nn.modelimport.keras.KerasModelImport;
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
import org.deeplearning4j.util.Convolution1DUtils;
import org.junit.Test;
Expand All @@ -38,6 +39,8 @@
import org.nd4j.linalg.learning.config.NoOp;
import org.nd4j.linalg.lossfunctions.LossFunctions;

import java.io.File;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -450,7 +453,7 @@ public void testCnn1dWithMasking(){
}

@Test
public void testCnn1Causal() {
public void testCnn1Causal() throws Exception {
int convNIn = 2;
int convNOut1 = 3;
int convNOut2 = 4;
Expand All @@ -462,7 +465,6 @@ public void testCnn1Causal() {
int[] strides = {1, 2, 1, 2, 1, 1};
boolean[] masks = {false, true, false, true, false, true};
boolean[] hasB = {true, false, true, false, true, true};

for (int i = 0; i < lengths.length; i++) {
int length = lengths[i];
int k = kernels[i];
Expand All @@ -471,7 +473,7 @@ public void testCnn1Causal() {
boolean mask = masks[i];
boolean hasBias = hasB[i];
//TODO has bias
String s = "k=" + k + ", s=" + st + "d=" + d + ", seqLen=" + length;
String s = "k=" + k + ", s=" + st + " d=" + d + ", seqLen=" + length;
log.info("Starting test: " + s);
Nd4j.getRandom().setSeed(12345);

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class KerasModelImport {
* @return ComputationGraph
* @see ComputationGraph
*/
public static ComputationGraph importKerasModelAndWeights( InputStream modelHdf5Stream, boolean enforceTrainingConfig)
public static ComputationGraph importKerasModelAndWeights(InputStream modelHdf5Stream, boolean enforceTrainingConfig)
throws IOException, UnsupportedKerasConfigurationException, InvalidKerasConfigurationException{
File f = null;
try{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.deeplearning4j.nn.modelimport.keras.exceptions.InvalidKerasConfigurationException;
import org.deeplearning4j.nn.modelimport.keras.exceptions.UnsupportedKerasConfigurationException;
import org.deeplearning4j.nn.modelimport.keras.utils.KerasConstraintUtils;
import org.deeplearning4j.nn.modelimport.keras.utils.KerasLayerUtils;
import org.deeplearning4j.nn.params.ConvolutionParamInitializer;
import org.deeplearning4j.nn.weights.IWeightInit;
import org.nd4j.linalg.api.ndarray.INDArray;
Expand Down Expand Up @@ -85,7 +86,6 @@ public KerasConvolution1D(Map<String, Object> layerConfig, boolean enforceTraini
hasBias = getHasBiasFromConfig(layerConfig, conf);
numTrainableParams = hasBias ? 2 : 1;
int[] dilationRate = getDilationRate(layerConfig, 1, conf, false);

LayerConstraint biasConstraint = KerasConstraintUtils.getConstraintsFromConfig(
layerConfig, conf.getLAYER_FIELD_B_CONSTRAINT(), conf, kerasMajorVersion);
LayerConstraint weightConstraint = KerasConstraintUtils.getConstraintsFromConfig(
Expand All @@ -101,7 +101,7 @@ public KerasConvolution1D(Map<String, Object> layerConfig, boolean enforceTraini
.convolutionMode(getConvolutionModeFromConfig(layerConfig, conf))
.kernelSize(getKernelSizeFromConfig(layerConfig, 1, conf, kerasMajorVersion)[0])
.hasBias(hasBias)
.stride(getStrideFromConfig(layerConfig, 1, conf)[0]).rnnDataFormat(dimOrder == DimOrder.TENSORFLOW? RNNFormat.NWC: RNNFormat.NCW);
.stride(getStrideFromConfig(layerConfig, 1, conf)[0]).rnnDataFormat(dimOrder == DimOrder.TENSORFLOW ? RNNFormat.NCW: RNNFormat.NWC);
int[] padding = getPaddingFromBorderModeConfig(layerConfig, 1, conf, kerasMajorVersion);
if (hasBias)
builder.biasInit(0.0);
Expand All @@ -113,6 +113,14 @@ public KerasConvolution1D(Map<String, Object> layerConfig, boolean enforceTraini
builder.constrainBias(biasConstraint);
if (weightConstraint != null)
builder.constrainWeights(weightConstraint);
if(inputShape != null) {
if(dimOrder == DimOrder.THEANO) {
builder.nIn(inputShape[0]);
}
else {
builder.nIn(inputShape[1]);
}
}
this.layer = builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ public void testMaskingTwoValue() throws Exception {
}

@Test
public void testCausalCon1D() throws Exception {
public void testCausalConv1D() throws Exception {
String[] names = new String[]{
"causal_conv1d_k2_s1_d1_cl_model.h5",
"causal_conv1d_k2_s1_d2_cl_model.h5",
Expand Down Expand Up @@ -635,7 +635,7 @@ public void testCausalCon1D() throws Exception {
}

@Test
public void testCon1D() throws Exception {
public void testConv1D() throws Exception {
String[] names = new String[]{
"conv1d_k2_s1_d1_cf_same_model.h5",
"conv1d_k2_s1_d1_cf_valid_model.h5",
Expand Down Expand Up @@ -697,6 +697,7 @@ public void testCon1D() throws Exception {
}
}


@Test
public void testActivationLayers() throws Exception {
String[] names = new String[]{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ public MultiLayerConfiguration build() {

if(backpropType == BackpropType.TruncatedBPTT && validateTbpttConfig){
//Check for invalid combination - tbptt plus LastTimeStepLayer or
for( int i=0; i<confs.size(); i++ ){
for( int i = 0; i < confs.size(); i++) {
Layer l = confs.get(i).getLayer();
if(l instanceof LastTimeStep || l instanceof GlobalPoolingLayer){
throw new IllegalStateException("Invalid network configuration detected: Truncated backpropagation through time (TBPTT)" +
Expand Down Expand Up @@ -698,7 +698,27 @@ public MultiLayerConfiguration build() {
if (inputPreProcessor != null) {
currentInputType = inputPreProcessor.getOutputType(currentInputType);
}
l.setNIn(currentInputType, false); //Don't override the nIn setting, if it's manually set by the user
if(i > 0) {
Layer layer = confs.get(i - 1).getLayer();
//convolution 1d is an edge case where it has rnn input type but the filters
//should be the output
if(layer instanceof Convolution1DLayer) {
Convolution1DLayer convolution1D = (Convolution1DLayer) layer;
if(l instanceof DenseLayer) {
FeedForwardLayer feedForwardLayer = (FeedForwardLayer) l;
InputType.InputTypeRecurrent recurrent = (InputType.InputTypeRecurrent) inputType;
feedForwardLayer.setNIn(recurrent.getTimeSeriesLength());
}
else
l.setNIn(currentInputType, false); //Don't override the nIn setting, if it's manually set by the user
}
else
l.setNIn(currentInputType, false); //Don't override the nIn setting, if it's manually set by the user

}
else
l.setNIn(currentInputType, false); //Don't override the nIn setting, if it's manually set by the user


currentInputType = l.getOutputType(i, currentInputType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ protected Pair<INDArray,INDArray> preOutput(boolean training, boolean forBackpro
return preOutput;
}

protected Pair<INDArray,INDArray> causalConv1dForward(){
protected Pair<INDArray,INDArray> causalConv1dForward() {
//TODO eventually we'll use this for all convolution modes - but only after libnd4j has cuDNN support
org.deeplearning4j.nn.conf.layers.Convolution1DLayer c = (org.deeplearning4j.nn.conf.layers.Convolution1DLayer) layerConf();
Conv1DConfig conf = Conv1DConfig.builder()
Expand All @@ -197,7 +197,7 @@ protected Pair<INDArray,INDArray> causalConv1dForward(){
.d(c.getDilation()[0])
.p(c.getPadding()[0])
.dataFormat((((org.deeplearning4j.nn.conf.layers.Convolution1DLayer)
layerConf()).getRnnDataFormat()== RNNFormat.NCW)?Conv1DConfig.NCW: Conv1DConfig.NCW)
layerConf()).getRnnDataFormat() == RNNFormat.NCW) ? Conv1DConfig.NCW: Conv1DConfig.NWC)
.paddingMode(PaddingMode.CAUSAL)
.build();
INDArray w = getParam(ConvolutionParamInitializer.WEIGHT_KEY);
Expand Down
13 changes: 0 additions & 13 deletions jumpy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,4 @@
</plugins>
</build>

<profiles>
<profile>
<id>nd4j-backend</id>
<activation>
<property>
<name>libnd4j.cuda</name>
</property>
</activation>
<properties>
<nd4j.backend>nd4j-cuda-${libnd4j.cuda}</nd4j.backend>
</properties>
</profile>
</profiles>
</project>
16 changes: 16 additions & 0 deletions libnd4j/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,19 @@ To run tests using CUDA backend it's pretty much similar process:
2. ./blasbuild/cuda/tests_cpu/layers_tests/runtests (.exe on Windows)
## Development
In order to extend and update libnd4j, understanding libnd4j's various
cmake flags is the key. Many of them are in buildnativeoperations.sh.
The pom.xml is used to integrate and auto configure the project
for building with deeplearning4j.

At a minimum, you will want to enable tests. An example default set of flags
for running tests and getting cpu builds working is as follows:
```bash
-DSD_CPU=true -DBLAS=TRUE -DSD_ARCH=x86-64 -DSD_EXTENSION= -DSD_LIBRARY_NAME=nd4jcpu -DSD_CHECK_VECTORIZATION=OFF -DSD_SHARED_LIB=ON -DSD_STATIC_LIB=OFF -DSD_BUILD_MINIFIER=false -DSD_ALL_OPS=true -DCMAKE_BUILD_TYPE=Release -DPACKAGING=none -DSD_BUILD_TESTS=OFF -DCOMPUTE=all -DOPENBLAS_PATH=C:/Users/agibs/.javacpp/cache/openblas-0.3.10-1.5.4-SNAPSHOT-windows-x86_64.jar/org/bytedeco/openblas/windows-x86_64 -DDEV=FALSE -DCMAKE_NEED_RESPONSE=YES -DMKL_MULTI_THREADED=TRUE -DSD_BUILD_TESTS=YES
```

The way the main build script works, it dynamically generates a set of flags
suitable for use for building the projects. Understanding the build script
will go a long way in to configuring cmake for your particular IDE.
7 changes: 0 additions & 7 deletions libnd4j/development.md

This file was deleted.

Loading

0 comments on commit be4628e

Please sign in to comment.