From 968eaad2ddf5136b8929724815ef577f97b6b66b Mon Sep 17 00:00:00 2001 From: agibsonccc Date: Sun, 7 Feb 2021 19:53:55 +0900 Subject: [PATCH] Update allowed data types in pooling --- .../declarable/helpers/cpu/convolutions_pooling2d.cpp | 2 +- .../declarable/helpers/cpu/convolutions_pooling2dBP.cpp | 2 +- .../declarable/helpers/cuda/convolutions_pooling2d.cu | 4 ++-- .../declarable/helpers/cuda/convolutions_pooling2dBP.cu | 2 +- nd4j/nd4j-backends/nd4j-tests/ops-imported-new.txt | 7 ++----- .../nd4j/imports/TFGraphs/TFGraphTestAllSameDiff.java | 9 +++------ nd4j/nd4j-backends/nd4j-tests/variables-added-new.txt | 3 ++- .../frameworkimport/tensorflow/TestTensorflowIR.kt | 7 ------- 8 files changed, 12 insertions(+), 24 deletions(-) diff --git a/libnd4j/include/ops/declarable/helpers/cpu/convolutions_pooling2d.cpp b/libnd4j/include/ops/declarable/helpers/cpu/convolutions_pooling2d.cpp index c86c3de30..0242451b4 100644 --- a/libnd4j/include/ops/declarable/helpers/cpu/convolutions_pooling2d.cpp +++ b/libnd4j/include/ops/declarable/helpers/cpu/convolutions_pooling2d.cpp @@ -218,7 +218,7 @@ namespace sd { } void ConvolutionUtils::pooling2d(sd::graph::Context& block, const NDArray& input, NDArray& output, const int kH, const int kW, const int sH, const int sW, const int pH, const int pW, const int dH, const int dW, const PoolingType poolingMode, const int extraParam0) { - BUILD_SINGLE_SELECTOR(input.dataType(), pooling2d_, (block, input, output, kH, kW, sH, sW, pH, pW, dH, dW, poolingMode, extraParam0), FLOAT_TYPES); + BUILD_SINGLE_SELECTOR(input.dataType(), pooling2d_, (block, input, output, kH, kW, sH, sW, pH, pW, dH, dW, poolingMode, extraParam0), NUMERIC_TYPES); } } diff --git a/libnd4j/include/ops/declarable/helpers/cpu/convolutions_pooling2dBP.cpp b/libnd4j/include/ops/declarable/helpers/cpu/convolutions_pooling2dBP.cpp index 1ff763491..54e903c09 100644 --- a/libnd4j/include/ops/declarable/helpers/cpu/convolutions_pooling2dBP.cpp +++ b/libnd4j/include/ops/declarable/helpers/cpu/convolutions_pooling2dBP.cpp @@ -301,7 +301,7 @@ namespace sd { } void ConvolutionUtils::pooling2dBP(sd::graph::Context& block, const NDArray& input, const NDArray& gradO, NDArray& gradI, const int kH, const int kW, const int sH, const int sW, const int pH, const int pW, const int dH, const int dW, const int poolingMode, const int extraParam0) { - BUILD_SINGLE_SELECTOR(input.dataType(), pooling2dBP_, (block, input, gradO, gradI, kH, kW, sH, sW, pH, pW, dH, dW, poolingMode, extraParam0), FLOAT_TYPES); + BUILD_SINGLE_SELECTOR(input.dataType(), pooling2dBP_, (block, input, gradO, gradI, kH, kW, sH, sW, pH, pW, dH, dW, poolingMode, extraParam0), NUMERIC_TYPES); } } diff --git a/libnd4j/include/ops/declarable/helpers/cuda/convolutions_pooling2d.cu b/libnd4j/include/ops/declarable/helpers/cuda/convolutions_pooling2d.cu index c146be7bf..cb7052d4b 100644 --- a/libnd4j/include/ops/declarable/helpers/cuda/convolutions_pooling2d.cu +++ b/libnd4j/include/ops/declarable/helpers/cuda/convolutions_pooling2d.cu @@ -315,11 +315,11 @@ void ConvolutionUtils::pooling2d(sd::graph::Context& block, const NDArray& input switch (poolingMode) { case MAX_POOL: { - BUILD_SINGLE_SELECTOR_TWICE(input.dataType(), maxPooling2dCudaLauncher, (*block.launchContext(), input.specialBuffer(), input.specialShapeInfo(), output.specialBuffer(), output.specialShapeInfo(), kH, kW, sH, sW, pH, pW, dH, dW, extraParam0), FLOAT_TYPES); + BUILD_SINGLE_SELECTOR_TWICE(input.dataType(), maxPooling2dCudaLauncher, (*block.launchContext(), input.specialBuffer(), input.specialShapeInfo(), output.specialBuffer(), output.specialShapeInfo(), kH, kW, sH, sW, pH, pW, dH, dW, extraParam0), NUMERIC_TYPES); } break; case AVG_POOL: { - BUILD_SINGLE_SELECTOR_TWICE(input.dataType(), avgPooling2dCudaLauncher, (*block.launchContext(), input.specialBuffer(), input.specialShapeInfo(), output.specialBuffer(), output.specialShapeInfo(), kH, kW, sH, sW, pH, pW, dH, dW, extraParam0), FLOAT_TYPES); + BUILD_SINGLE_SELECTOR_TWICE(input.dataType(), avgPooling2dCudaLauncher, (*block.launchContext(), input.specialBuffer(), input.specialShapeInfo(), output.specialBuffer(), output.specialShapeInfo(), kH, kW, sH, sW, pH, pW, dH, dW, extraParam0), NUMERIC_TYPES); } break; case PNORM_POOL: { diff --git a/libnd4j/include/ops/declarable/helpers/cuda/convolutions_pooling2dBP.cu b/libnd4j/include/ops/declarable/helpers/cuda/convolutions_pooling2dBP.cu index 62f4787dd..6ed62c6d4 100644 --- a/libnd4j/include/ops/declarable/helpers/cuda/convolutions_pooling2dBP.cu +++ b/libnd4j/include/ops/declarable/helpers/cuda/convolutions_pooling2dBP.cu @@ -178,7 +178,7 @@ void ConvolutionUtils::pooling2dBP(sd::graph::Context& block, const NDArray& inp const int sharedMem = gradO.rankOf() * sizeof(Nd4jLong) * threadsPerBlock + 128; NDArray::prepareSpecialUse({&gradI}, {&input, &gradO}); - BUILD_SINGLE_SELECTOR(input.dataType(), pooling2dBPCudaLauncher, (blocksPerGrid, threadsPerBlock, sharedMem, block.launchContext()->getCudaStream(), input.specialBuffer(), input.specialShapeInfo(), gradO.specialBuffer(), gradO.specialShapeInfo(), gradI.specialBuffer(), gradI.specialShapeInfo(), kH, kW, sH, sW, pH, pW, dH, dW, poolingMode, extraParam0), FLOAT_TYPES); + BUILD_SINGLE_SELECTOR(input.dataType(), pooling2dBPCudaLauncher, (blocksPerGrid, threadsPerBlock, sharedMem, block.launchContext()->getCudaStream(), input.specialBuffer(), input.specialShapeInfo(), gradO.specialBuffer(), gradO.specialShapeInfo(), gradI.specialBuffer(), gradI.specialShapeInfo(), kH, kW, sH, sW, pH, pW, dH, dW, poolingMode, extraParam0), NUMERIC_TYPES); NDArray::registerSpecialUse({&gradI}, {&input, &gradO}); manager.synchronize(); diff --git a/nd4j/nd4j-backends/nd4j-tests/ops-imported-new.txt b/nd4j/nd4j-backends/nd4j-tests/ops-imported-new.txt index dab71d97e..e10e2c68e 100644 --- a/nd4j/nd4j-backends/nd4j-tests/ops-imported-new.txt +++ b/nd4j/nd4j-backends/nd4j-tests/ops-imported-new.txt @@ -1,5 +1,2 @@ -Identity,Variable/read -Identity,Variable_1/read -Pack,floordiv/x -Pack,floordiv/y -FloorDiv,floordiv +Identity,in_0/read +MaxPoolWithArgmax,MaxPoolWithArgmax diff --git a/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/imports/TFGraphs/TFGraphTestAllSameDiff.java b/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/imports/TFGraphs/TFGraphTestAllSameDiff.java index 4ad35947d..6c097f0b7 100644 --- a/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/imports/TFGraphs/TFGraphTestAllSameDiff.java +++ b/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/imports/TFGraphs/TFGraphTestAllSameDiff.java @@ -69,14 +69,11 @@ public class TFGraphTestAllSameDiff { //Note: Can't extend BaseNd4jTest here a * the status of the test failing. No tests will run. */ public final static List EXECUTE_ONLY_MODELS = Arrays.asList( - // "max_pool_with_argmax/int32_int64_padding_SAME", + "max_pool_with_argmax/int32_int64_padding_SAME", // "fused_batch_norm/float32_nhwc", - // "max_pool_with_argmax/int64_int64_padding_SAME", + "max_pool_with_argmax/int64_int64_padding_SAME" // "fused_batch_norm/float16_nhwc", - "roll/rank3_int32_axis", - "roll/rank3_int32_axis", - "roll/rank2_float32_zeroshift", - "roll/rank3_float64_axis" + ); public static final String[] IGNORE_REGEXES = new String[]{ diff --git a/nd4j/nd4j-backends/nd4j-tests/variables-added-new.txt b/nd4j/nd4j-backends/nd4j-tests/variables-added-new.txt index be63da579..80e6a0487 100644 --- a/nd4j/nd4j-backends/nd4j-tests/variables-added-new.txt +++ b/nd4j/nd4j-backends/nd4j-tests/variables-added-new.txt @@ -1,2 +1,3 @@ in_0/read,in_0/read -Roll,Roll +MaxPoolWithArgmax,MaxPoolWithArgmax +MaxPoolWithArgmax:1,MaxPoolWithArgmax diff --git a/nd4j/samediff-import/samediff-import-tensorflow/src/test/kotlin/org/nd4j/samediff/frameworkimport/tensorflow/TestTensorflowIR.kt b/nd4j/samediff-import/samediff-import-tensorflow/src/test/kotlin/org/nd4j/samediff/frameworkimport/tensorflow/TestTensorflowIR.kt index 075e08233..85e47ec6d 100644 --- a/nd4j/samediff-import/samediff-import-tensorflow/src/test/kotlin/org/nd4j/samediff/frameworkimport/tensorflow/TestTensorflowIR.kt +++ b/nd4j/samediff-import/samediff-import-tensorflow/src/test/kotlin/org/nd4j/samediff/frameworkimport/tensorflow/TestTensorflowIR.kt @@ -99,13 +99,6 @@ class TestTensorflowIR { val output2 = importedGraph.outputAll(inputMap) - val matrix = - TensorflowIRTensor(tensorflowIRGraph.nodeByName("in_0").attrMap["value"]!!.tensor).toNd4jNDArray() - val roll2 = Roll(matrix, Nd4j.scalar(2), Nd4j.scalar(1)) - val outputs = Nd4j.exec(roll2)[0] - val tfOutputRoll = tfOutput["Roll"] - val nd4jOutput = output["Roll"] - //assertEquals(tfOutput.keys,outputList) //assertEquals(tfOutput.keys,output2.keys) val names = tensorflowIRGraph.nodeList().map { input -> input.nodeName() }