Adds int32_t and uint32_t clip kernels (#15306)

This commit is contained in:
Aditya Goel 2023-04-04 21:44:50 +01:00 committed by GitHub
parent adb3d5dcb9
commit 1c1d386561
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 3 deletions

View file

@ -54,8 +54,8 @@ Do not modify directly.*
|Ceil|*in* X:**T**<br> *out* Y:**T**|13+|**T** = tensor(double), tensor(float)|
|||[6, 12]|**T** = tensor(double), tensor(float)|
|Celu|*in* X:**T**<br> *out* Y:**T**|12+|**T** = tensor(float)|
|Clip|*in* input:**T**<br> *in* min:**T**<br> *in* max:**T**<br> *out* output:**T**<br><br>or<br><br>*in* input:**T**<br> *out* output:**T**|13+|**T** = tensor(double), tensor(float), tensor(int64), tensor(int8), tensor(uint64), tensor(uint8)|
|||12|**T** = tensor(double), tensor(float), tensor(int64), tensor(int8), tensor(uint64), tensor(uint8)|
|Clip|*in* input:**T**<br> *in* min:**T**<br> *in* max:**T**<br> *out* output:**T**<br><br>or<br><br>*in* input:**T**<br> *out* output:**T**|13+|**T** = tensor(double), tensor(float), tensor(int32), tensor(int64), tensor(int8), tensor(uint32), tensor(uint64), tensor(uint8)|
|||12|**T** = tensor(double), tensor(float), tensor(int32), tensor(int64), tensor(int8), tensor(uint32), tensor(uint64), tensor(uint8)|
|||11|**T** = tensor(float)|
|||[6, 10]|**T** = tensor(float)|
|Col2Im|*in* input:**T**<br> *in* image_shape:**tensor(int64)**<br> *in* block_shape:**tensor(int64)**<br> *out* output:**T**|18+|**T** = tensor(float)|

View file

@ -23,7 +23,7 @@ ORT_SPECIFY_OP_KERNEL_ARG_DEFAULT_TYPES(
float);
ORT_SPECIFY_OP_KERNEL_ARG_DEFAULT_TYPES(
kCpuExecutionProvider, kOnnxDomain, Clip, 12, Input, 0,
float, double, int8_t, uint8_t, int64_t, uint64_t);
float, double, int8_t, uint8_t, int32_t, uint32_t, int64_t, uint64_t);
} // namespace op_kernel_type_control
using EnabledClip11Types = ORT_OP_KERNEL_ARG_ENABLED_TYPE_LIST(

View file

@ -123,6 +123,44 @@ TEST(MathOpTest, Clip_Default_uint64) {
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
}
TEST(MathOpTest, Clip_int32) {
OpTester test("Clip", 12);
std::vector<int64_t> dims{3, 3};
test.AddInput<int32_t>("X", dims,
{-1, 0, 1,
-16, 12, -6,
-5, 2, 16});
test.AddInput<int32_t>("min", {}, {-10});
test.AddInput<int32_t>("max", {}, {10});
test.AddOutput<int32_t>("Y", dims,
{-1, 0, 1,
-10, 10, -6,
-5, 2, 10});
// TensorRT does not support Clip opset 12 yet.
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
}
TEST(MathOpTest, Clip_uint32) {
OpTester test("Clip", 12);
std::vector<int64_t> dims{3, 3};
test.AddInput<uint32_t>("X", dims,
{0, 0, 1,
5, 12, 3,
2, 7, 16});
test.AddInput<uint32_t>("min", {}, {3});
test.AddInput<uint32_t>("max", {}, {10});
test.AddOutput<uint32_t>("Y", dims,
{3, 3, 3,
5, 10, 3,
3, 7, 10});
// TensorRT does not support Clip opset 12 yet.
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
}
TEST(MathOpTest, Clip) {
// To test NNAPI EP, we need the min/max to be in initializers
auto run_test = [](bool min_max_are_initializer) {