From d6ca03eb21d2489143e4b72458cb26794a712294 Mon Sep 17 00:00:00 2001 From: dangqingqing Date: Mon, 31 Jul 2017 11:15:01 +0800 Subject: [PATCH] Fix out of memory. --- paddle/cuda/src/hl_cuda_sequence.cu | 2 +- paddle/math/tests/test_matrixCompare.cpp | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/paddle/cuda/src/hl_cuda_sequence.cu b/paddle/cuda/src/hl_cuda_sequence.cu index c7282198494..eeee921db54 100644 --- a/paddle/cuda/src/hl_cuda_sequence.cu +++ b/paddle/cuda/src/hl_cuda_sequence.cu @@ -269,7 +269,7 @@ void hl_sequence2batch_copy_padding(real* batch, int blockDimY = CUDA_BLOCK_SIZE / blockDimX; dim3 threads(blockDimX, blockDimY); - int gridDimX = (maxSequenceLength + blockDimY - 1)/blockDimY; + int gridDimX = (maxSequenceLength + blockDimY - 1) / blockDimY; int gridDimY = numSequences; dim3 grid(gridDimX, gridDimY); diff --git a/paddle/math/tests/test_matrixCompare.cpp b/paddle/math/tests/test_matrixCompare.cpp index 65a37cefe66..4980208e659 100644 --- a/paddle/math/tests/test_matrixCompare.cpp +++ b/paddle/math/tests/test_matrixCompare.cpp @@ -1152,16 +1152,9 @@ void testBatch2seqPadding(int batchSize, int inputDim) { IVectorPtr gpuSequence = IVector::create(cpuSequence->getSize(), true); gpuSequence->copyFrom(*cpuSequence); - int newBatchSize = cpuSequence->getSize() - 1; - MatrixPtr cpuOutput = std::make_shared(newBatchSize, inputDim); - MatrixPtr gpuOutput = std::make_shared(newBatchSize, inputDim); - cpuOutput->zero(); - gpuOutput->zero(); - - size_t maxSeqLen = 0; size_t numSeq = cpuSequence->getSize() - 1; - maxSeqLen = *std::max_element(cpuSequence->getData(), - cpuSequence->getData() + numSeq); + size_t maxSeqLen = *std::max_element(cpuSequence->getData(), + cpuSequence->getData() + numSeq); MatrixPtr cBatch = std::make_shared(numSeq * maxSeqLen, inputDim); MatrixPtr gBatch = std::make_shared(numSeq * maxSeqLen, inputDim); @@ -1200,8 +1193,8 @@ void testBatch2seqPadding(int batchSize, int inputDim) { } TEST(Matrix, warpCTC) { - for (auto batchSize : {51, 1285, 3884}) { - for (auto inputDim : {32, 512, 3026}) { + for (auto batchSize : {51, 526, 2884}) { + for (auto inputDim : {32, 512, 2026}) { VLOG(3) << " batchSize=" << batchSize << " inputDim=" << inputDim; testBatch2seqPadding(batchSize, inputDim); } -- GitLab