diff --git a/docs/OperatorKernels.md b/docs/OperatorKernels.md index 6f09fb5026..ee92269f1b 100644 --- a/docs/OperatorKernels.md +++ b/docs/OperatorKernels.md @@ -265,9 +265,9 @@ Do not modify directly.* |||13|**T** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)
**shape** = tensor(int64)| |||[5, 12]|**T** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)
**shape** = tensor(int64)| |||[1, 4]|**T** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)| -|Resize|*in* X:**T**
*in* scales:**tensor(float)**
*out* Y:**T**

or

*in* X:**T1**
*in* roi:**T2**
*in* scales:**tensor(float)**
*in* sizes:**tensor(int64)**
*out* Y:**T1**|13+|**T1** = tensor(float), tensor(int32), tensor(uint8)| -|||[11, 12]|**T1** = tensor(float), tensor(int32), tensor(uint8)| -|||10|**T** = tensor(float), tensor(int32), tensor(uint8)| +|Resize|*in* X:**T**
*in* scales:**tensor(float)**
*out* Y:**T**

or

*in* X:**T1**
*in* roi:**T2**
*in* scales:**tensor(float)**
*in* sizes:**tensor(int64)**
*out* Y:**T1**|13+|**T1** = tensor(float), tensor(int32), tensor(int8), tensor(uint8)| +|||[11, 12]|**T1** = tensor(float), tensor(int32), tensor(int8), tensor(uint8)| +|||10|**T** = tensor(float), tensor(int32), tensor(int8), tensor(uint8)| |ReverseSequence|*in* input:**T**
*in* sequence_lens:**tensor(int64)**
*out* Y:**T**|10+|**T** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)| |RoiAlign|*in* X:**T1**
*in* rois:**T1**
*in* batch_indices:**T2**
*out* Y:**T1**|10+|**T** = tensor(double), tensor(float)
**T2** = tensor(int64)| |Round|*in* X:**T**
*out* Y:**T**|11+|**T** = tensor(double), tensor(float), tensor(float16)| @@ -346,8 +346,8 @@ Do not modify directly.* |Unsqueeze|*in* data:**T**
*in* axes:**tensor(int64)**
*out* expanded:**T**

or

*in* data:**T**
*out* expanded:**T**|13+|**T** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)| |||[11, 12]|**T** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)| |||[1, 10]|**T** = tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)| -|Upsample|*in* X:**T**
*in* scales:**tensor(float)**
*out* Y:**T**

or

*in* X:**T**
*out* Y:**T**|9|**T** = tensor(float), tensor(int32), tensor(uint8)| -|||[7, 8]|**T** = tensor(float), tensor(int32), tensor(uint8)| +|Upsample|*in* X:**T**
*in* scales:**tensor(float)**
*out* Y:**T**

or

*in* X:**T**
*out* Y:**T**|9|**T** = tensor(float), tensor(int32), tensor(int8), tensor(uint8)| +|||[7, 8]|**T** = tensor(float), tensor(int32), tensor(int8), tensor(uint8)| |Where|*in* condition:**B**
*in* X:**T**
*in* Y:**T**
*out* output:**T**|9+|**T** = tensor(double), tensor(float), tensor(int32), tensor(int64), tensor(string), tensor(uint8)| |Xor|*in* A:**T**
*in* B:**T**
*out* C:**T1**|7+|**T** = tensor(bool)
**T1** = tensor(bool)| | | diff --git a/onnxruntime/core/providers/cpu/cpu_execution_provider.cc b/onnxruntime/core/providers/cpu/cpu_execution_provider.cc index c2fad48e06..1732170145 100644 --- a/onnxruntime/core/providers/cpu/cpu_execution_provider.cc +++ b/onnxruntime/core/providers/cpu/cpu_execution_provider.cc @@ -219,6 +219,7 @@ class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDoma class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 1, 10, Unsqueeze); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 7, 8, float, Upsample); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 7, 8, int32_t, Upsample); +class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 7, 8, int8_t, Upsample); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 7, 8, uint8_t, Upsample); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 8, 12, float, Expand); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 8, 12, double, Expand); @@ -298,6 +299,7 @@ class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOn class ONNX_OPERATOR_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, PRelu); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 9, float, Upsample); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 9, int32_t, Upsample); +class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 9, int8_t, Upsample); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 9, uint8_t, Upsample); // Opset 10 @@ -308,6 +310,7 @@ class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDoma class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 10, 12, Mod); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 10, 10, float, Resize); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 10, 10, int32_t, Resize); +class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 10, 10, int8_t, Resize); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 10, 10, uint8_t, Resize); class ONNX_OPERATOR_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 10, ThresholdedRelu); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 10, 12, uint8_t, DequantizeLinear); @@ -442,6 +445,7 @@ class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 11, int64_t_float_int32_t, OneHot); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 11, 12, float, Resize); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 11, 12, int32_t, Resize); +class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 11, 12, int8_t, Resize); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 11, 12, uint8_t, Resize); // opset 12 @@ -659,6 +663,7 @@ class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 13, int64_t, ReduceSum); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 13, float, Resize); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 13, int32_t, Resize); +class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 13, int8_t, Resize); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 13, uint8_t, Resize); class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 13, 15, Loop); class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 13, 15, If); @@ -1042,6 +1047,8 @@ Status RegisterOnnxOperatorKernels(KernelRegistry& kernel_registry) { float, Upsample)>, BuildKernelCreateInfo, + BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, + BuildKernelCreateInfo, BuildKernelCreateInfo, @@ -1201,6 +1210,8 @@ Status RegisterOnnxOperatorKernels(KernelRegistry& kernel_registry) { float, Resize)>, BuildKernelCreateInfo, + BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, @@ -1366,6 +1377,8 @@ Status RegisterOnnxOperatorKernels(KernelRegistry& kernel_registry) { float, Resize)>, BuildKernelCreateInfo, + BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, + BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, diff --git a/onnxruntime/core/providers/cpu/tensor/resize.cc b/onnxruntime/core/providers/cpu/tensor/resize.cc index 03468d6b97..6ff605b7a3 100644 --- a/onnxruntime/core/providers/cpu/tensor/resize.cc +++ b/onnxruntime/core/providers/cpu/tensor/resize.cc @@ -21,6 +21,14 @@ ONNX_CPU_OPERATOR_VERSIONED_TYPED_KERNEL( KernelDefBuilder().TypeConstraint("T", DataTypeImpl::GetTensorType()), Resize); +ONNX_CPU_OPERATOR_VERSIONED_TYPED_KERNEL( + Resize, + 10, + 10, + int8_t, + KernelDefBuilder().TypeConstraint("T", DataTypeImpl::GetTensorType()), + Resize); + ONNX_CPU_OPERATOR_VERSIONED_TYPED_KERNEL( Resize, 10, @@ -43,6 +51,13 @@ ONNX_CPU_OPERATOR_VERSIONED_TYPED_KERNEL( KernelDefBuilder().TypeConstraint("T1", DataTypeImpl::GetTensorType()), Resize); +ONNX_CPU_OPERATOR_VERSIONED_TYPED_KERNEL( + Resize, + 11, 12, + int8_t, + KernelDefBuilder().TypeConstraint("T1", DataTypeImpl::GetTensorType()), + Resize); + ONNX_CPU_OPERATOR_VERSIONED_TYPED_KERNEL( Resize, 11, 12, @@ -64,6 +79,13 @@ ONNX_CPU_OPERATOR_TYPED_KERNEL( KernelDefBuilder().TypeConstraint("T1", DataTypeImpl::GetTensorType()), Resize); +ONNX_CPU_OPERATOR_TYPED_KERNEL( + Resize, + 13, + int8_t, + KernelDefBuilder().TypeConstraint("T1", DataTypeImpl::GetTensorType()), + Resize); + ONNX_CPU_OPERATOR_TYPED_KERNEL( Resize, 13, diff --git a/onnxruntime/core/providers/cpu/tensor/upsample.cc b/onnxruntime/core/providers/cpu/tensor/upsample.cc index af6ef46d09..55422654ff 100644 --- a/onnxruntime/core/providers/cpu/tensor/upsample.cc +++ b/onnxruntime/core/providers/cpu/tensor/upsample.cc @@ -20,11 +20,13 @@ namespace onnxruntime { REGISTER_VERSIONED_TYPED_KERNEL(float, 7, 8); REGISTER_VERSIONED_TYPED_KERNEL(int32_t, 7, 8); +REGISTER_VERSIONED_TYPED_KERNEL(int8_t, 7, 8); REGISTER_VERSIONED_TYPED_KERNEL(uint8_t, 7, 8); // Upsample was deprecated in opset 10 REGISTER_VERSIONED_TYPED_KERNEL(float, 9, 9); REGISTER_VERSIONED_TYPED_KERNEL(int32_t, 9, 9); +REGISTER_VERSIONED_TYPED_KERNEL(int8_t, 9, 9); REGISTER_VERSIONED_TYPED_KERNEL(uint8_t, 9, 9); template diff --git a/onnxruntime/test/providers/cpu/tensor/resize_op_test.cc b/onnxruntime/test/providers/cpu/tensor/resize_op_test.cc index 96556f8e8d..6a9b8fb06e 100644 --- a/onnxruntime/test/providers/cpu/tensor/resize_op_test.cc +++ b/onnxruntime/test/providers/cpu/tensor/resize_op_test.cc @@ -1224,5 +1224,73 @@ TEST(ResizeOpTest, ResizeOp_MissingRoiAndMissingScalesOptionalInputs) { test.AddOutput("Y", {H, W}, X); test.Run(); } + +template +void ResizeOpTypeCheck_Ver_10() { + OpTester test("Resize", 10); + std::vector scales{1.0f, 1.0f, 2.0f, 3.0f}; + + test.AddAttribute("mode", "nearest"); + + constexpr int64_t N = 1, C = 1, H = 2, W = 2; + std::vector X = {1, 2, 3, 4}; + + test.AddInput("X", {N, C, H, W}, X); + test.AddInput("scales", {4}, scales); + + std::vector Y = {1, 1, 1, 2, 2, 2, + 1, 1, 1, 2, 2, 2, + 3, 3, 3, 4, 4, 4, + 3, 3, 3, 4, 4, 4}; + + test.AddOutput("Y", {N, C, static_cast(H * scales[2]), static_cast(W * scales[3])}, Y); + test.Run(); +} + +TEST(ResizeOpTest, ResizeOpTypeCheck_Ver_10) { + ResizeOpTypeCheck_Ver_10(); + ResizeOpTypeCheck_Ver_10(); + ResizeOpTypeCheck_Ver_10(); + ResizeOpTypeCheck_Ver_10(); +} + +template +void ResizeOpTypeCheck_Ver_11_13(int opset_version) { + OpTester test("Resize", opset_version); + std::vector roi{}; + std::vector scales{1.0f, 1.0f, 2.0f, 3.0f}; + + test.AddAttribute("mode", "nearest"); + + constexpr int64_t N = 1, C = 1, H = 2, W = 2; + std::vector X = {1, 2, 3, 4}; + + test.AddInput("X", {N, C, H, W}, X); + test.AddInput("roi", {0}, roi); + test.AddInput("scales", {4}, scales); + + std::vector Y = {1, 1, 1, 2, 2, 2, + 1, 1, 1, 2, 2, 2, + 3, 3, 3, 4, 4, 4, + 3, 3, 3, 4, 4, 4}; + + test.AddOutput("Y", {N, C, static_cast(H * scales[2]), static_cast(W * scales[3])}, Y); + test.Run(); +} + +TEST(ResizeOpTest, ResizeOpTypeCheck_Ver11) { + ResizeOpTypeCheck_Ver_11_13(11); + ResizeOpTypeCheck_Ver_11_13(11); + ResizeOpTypeCheck_Ver_11_13(11); + ResizeOpTypeCheck_Ver_11_13(11); +} + +TEST(ResizeOpTest, ResizeOpTypeCheck_Ver13) { + ResizeOpTypeCheck_Ver_11_13(13); + ResizeOpTypeCheck_Ver_11_13(13); + ResizeOpTypeCheck_Ver_11_13(13); + ResizeOpTypeCheck_Ver_11_13(13); +} + } // namespace test } // namespace onnxruntime diff --git a/onnxruntime/test/testdata/kernel_def_hashes/onnx.cpu.json b/onnxruntime/test/testdata/kernel_def_hashes/onnx.cpu.json index 9de2bbd54c..41027eff75 100644 --- a/onnxruntime/test/testdata/kernel_def_hashes/onnx.cpu.json +++ b/onnxruntime/test/testdata/kernel_def_hashes/onnx.cpu.json @@ -2095,6 +2095,18 @@ "Resize ai.onnx CPUExecutionProvider", 16654410418270805888 ], + [ + "Resize ai.onnx CPUExecutionProvider", + 11612050915202267528 + ], + [ + "Resize ai.onnx CPUExecutionProvider", + 17391179092212899176 + ], + [ + "Resize ai.onnx CPUExecutionProvider", + 18197536715869401872 + ], [ "ReverseSequence ai.onnx CPUExecutionProvider", 777686786711298232 @@ -2543,6 +2555,14 @@ "Upsample ai.onnx CPUExecutionProvider", 17854969343220970496 ], + [ + "Upsample ai.onnx CPUExecutionProvider", + 4881414272874428968 + ], + [ + "Upsample ai.onnx CPUExecutionProvider", + 7886741677344006832 + ], [ "Where ai.onnx CPUExecutionProvider", 4809895774227191528