diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorSlice.cpp b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorSlice.cpp index c26f223634..5a2e9d888b 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorSlice.cpp +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorSlice.cpp @@ -15,7 +15,7 @@ public: { const uint32_t inputCount = kernelInfo.GetInputCount(); ML_CHECK_VALID_ARGUMENT((opsetVersion < 10 && inputCount == 1) - || (opsetVersion == 10 && inputCount >= 3 && inputCount <= 5)); + || (opsetVersion >= 10 && opsetVersion <= 11 && inputCount >= 3 && inputCount <= 5)); ML_CHECK_VALID_ARGUMENT(kernelInfo.GetOutputCount() == 1); std::vector> kernelInputIndices = { 0 }; // Only bind GPU to first 'data' tensor. @@ -65,5 +65,5 @@ void CALLBACK QuerySlice(IMLOperatorSupportQueryContextPrivate* context, bool *i DML_OP_DEFINE_CREATION_FUNCTION(Slice7, DmlOperatorSliceTemplate<7>); DML_OP_DEFINE_CREATION_FUNCTION(Slice10, DmlOperatorSliceTemplate<10>); -DML_OP_DEFINE_CREATION_FUNCTION(Slice11, DmlOperatorSliceTemplate<10>); +DML_OP_DEFINE_CREATION_FUNCTION(Slice11, DmlOperatorSliceTemplate<11>); } // namespace Dml diff --git a/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp b/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp index 185020ce24..f4123c97d0 100644 --- a/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp +++ b/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp @@ -55,6 +55,7 @@ void ReadCpuLocalTensorIntoInt32( case MLOperatorTensorDataType::Int64: { const int64_t* data = tensor.GetData(); + result.reserve(elementCount); for (auto d : gsl::make_span(data, data + elementCount)) { result.push_back(gsl::narrow_cast(d)); diff --git a/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.h b/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.h index 4e62ba9bb8..1f89948e34 100644 --- a/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.h +++ b/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.h @@ -562,7 +562,7 @@ public: ends = operatorInfo.GetOptionalAttributeVectorInt32(AttrName::Ends); axes = operatorInfo.GetOptionalAttributeVectorInt32(AttrName::Axes); } - else if (opsetVersion == 10) + else if (opsetVersion == 10 || opsetVersion == 11) { // Read starts, ends, and axes from tensors. ReadIndexTensors(operatorInfo, /*out*/ starts, /*out*/ ends, /*out*/ axes, /*out*/ steps); @@ -615,6 +615,9 @@ public: end = std::min(end, dim); int size = std::max(end - start, 0); + // Set the input window offsets/sizes, and compute output size based on input + // window size (rounding up). + // e.g. a window size 13 and step 3 yields 5 output elements. int absoluteStride = abs(stride); m_outputDimensions[dimIndex] = (size / absoluteStride) + (size % absoluteStride != 0); m_offsets[dimIndex] = start;