Repository: deeplearning4j/deeplearning4j
Issue: Workspace exception in 1.0.0 snapshot

#### Issue Description

Running the following method results in a Workspace exception being thrown:

public static void main(String[] args) {

        final int[] inputShape = {1, 1, 4, 4};
        final INDArray input = Nd4j.rand(inputShape);
        final INDArray label = Nd4j.create(new double[]{1});

        final String inputName = "input";
        final String outputName = "output";

        ComputationGraphConfiguration graphConf = new NeuralNetConfiguration.Builder()
                .weightInit(WeightInit.RELU_UNIFORM)
                .activation(Activation.IDENTITY) // Will be set later on
                .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
                .updater(new Nesterovs(0.01, 0.9))
                .trainingWorkspaceMode(WorkspaceMode.ENABLED)
                .inferenceWorkspaceMode(WorkspaceMode.ENABLED)
                .graphBuilder()
                .addInputs(inputName)
                .backprop(true)
                .pretrain(false)
                .setInputTypes(InputType.convolutional(inputShape[3], inputShape[2], inputShape[1]))
                .layer("conv", new ConvolutionLayer.Builder(3,3)
                        .nIn(1)
                        .nOut(1)
                        .build(),  inputName)
                .addVertex("mv", new MergeVertex(), "conv")
                .addVertex("add",
                        new ElementWiseVertex(ElementWiseVertex.Op.Add), "mv", "conv")
                .layer("gp", new GlobalPoolingLayer.Builder().build(), "add")
                .layer(outputName, new CenterLossOutputLayer.Builder()
                        .lossFunction(new LossMCXENT())
                        .nOut(label.length())
                        .build(), "gp")
                .setOutputs(outputName)
                .build();

        final ComputationGraph graph = new ComputationGraph(graphConf);
        graph.init();

        graph.fit(new INDArray[] {input}, new INDArray[] {label});
    } 

Exception thrown:
Exception in thread "main" java.lang.IllegalStateException: Backprop: array (ACTIVATION_GRAD) workspace validation failed (vertex mv - class: MergeVertex) - array is defined in incorrect workspace
	at org.deeplearning4j.nn.graph.ComputationGraph.validateArrayWorkspaces(ComputationGraph.java:1603)
	at org.deeplearning4j.nn.graph.ComputationGraph.calcBackpropGradients(ComputationGraph.java:2319)
	at org.deeplearning4j.nn.graph.ComputationGraph.computeGradientAndScore(ComputationGraph.java:1218)
	at org.deeplearning4j.nn.graph.ComputationGraph.computeGradientAndScore(ComputationGraph.java:1179)
	at org.deeplearning4j.optimize.solvers.BaseOptimizer.gradientAndScore(BaseOptimizer.java:178)
	at org.deeplearning4j.optimize.solvers.StochasticGradientDescent.optimize(StochasticGradientDescent.java:60)
	at org.deeplearning4j.optimize.Solver.optimize(Solver.java:54)
	at org.deeplearning4j.nn.graph.ComputationGraph.fit(ComputationGraph.java:1052)
	at org.deeplearning4j.nn.graph.ComputationGraph.fit(ComputationGraph.java:998)
	at ampControl.model.training.model.layerblocks.graph.WorkspaceException.main(WorkspaceException.java:63)
Caused by: org.nd4j.linalg.workspace.ND4JWorkspaceException: Array workspace validation failed: Array of type ACTIVATION_GRAD should be in workspace "WS_LAYER_ACT_1" but is in workspace "WS_LAYER_ACT_0"
	at org.nd4j.linalg.workspace.BaseWorkspaceMgr.validateArrayLocation(BaseWorkspaceMgr.java:221)
	at org.deeplearning4j.nn.workspace.LayerWorkspaceMgr.validateArrayLocation(LayerWorkspaceMgr.java:66)
	at org.deeplearning4j.nn.graph.ComputationGraph.validateArrayWorkspaces(ComputationGraph.java:1594)
	... 9 more


#### Version Information

Please indicate relevant versions, including, if relevant:

* Deeplearning4j version : 1.0.0 snapshot (pom refreshed ~1 hour before post in case it matters).
* platform information: Windows 10
* CUDA version, if used: CUDA 8.0, cudnn 6.0
* NVIDIA driver version, if in use: 391.35

#### Contributing

Would ofc love to help out, but I don't think I'll be able to help out efficiently here.


Changed files:
deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/graph/vertex/impl/MergeVertex.java

diff --git a/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/graph/vertex/impl/MergeVertex.java b/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/graph/vertex/impl/MergeVertex.java
index 8c4a1d4d30..73a1da33e0 100644
--- a/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/graph/vertex/impl/MergeVertex.java
+++ b/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/graph/vertex/impl/MergeVertex.java
@@ -82,7 +82,7 @@ public class MergeVertex extends BaseGraphVertex {
             //No-op case
             int[] shape = inputs[0].shape();
             forwardPassShapes = new int[][] {Arrays.copyOf(shape, shape.length)};
-            return inputs[0];
+            return workspaceMgr.leverageTo(ArrayType.ACTIVATIONS, inputs[0]);
         }
 
         forwardPassShapes = new int[inputs.length][0];
@@ -120,7 +120,7 @@ public class MergeVertex extends BaseGraphVertex {
 
         if (forwardPassShapes.length == 1) {
             //No op case
-            return new Pair<>(null, new INDArray[] {epsilon});
+            return new Pair<>(null, new INDArray[] {workspaceMgr.leverageTo(ArrayType.ACTIVATION_GRAD, epsilon)});
         }
 
         //Split the epsilons in the opposite way that the activations were merged