diff --git a/Source/Common/Include/Sequences.h b/Source/Common/Include/Sequences.h index ef6743e5a..65a1c555c 100644 --- a/Source/Common/Include/Sequences.h +++ b/Source/Common/Include/Sequences.h @@ -853,18 +853,23 @@ namespace Microsoft { namespace MSR { namespace CNTK { // but as a reference (e.g. it cannot be resized) else if (!pMBLayout || fr.IsAllFrames()) { - result.first[iterDim] += (ElemType) fr.m_timeOffset; // Note: If we have an offset, this is guaranteed to yield a slice that is out of bounds. - result.second[iterDim] += (ElemType) fr.m_timeOffset; - if (result.first[iterDim] > result.second[iterDim]) - LogicError("DataFor: Numeric wraparound. You used a size_t vector where an int vector would be needed."); + if (fr.m_timeOffset) + { + if (iterDim >= result.first.size()) + LogicError("DataFor: Time offset cannot be applied to tensors that have no time dimension."); + result.first[iterDim] += (ElemType)fr.m_timeOffset; // Note: If we have an offset, this is guaranteed to yield a slice that is out of bounds. + result.second[iterDim] += (ElemType)fr.m_timeOffset; + if (result.first[iterDim] > result.second[iterDim]) + LogicError("DataFor: Numeric wraparound. You used a size_t vector where an int vector would be needed."); + } } // FrameRange refers to a time slice -> return that else if (result.second[iterDim] > 1) // (if time dim is broadcasting then always return that one independent of requested index) { size_t ts = fr.timeIdxInSeq + fr.m_timeOffset; size_t te = ts + fr.m_timeRange; - result.first[iterDim] = (ElemType) ts; - result.second[iterDim] = (ElemType) te; + result.first[iterDim] = (ElemType)ts; + result.second[iterDim] = (ElemType)te; } // sequence index @@ -873,8 +878,8 @@ namespace Microsoft { namespace MSR { namespace CNTK { size_t s = fr.seqIndex; if (s >= result.second[sequenceDim]) LogicError("DataFor: FrameRange specifies a paralllel-sequence index that is out of range."); - result.first[sequenceDim] = (ElemType) s; - result.second[sequenceDim] = (ElemType) s + 1; + result.first[sequenceDim] = (ElemType)s; + result.second[sequenceDim] = (ElemType)s + 1; } return result; diff --git a/Source/Math/GPUMatrixCUDAKernels.cuh b/Source/Math/GPUMatrixCUDAKernels.cuh index 65decd1b4..153dff585 100644 --- a/Source/Math/GPUMatrixCUDAKernels.cuh +++ b/Source/Math/GPUMatrixCUDAKernels.cuh @@ -137,7 +137,7 @@ struct GridDim std::vector props(numDevices); for (int i = 0; i < numDevices; i++) CUDA_CALL(cudaGetDeviceProperties(&props[i], i)); -#if 1 // on Linux, maxGridSize[0] gets reported as 0 +#if 0 // on Linux, maxGridSize[0] gets reported as 0 for (int i = 0; i < numDevices; i++) fprintf(stderr, "%d procs %d warps %d %d %d max grid on %s\n", (int)props[i].multiProcessorCount, (int)props[i].warpSize, (int)props[i].maxGridSize[0], (int)props[i].maxGridSize[1], (int)props[i].maxGridSize[2], props[i].name); #endif