diff --git a/backends/cadence/fused_quant/op_add.cpp b/backends/cadence/fused_quant/op_add.cpp index 1aea2ccfb6c..5308c1594ab 100644 --- a/backends/cadence/fused_quant/op_add.cpp +++ b/backends/cadence/fused_quant/op_add.cpp @@ -17,7 +17,6 @@ namespace native { using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::KernelRuntimeContext; -using std::optional; namespace { @@ -38,18 +37,18 @@ Tensor& add_out( KernelRuntimeContext& ctx, const Tensor& inp, const Tensor& other, - const optional& inp_scale, - const optional& inp_zero_point, + const std::optional& inp_scale, + const std::optional& inp_zero_point, ScalarType inp_dtype, int64_t inp_quant_min, int64_t inp_quant_max, - const optional& other_scale, - const optional& other_zero_point, + const std::optional& other_scale, + const std::optional& other_zero_point, ScalarType other_dtype, int64_t other_quant_min, int64_t other_quant_max, - const optional& out_scale, - const optional& out_zero_point, + const std::optional& out_scale, + const std::optional& out_zero_point, ScalarType out_dtype, int64_t out_quant_min, int64_t out_quant_max, diff --git a/backends/cadence/fused_quant/op_bmm.cpp b/backends/cadence/fused_quant/op_bmm.cpp index 8d071b48a33..7752e5792aa 100644 --- a/backends/cadence/fused_quant/op_bmm.cpp +++ b/backends/cadence/fused_quant/op_bmm.cpp @@ -17,7 +17,6 @@ namespace native { using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::KernelRuntimeContext; -using std::optional; namespace { @@ -48,18 +47,18 @@ Tensor& bmm_out( KernelRuntimeContext& ctx, const Tensor& inp, const Tensor& other, - const optional& inp_scale, - const optional& inp_zero_point, + const std::optional& inp_scale, + const std::optional& inp_zero_point, ScalarType inp_dtype, int64_t inp_quant_min, int64_t inp_quant_max, - const optional& other_scale, - const optional& other_zero_point, + const std::optional& other_scale, + const std::optional& other_zero_point, ScalarType other_dtype, int64_t other_quant_min, int64_t other_quant_max, - const optional& out_scale, - const optional& out_zero_point, + const std::optional& out_scale, + const std::optional& out_zero_point, ScalarType out_dtype, int64_t out_quant_min, int64_t out_quant_max, diff --git a/backends/cadence/fused_quant/op_hardswish.cpp b/backends/cadence/fused_quant/op_hardswish.cpp index 4b968cebe6c..2c198c6e393 100644 --- a/backends/cadence/fused_quant/op_hardswish.cpp +++ b/backends/cadence/fused_quant/op_hardswish.cpp @@ -19,7 +19,6 @@ namespace native { using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::KernelRuntimeContext; -using std::optional; namespace { @@ -35,13 +34,13 @@ void hardswish_kernel(const float* inp, float* out, int64_t numel) { Tensor& hardswish_out( KernelRuntimeContext& ctx, const Tensor& inp, - const optional& inp_scale, - const optional& inp_zero_point, + const std::optional& inp_scale, + const std::optional& inp_zero_point, ScalarType inp_dtype, int64_t inp_quant_min, int64_t inp_quant_max, - const optional& out_scale, - const optional& out_zero_point, + const std::optional& out_scale, + const std::optional& out_zero_point, ScalarType out_dtype, int64_t out_quant_min, int64_t out_quant_max, diff --git a/backends/cadence/fused_quant/op_mul.cpp b/backends/cadence/fused_quant/op_mul.cpp index a2595104ae8..dde8660ba45 100644 --- a/backends/cadence/fused_quant/op_mul.cpp +++ b/backends/cadence/fused_quant/op_mul.cpp @@ -17,7 +17,6 @@ namespace native { using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::KernelRuntimeContext; -using std::optional; namespace { @@ -37,18 +36,18 @@ Tensor& mul_out( KernelRuntimeContext& ctx, const Tensor& inp, const Tensor& other, - const optional& inp_scale, - const optional& inp_zero_point, + const std::optional& inp_scale, + const std::optional& inp_zero_point, ScalarType inp_dtype, int64_t inp_quant_min, int64_t inp_quant_max, - const optional& other_scale, - const optional& other_zero_point, + const std::optional& other_scale, + const std::optional& other_zero_point, ScalarType other_dtype, int64_t other_quant_min, int64_t other_quant_max, - const optional& out_scale, - const optional& out_zero_point, + const std::optional& out_scale, + const std::optional& out_zero_point, ScalarType out_dtype, int64_t out_quant_min, int64_t out_quant_max, diff --git a/backends/cadence/fused_quant/op_relu.cpp b/backends/cadence/fused_quant/op_relu.cpp index e8e58522d2e..25bda3bd78f 100644 --- a/backends/cadence/fused_quant/op_relu.cpp +++ b/backends/cadence/fused_quant/op_relu.cpp @@ -19,7 +19,6 @@ namespace native { using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::KernelRuntimeContext; -using std::optional; namespace { @@ -34,13 +33,13 @@ void relu_kernel(const float* inp, float* out, int64_t numel) { Tensor& relu_out( KernelRuntimeContext& ctx, const Tensor& inp, - const optional& inp_scale, - const optional& inp_zero_point, + const std::optional& inp_scale, + const std::optional& inp_zero_point, ScalarType inp_dtype, int64_t inp_quant_min, int64_t inp_quant_max, - const optional& out_scale, - const optional& out_zero_point, + const std::optional& out_scale, + const std::optional& out_zero_point, ScalarType out_dtype, int64_t out_quant_min, int64_t out_quant_max, diff --git a/backends/cadence/fused_quant/tests/test_op_add.cpp b/backends/cadence/fused_quant/tests/test_op_add.cpp index 61124f0b9b2..1e53583e048 100644 --- a/backends/cadence/fused_quant/tests/test_op_add.cpp +++ b/backends/cadence/fused_quant/tests/test_op_add.cpp @@ -17,12 +17,11 @@ using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::testing::TensorFactory; -using std::optional; namespace { -optional none_tensor() { - return optional(); +std::optional none_tensor() { + return std::optional(); } } // namespace @@ -57,18 +56,18 @@ TEST_F(FusedQuantAddTest, AllQuantizedPerTensor) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -110,8 +109,8 @@ TEST_F(FusedQuantAddTest, FloatInputsQuantizedOutput) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -146,8 +145,8 @@ TEST_F(FusedQuantAddTest, QuantizedInpFloatOther) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, @@ -156,8 +155,8 @@ TEST_F(FusedQuantAddTest, QuantizedInpFloatOther) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -197,13 +196,13 @@ TEST_F(FusedQuantAddTest, FloatInpQuantizedOther) { ScalarType::Float, 0, 0, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -238,13 +237,13 @@ TEST_F(FusedQuantAddTest, QuantizedInputsFloatOutput) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, @@ -281,8 +280,8 @@ TEST_F(FusedQuantAddTest, QuantizedInpFloatOtherFloatOutput) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, @@ -329,8 +328,8 @@ TEST_F(FusedQuantAddTest, FloatInpQuantizedOtherFloatOutput) { ScalarType::Float, 0, 0, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, @@ -374,8 +373,8 @@ TEST_F(FusedQuantAddTest, PerChannelInput) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, @@ -384,8 +383,8 @@ TEST_F(FusedQuantAddTest, PerChannelInput) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -430,8 +429,8 @@ TEST_F(FusedQuantAddTest, PerChannelOutput) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -469,18 +468,18 @@ TEST_F(FusedQuantAddTest, AlphaScaling) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -521,18 +520,18 @@ TEST_F(FusedQuantAddTest, NonZeroZeroPoint) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, diff --git a/backends/cadence/fused_quant/tests/test_op_bmm.cpp b/backends/cadence/fused_quant/tests/test_op_bmm.cpp index bae04993a7a..208274534a6 100644 --- a/backends/cadence/fused_quant/tests/test_op_bmm.cpp +++ b/backends/cadence/fused_quant/tests/test_op_bmm.cpp @@ -17,12 +17,11 @@ using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::testing::TensorFactory; -using std::optional; namespace { -optional none_tensor() { - return optional(); +std::optional none_tensor() { + return std::optional(); } } // namespace @@ -64,18 +63,18 @@ TEST_F(FusedQuantBmmTest, AllQuantizedPerTensor) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -119,8 +118,8 @@ TEST_F(FusedQuantBmmTest, FloatInputsQuantizedOutput) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -156,13 +155,13 @@ TEST_F(FusedQuantBmmTest, QuantizedInputsFloatOutput) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, @@ -203,8 +202,8 @@ TEST_F(FusedQuantBmmTest, QuantizedInpFloatOther) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, @@ -213,8 +212,8 @@ TEST_F(FusedQuantBmmTest, QuantizedInpFloatOther) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -263,18 +262,18 @@ TEST_F(FusedQuantBmmTest, NonZeroZeroPoint) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -317,18 +316,18 @@ TEST_F(FusedQuantBmmTest, LargerBatch) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, diff --git a/backends/cadence/fused_quant/tests/test_op_hardswish.cpp b/backends/cadence/fused_quant/tests/test_op_hardswish.cpp index eb6231161f2..a78a8beb0cb 100644 --- a/backends/cadence/fused_quant/tests/test_op_hardswish.cpp +++ b/backends/cadence/fused_quant/tests/test_op_hardswish.cpp @@ -17,12 +17,11 @@ using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::testing::TensorFactory; -using std::optional; namespace { -optional none_tensor() { - return optional(); +std::optional none_tensor() { + return std::optional(); } } // namespace @@ -57,13 +56,13 @@ TEST_F(FusedQuantHardswishTest, AllQuantizedPerTensor) { cadence::fused_quant::native::hardswish_out( context_, inp, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -97,8 +96,8 @@ TEST_F(FusedQuantHardswishTest, FloatInputQuantizedOutput) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -127,8 +126,8 @@ TEST_F(FusedQuantHardswishTest, QuantizedInputFloatOutput) { cadence::fused_quant::native::hardswish_out( context_, inp, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, @@ -173,13 +172,13 @@ TEST_F(FusedQuantHardswishTest, PerChannelInput) { cadence::fused_quant::native::hardswish_out( context_, inp, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -218,8 +217,8 @@ TEST_F(FusedQuantHardswishTest, PerChannelOutput) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -254,13 +253,13 @@ TEST_F(FusedQuantHardswishTest, NonZeroZeroPoint) { cadence::fused_quant::native::hardswish_out( context_, inp, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -297,8 +296,8 @@ TEST_F(FusedQuantHardswishTest, NegativeRegion) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -368,13 +367,13 @@ TEST_F(FusedQuantHardswishTest, TransitionRegion) { cadence::fused_quant::native::hardswish_out( context_, inp, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, diff --git a/backends/cadence/fused_quant/tests/test_op_mul.cpp b/backends/cadence/fused_quant/tests/test_op_mul.cpp index da27c7287c9..cc9edada801 100644 --- a/backends/cadence/fused_quant/tests/test_op_mul.cpp +++ b/backends/cadence/fused_quant/tests/test_op_mul.cpp @@ -17,12 +17,11 @@ using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::testing::TensorFactory; -using std::optional; namespace { -optional none_tensor() { - return optional(); +std::optional none_tensor() { + return std::optional(); } } // namespace @@ -57,18 +56,18 @@ TEST_F(FusedQuantMulTest, AllQuantizedPerTensor) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -109,8 +108,8 @@ TEST_F(FusedQuantMulTest, FloatInputsQuantizedOutput) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -144,8 +143,8 @@ TEST_F(FusedQuantMulTest, QuantizedInpFloatOther) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, @@ -154,8 +153,8 @@ TEST_F(FusedQuantMulTest, QuantizedInpFloatOther) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -194,13 +193,13 @@ TEST_F(FusedQuantMulTest, FloatInpQuantizedOther) { ScalarType::Float, 0, 0, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -234,13 +233,13 @@ TEST_F(FusedQuantMulTest, QuantizedInputsFloatOutput) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, @@ -276,8 +275,8 @@ TEST_F(FusedQuantMulTest, QuantizedInpFloatOtherFloatOutput) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, @@ -323,8 +322,8 @@ TEST_F(FusedQuantMulTest, FloatInpQuantizedOtherFloatOutput) { ScalarType::Float, 0, 0, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, @@ -367,8 +366,8 @@ TEST_F(FusedQuantMulTest, PerChannelInput) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, @@ -377,8 +376,8 @@ TEST_F(FusedQuantMulTest, PerChannelInput) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -422,8 +421,8 @@ TEST_F(FusedQuantMulTest, PerChannelOutput) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -463,18 +462,18 @@ TEST_F(FusedQuantMulTest, NonZeroZeroPoint) { context_, inp, other, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(other_scale), - optional(other_zp), + std::optional(other_scale), + std::optional(other_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, diff --git a/backends/cadence/fused_quant/tests/test_op_relu.cpp b/backends/cadence/fused_quant/tests/test_op_relu.cpp index 1096daae202..77ca8b7450d 100644 --- a/backends/cadence/fused_quant/tests/test_op_relu.cpp +++ b/backends/cadence/fused_quant/tests/test_op_relu.cpp @@ -17,12 +17,11 @@ using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::testing::TensorFactory; -using std::optional; namespace { -optional none_tensor() { - return optional(); +std::optional none_tensor() { + return std::optional(); } } // namespace @@ -52,13 +51,13 @@ TEST_F(FusedQuantReluTest, AllQuantizedPerTensor) { cadence::fused_quant::native::relu_out( context_, inp, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -92,8 +91,8 @@ TEST_F(FusedQuantReluTest, FloatInputQuantizedOutput) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -122,8 +121,8 @@ TEST_F(FusedQuantReluTest, QuantizedInputFloatOutput) { cadence::fused_quant::native::relu_out( context_, inp, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, @@ -164,13 +163,13 @@ TEST_F(FusedQuantReluTest, PerChannelInput) { cadence::fused_quant::native::relu_out( context_, inp, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -207,8 +206,8 @@ TEST_F(FusedQuantReluTest, PerChannelOutput) { ScalarType::Float, 0, 0, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -243,13 +242,13 @@ TEST_F(FusedQuantReluTest, NonZeroZeroPoint) { cadence::fused_quant::native::relu_out( context_, inp, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -281,13 +280,13 @@ TEST_F(FusedQuantReluTest, AllNegativeInputs) { cadence::fused_quant::native::relu_out( context_, inp, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, @@ -319,13 +318,13 @@ TEST_F(FusedQuantReluTest, AllPositiveInputs) { cadence::fused_quant::native::relu_out( context_, inp, - optional(inp_scale), - optional(inp_zp), + std::optional(inp_scale), + std::optional(inp_zp), ScalarType::Float, -128, 127, - optional(out_scale), - optional(out_zp), + std::optional(out_scale), + std::optional(out_zp), ScalarType::Char, -128, 127, diff --git a/backends/cadence/fusion_g3/operators/op_clamp.cpp b/backends/cadence/fusion_g3/operators/op_clamp.cpp index 8eed6b681c2..6e4c3de28ec 100644 --- a/backends/cadence/fusion_g3/operators/op_clamp.cpp +++ b/backends/cadence/fusion_g3/operators/op_clamp.cpp @@ -27,7 +27,6 @@ using ::executorch::aten::Tensor; using ::executorch::runtime::canCast; using ::executorch::runtime::Error; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; namespace impl { namespace G3 { @@ -80,8 +79,8 @@ ET_NODISCARD bool check_bounds( Tensor& clamp_out( KernelRuntimeContext& ctx, const Tensor& in, - const optional& min_opt, - const optional& max_opt, + const std::optional& min_opt, + const std::optional& max_opt, Tensor& out) { bool has_min = min_opt.has_value(); bool has_max = max_opt.has_value(); @@ -333,8 +332,8 @@ Tensor& clamp_out( Tensor& clamp_Tensor_out( KernelRuntimeContext& ctx, const Tensor& in, - const optional& min_opt, - const optional& max_opt, + const std::optional& min_opt, + const std::optional& max_opt, Tensor& out) { bool has_min = min_opt.has_value(); bool has_max = max_opt.has_value(); diff --git a/backends/cadence/fusion_g3/operators/op_div.cpp b/backends/cadence/fusion_g3/operators/op_div.cpp index e3610a84baf..2efe2b8885d 100644 --- a/backends/cadence/fusion_g3/operators/op_div.cpp +++ b/backends/cadence/fusion_g3/operators/op_div.cpp @@ -26,8 +26,6 @@ using ::executorch::aten::Tensor; using ::executorch::runtime::canCast; using ::executorch::runtime::Error; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; -using std::string_view; namespace impl { namespace G3 { @@ -256,7 +254,7 @@ Tensor& div_out_mode( KernelRuntimeContext& ctx, const Tensor& a, const Tensor& b, - optional mode, + std::optional mode, Tensor& out) { ET_DCHECK_MSG(!tensor_has_zero(b), "divisor tensor contains zero"); @@ -583,7 +581,7 @@ Tensor& div_scalar_mode_out( KernelRuntimeContext& ctx, const Tensor& a, const Scalar& b, - optional mode, + std::optional mode, Tensor& out) { if (!mode.has_value()) { return div_scalar_out(ctx, a, b, out); diff --git a/backends/cadence/fusion_g3/operators/op_mean.cpp b/backends/cadence/fusion_g3/operators/op_mean.cpp index cefd45f6ef8..335e4d09f68 100644 --- a/backends/cadence/fusion_g3/operators/op_mean.cpp +++ b/backends/cadence/fusion_g3/operators/op_mean.cpp @@ -21,7 +21,6 @@ using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::Error; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; namespace impl { namespace G3 { @@ -30,7 +29,7 @@ namespace native { int prepare_data( const Tensor& in, Tensor& out, - optional> dim_list, + std::optional> dim_list, int* inp_shape, int* out_shape, int* p_axis, @@ -62,9 +61,9 @@ int prepare_data( Tensor& mean_out( KernelRuntimeContext& ctx, const Tensor& in, - optional> dim_list, + std::optional> dim_list, bool keepdim, - optional dtype, + std::optional dtype, Tensor& out) { (void)ctx; diff --git a/backends/cadence/fusion_g3/operators/op_native_layer_norm.cpp b/backends/cadence/fusion_g3/operators/op_native_layer_norm.cpp index aa25cec9230..9bef36fe261 100644 --- a/backends/cadence/fusion_g3/operators/op_native_layer_norm.cpp +++ b/backends/cadence/fusion_g3/operators/op_native_layer_norm.cpp @@ -23,7 +23,6 @@ using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::Error; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; namespace impl { namespace G3 { @@ -35,8 +34,8 @@ template void layer_norm( const Tensor& input, IntArrayRef normalized_shape, - const optional& weight, - const optional& bias, + const std::optional& weight, + const std::optional& bias, CTYPE eps, Tensor& out, Tensor& mean, @@ -112,8 +111,8 @@ std::tuple native_layer_norm_out( KernelRuntimeContext& ctx, const Tensor& input, IntArrayRef normalized_shape, - const optional& weight, - const optional& bias, + const std::optional& weight, + const std::optional& bias, double eps, Tensor& out, Tensor& mean_out, diff --git a/backends/cadence/generic/operators/op_avg_pool2d.cpp b/backends/cadence/generic/operators/op_avg_pool2d.cpp index c33f91151fb..0132dbd8633 100644 --- a/backends/cadence/generic/operators/op_avg_pool2d.cpp +++ b/backends/cadence/generic/operators/op_avg_pool2d.cpp @@ -23,7 +23,6 @@ using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::getLeadingDims; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; // Compute the avg_pool2d for in_data in NCHW layout. IT is the input datatype, // and AT is the accumulation datatype. 'quantized' is true when the input is @@ -37,7 +36,7 @@ void avg_pool2d_nchw( IntArrayRef stride, IntArrayRef padding, bool count_include_pad, - optional divisor_override, + std::optional divisor_override, int leading_dims, int ih, int iw, @@ -99,8 +98,8 @@ Tensor& avg_pool2d_out( IntArrayRef padding, bool ceil_mode, bool count_include_pad, - optional divisor_override, - const optional& in_zero_point_t, + std::optional divisor_override, + const std::optional& in_zero_point_t, bool channel_last, Tensor& out) { ET_DCHECK_MSG(!channel_last, "NHWC layout for avg_pool2d not yet supported"); diff --git a/backends/cadence/generic/operators/op_fully_connected.cpp b/backends/cadence/generic/operators/op_fully_connected.cpp index b65f8016880..006970e4737 100644 --- a/backends/cadence/generic/operators/op_fully_connected.cpp +++ b/backends/cadence/generic/operators/op_fully_connected.cpp @@ -18,12 +18,11 @@ namespace native { using ::executorch::aten::Tensor; using ::executorch::runtime::getLeadingDims; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; void linear( const Tensor& input, const Tensor& weight, - const optional& bias, + const std::optional& bias, Tensor& output) { const float* __restrict__ input_data = input.const_data_ptr(); const float* __restrict__ weight_data = weight.const_data_ptr(); @@ -57,7 +56,7 @@ Tensor& fully_connected_out( ET_UNUSED KernelRuntimeContext& ctx, const Tensor& input, const Tensor& weight, - const optional& bias, + const std::optional& bias, Tensor& output) { linear(input, weight, bias, output); return output; diff --git a/backends/cadence/generic/operators/op_fully_connected.h b/backends/cadence/generic/operators/op_fully_connected.h index 7e03f5ef664..b2b7af6022a 100644 --- a/backends/cadence/generic/operators/op_fully_connected.h +++ b/backends/cadence/generic/operators/op_fully_connected.h @@ -17,13 +17,12 @@ namespace native { using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; Tensor& fully_connected_out( KernelRuntimeContext& ctx, const Tensor& input, const Tensor& weight, - const optional& bias, + const std::optional& bias, Tensor& output); } // namespace native diff --git a/backends/cadence/generic/operators/op_quantized_embedding_byte.cpp b/backends/cadence/generic/operators/op_quantized_embedding_byte.cpp index 54abb75b765..70cd2268e76 100644 --- a/backends/cadence/generic/operators/op_quantized_embedding_byte.cpp +++ b/backends/cadence/generic/operators/op_quantized_embedding_byte.cpp @@ -21,7 +21,6 @@ namespace native { using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; #define ET_FORALL_CADENCE_QUANTIZED_TYPES(_) \ _(uint8_t, Byte) \ @@ -31,7 +30,7 @@ Tensor& quantized_embedding_byte_out( ET_UNUSED KernelRuntimeContext& ctx, const Tensor& weight, const Tensor& weight_scales, - const optional& weight_zero_points, + const std::optional& weight_zero_points, const Tensor& indices, ET_UNUSED bool pruned_weights, Tensor& out) { diff --git a/backends/cadence/generic/operators/op_quantized_fully_connected.cpp b/backends/cadence/generic/operators/op_quantized_fully_connected.cpp index ce74b5b8b7f..67a78f2d9c7 100644 --- a/backends/cadence/generic/operators/op_quantized_fully_connected.cpp +++ b/backends/cadence/generic/operators/op_quantized_fully_connected.cpp @@ -19,7 +19,6 @@ namespace native { using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; Tensor& quantized_fully_connected_out( ET_UNUSED KernelRuntimeContext& ctx, @@ -31,7 +30,7 @@ Tensor& quantized_fully_connected_out( const Tensor& out_multiplier, const Tensor& out_shift, int64_t out_zero_point, - ET_UNUSED const optional& offset, + ET_UNUSED const std::optional& offset, Tensor& out) { #define typed_quantized_linear(ctype, dtype) \ case ScalarType::dtype: { \ @@ -69,7 +68,7 @@ Tensor& quantized_fully_connected_per_tensor_out( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - ET_UNUSED const optional& offset, + ET_UNUSED const std::optional& offset, Tensor& out) { #define typed_quantized_linear(ctype, dtype) \ case ScalarType::dtype: { \ @@ -107,7 +106,7 @@ Tensor& quantized_fully_connected_asym8sxasym8s_asym8s_per_tensor_out( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - ET_UNUSED const optional& offset, + ET_UNUSED const std::optional& offset, Tensor& out) { #define typed_quantized_linear(ctype, dtype) \ case ScalarType::dtype: { \ @@ -145,7 +144,7 @@ Tensor& quantized_fully_connected_asym8uxasym8u_asym8u_per_tensor_out( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - ET_UNUSED const optional& offset, + ET_UNUSED const std::optional& offset, Tensor& out) { #define typed_quantized_linear(ctype, dtype) \ case ScalarType::dtype: { \ diff --git a/backends/cadence/generic/operators/op_quantized_linear.cpp b/backends/cadence/generic/operators/op_quantized_linear.cpp index 02ff97de74d..dcfb16312cb 100644 --- a/backends/cadence/generic/operators/op_quantized_linear.cpp +++ b/backends/cadence/generic/operators/op_quantized_linear.cpp @@ -22,7 +22,6 @@ using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; using ::executorch::runtime::toString; -using std::optional; Tensor& quantized_linear_out( ET_UNUSED KernelRuntimeContext& ctx, @@ -34,7 +33,7 @@ Tensor& quantized_linear_out( const Tensor& out_multiplier, const Tensor& out_shift, int64_t out_zero_point, - ET_UNUSED const optional& offset, + ET_UNUSED const std::optional& offset, Tensor& out) { #define typed_quantized_linear(ctype, dtype) \ case ScalarType::dtype: { \ @@ -88,7 +87,7 @@ Tensor& quantized_linear_per_tensor_out( const int64_t out_multiplier, const int64_t out_shift, const int64_t out_zero_point, - ET_UNUSED const optional& offset, + ET_UNUSED const std::optional& offset, Tensor& out) { #define typed_quantized_linear_per_tensor(ctype, dtype) \ case ScalarType::dtype: { \ diff --git a/backends/cadence/generic/operators/op_quantized_matmul.cpp b/backends/cadence/generic/operators/op_quantized_matmul.cpp index b3dc9e7c21a..fa106bda67e 100644 --- a/backends/cadence/generic/operators/op_quantized_matmul.cpp +++ b/backends/cadence/generic/operators/op_quantized_matmul.cpp @@ -24,7 +24,6 @@ using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; using ::impl::generic::kernels::quantize; -using std::optional; // The quantized matmul. The quantized matmul accumulates in a wider register, // whose type is TA. @@ -69,7 +68,7 @@ Tensor& quantized_matmul_out( int64_t X_zero_point, const Tensor& Y, int64_t Y_zero_point, - ET_UNUSED const optional& bias, + ET_UNUSED const std::optional& bias, int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, @@ -179,7 +178,7 @@ void _typed_quantized_matmul( int64_t X_zero_point, const Tensor& Y, int64_t Y_zero_point, - ET_UNUSED const optional& bias, + ET_UNUSED const std::optional& bias, int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, @@ -233,7 +232,7 @@ Tensor& quantized_matmul_asym8sxasym8s_asym8s_out( int64_t X_zero_point, const Tensor& Y, int64_t Y_zero_point, - const optional& bias, + const std::optional& bias, int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, @@ -259,7 +258,7 @@ Tensor& quantized_matmul_asym8uxasym8u_asym8u_out( int64_t X_zero_point, const Tensor& Y, int64_t Y_zero_point, - const optional& bias, + const std::optional& bias, int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, diff --git a/backends/cadence/generic/operators/op_quantized_matmul.h b/backends/cadence/generic/operators/op_quantized_matmul.h index c28862aa11e..1aa5da20f8f 100644 --- a/backends/cadence/generic/operators/op_quantized_matmul.h +++ b/backends/cadence/generic/operators/op_quantized_matmul.h @@ -17,7 +17,6 @@ namespace native { using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; Tensor& quantized_matmul_out( KernelRuntimeContext& ctx, @@ -25,7 +24,7 @@ Tensor& quantized_matmul_out( int64_t X_zero_point, const Tensor& Y, int64_t Y_zero_point, - const optional& bias, + const std::optional& bias, int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, @@ -38,7 +37,7 @@ Tensor& quantized_matmul_asym8sxasym8s_asym8s_out( int64_t X_zero_point, const Tensor& Y, int64_t Y_zero_point, - const optional& bias, + const std::optional& bias, int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, @@ -51,7 +50,7 @@ Tensor& quantized_matmul_asym8uxasym8u_asym8u_out( int64_t X_zero_point, const Tensor& Y, int64_t Y_zero_point, - const optional& bias, + const std::optional& bias, int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, diff --git a/backends/cadence/generic/operators/op_rope.cpp b/backends/cadence/generic/operators/op_rope.cpp index fcc7d629cf7..9bcd1e9b354 100644 --- a/backends/cadence/generic/operators/op_rope.cpp +++ b/backends/cadence/generic/operators/op_rope.cpp @@ -13,14 +13,13 @@ namespace generic { namespace native { using ::executorch::aten::Tensor; -using std::optional; Tensor& rope_out( ET_UNUSED ::executorch::runtime::KernelRuntimeContext& ctx, const Tensor& input, const Tensor& sin_tensor, const Tensor& cos_tensor, - const optional& pos, + const std::optional& pos, Tensor& out) { // Input shape is [1, seq, h, hd / 2, 2] or [1, seq, h, hd] const ssize_t seq_length = input.size(1); @@ -76,14 +75,13 @@ namespace generic { namespace native { using ::executorch::aten::Tensor; -using std::optional; Tensor& rope_rotate_stacked_halves_out( ET_UNUSED ::executorch::runtime::KernelRuntimeContext& ctx, const Tensor& input, const Tensor& sin_tensor, const Tensor& cos_tensor, - const optional& pos, + const std::optional& pos, Tensor& out) { // Input shape is [1, seq, h, 2, hd / 2] or [1, seq, h, hd] const ssize_t seq_length = input.size(1); diff --git a/backends/cadence/hifi/operators/op_mean.cpp b/backends/cadence/hifi/operators/op_mean.cpp index ccd54e80698..687de584c24 100644 --- a/backends/cadence/hifi/operators/op_mean.cpp +++ b/backends/cadence/hifi/operators/op_mean.cpp @@ -17,7 +17,6 @@ using executorch::aten::RuntimeContext; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::ArrayRef; -using std::optional; using torch::executor::Error; namespace impl { @@ -27,7 +26,7 @@ namespace native { int prepare_data( const Tensor& in, Tensor& out, - optional> dim_list, + std::optional> dim_list, int* inp_shape, int* out_shape, int* p_axis, @@ -58,9 +57,9 @@ int prepare_data( Tensor& mean_out( RuntimeContext& ctx, const Tensor& in, - optional> dim_list, + std::optional> dim_list, bool keepdim, - optional dtype, + std::optional dtype, Tensor& out) { ET_KERNEL_CHECK( ctx, @@ -170,9 +169,9 @@ Tensor& mean_out( Tensor& mean_dim_out( RuntimeContext& ctx, const Tensor& in, - optional> dim_list, + std::optional> dim_list, bool keepdim, - optional dtype, + std::optional dtype, Tensor& out) { return mean_out(ctx, in, dim_list, keepdim, dtype, out); } diff --git a/backends/cadence/hifi/operators/op_quantized_conv2d_nhwc_out.cpp b/backends/cadence/hifi/operators/op_quantized_conv2d_nhwc_out.cpp index 86ef244711d..79dd1379d18 100644 --- a/backends/cadence/hifi/operators/op_quantized_conv2d_nhwc_out.cpp +++ b/backends/cadence/hifi/operators/op_quantized_conv2d_nhwc_out.cpp @@ -17,7 +17,6 @@ using Tensor = executorch::aten::Tensor; using KernelRuntimeContext = torch::executor::KernelRuntimeContext; using ScalarType = executorch::aten::ScalarType; using ::executorch::aten::IntArrayRef; -using std::optional; namespace impl { namespace HiFi { @@ -379,7 +378,7 @@ void xa_opt_quantized_conv2d_nhwc( output_zero_point, 0, // out_multiplier (unused) 0, // out_shift (unused) - optional(), // offset (unused) + std::optional(), // offset (unused) out); } @@ -570,7 +569,7 @@ void quantized_conv2d_nhwc_per_tensor_out( int64_t output_zero_point, __ET_UNUSED int64_t out_multiplier, __ET_UNUSED int64_t out_shift, - const optional& offset, + const std::optional& offset, Tensor& out) { // Handle W8A16 heterogeneous type (int16_t activations, int8_t weights) if (out.scalar_type() == ::executorch::aten::ScalarType::Short && diff --git a/backends/cadence/hifi/operators/op_quantized_fully_connected_asym8sxasym8s_asym8s_per_tensor_out.cpp b/backends/cadence/hifi/operators/op_quantized_fully_connected_asym8sxasym8s_asym8s_per_tensor_out.cpp index 1c5e725a023..f3e46329ff2 100644 --- a/backends/cadence/hifi/operators/op_quantized_fully_connected_asym8sxasym8s_asym8s_per_tensor_out.cpp +++ b/backends/cadence/hifi/operators/op_quantized_fully_connected_asym8sxasym8s_asym8s_per_tensor_out.cpp @@ -15,7 +15,6 @@ namespace native { using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; void quantized_fully_connected_asym8sxasym8s_asym8s_per_tensor_out( __ET_UNUSED KernelRuntimeContext& ctx, @@ -27,7 +26,7 @@ void quantized_fully_connected_asym8sxasym8s_asym8s_per_tensor_out( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { // input comes in shape [leading_dims, in_dim] // weight comes in shape [out_dim, in_dim] diff --git a/backends/cadence/hifi/operators/op_quantized_fully_connected_asym8uxasym8u_asym8u_per_tensor_out.cpp b/backends/cadence/hifi/operators/op_quantized_fully_connected_asym8uxasym8u_asym8u_per_tensor_out.cpp index fe94700ebef..fde0621e5b9 100644 --- a/backends/cadence/hifi/operators/op_quantized_fully_connected_asym8uxasym8u_asym8u_per_tensor_out.cpp +++ b/backends/cadence/hifi/operators/op_quantized_fully_connected_asym8uxasym8u_asym8u_per_tensor_out.cpp @@ -15,7 +15,6 @@ namespace native { using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; void quantized_fully_connected_asym8uxasym8u_asym8u_per_tensor_out( __ET_UNUSED KernelRuntimeContext& ctx, @@ -27,7 +26,7 @@ void quantized_fully_connected_asym8uxasym8u_asym8u_per_tensor_out( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { // input comes in shape [leading_dims, in_dim] // weight comes in shape [out_dim, in_dim] diff --git a/backends/cadence/hifi/operators/op_quantized_fully_connected_out.cpp b/backends/cadence/hifi/operators/op_quantized_fully_connected_out.cpp index 5b75ea110c7..ea005edc500 100644 --- a/backends/cadence/hifi/operators/op_quantized_fully_connected_out.cpp +++ b/backends/cadence/hifi/operators/op_quantized_fully_connected_out.cpp @@ -19,7 +19,6 @@ namespace native { using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; void inline _quantized_fully_connected_asym8u( const Tensor& in, @@ -30,7 +29,7 @@ void inline _quantized_fully_connected_asym8u( const Tensor& out_multiplier, const Tensor& out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { // input comes in shape [leading_dims, in_dim] // weight comes in shape [out_dim, in_dim] @@ -69,7 +68,7 @@ void inline _quantized_fully_connected_asym8s( const Tensor& out_multiplier, const Tensor& out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { // input comes in shape [leading_dims, in_dim] // weight comes in shape [out_dim, in_dim] @@ -109,7 +108,7 @@ void quantized_fully_connected_out( const Tensor& out_multiplier, const Tensor& out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { if (out.scalar_type() == ScalarType::Byte) { _quantized_fully_connected_asym8u( @@ -151,7 +150,7 @@ void inline _quantized_fully_connected_per_tensor_asym8u( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { // input comes in shape [leading_dims, in_dim] // weight comes in shape [out_dim, in_dim] @@ -190,7 +189,7 @@ void inline _quantized_fully_connected_per_tensor_asym8s( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { // input comes in shape [leading_dims, in_dim] // weight comes in shape [out_dim, in_dim] @@ -230,7 +229,7 @@ void quantized_fully_connected_per_tensor_out( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { if (out.scalar_type() == ScalarType::Byte) { _quantized_fully_connected_per_tensor_asym8u( diff --git a/backends/cadence/hifi/operators/op_quantized_linear_asym8sxasym8s_asym8s_per_tensor_out.cpp b/backends/cadence/hifi/operators/op_quantized_linear_asym8sxasym8s_asym8s_per_tensor_out.cpp index 76ab229d606..c1a73205241 100644 --- a/backends/cadence/hifi/operators/op_quantized_linear_asym8sxasym8s_asym8s_per_tensor_out.cpp +++ b/backends/cadence/hifi/operators/op_quantized_linear_asym8sxasym8s_asym8s_per_tensor_out.cpp @@ -17,7 +17,6 @@ namespace native { using ::executorch::aten::Tensor; using ::executorch::runtime::getLeadingDims; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; void quantized_linear_asym8sxasym8s_asym8s_per_tensor_out( __ET_UNUSED KernelRuntimeContext& ctx, @@ -29,7 +28,7 @@ void quantized_linear_asym8sxasym8s_asym8s_per_tensor_out( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { // input comes in shape [leading_dims, in_dim] // weight comes in shape [out_dim, in_dim] diff --git a/backends/cadence/hifi/operators/op_quantized_linear_asym8uxasym8u_asym8u_per_tensor_out.cpp b/backends/cadence/hifi/operators/op_quantized_linear_asym8uxasym8u_asym8u_per_tensor_out.cpp index be5246b8cc8..608deca76e4 100644 --- a/backends/cadence/hifi/operators/op_quantized_linear_asym8uxasym8u_asym8u_per_tensor_out.cpp +++ b/backends/cadence/hifi/operators/op_quantized_linear_asym8uxasym8u_asym8u_per_tensor_out.cpp @@ -17,7 +17,6 @@ namespace native { using ::executorch::aten::Tensor; using ::executorch::runtime::getLeadingDims; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; void quantized_linear_asym8uxasym8u_asym8u_per_tensor_out( __ET_UNUSED KernelRuntimeContext& ctx, @@ -29,7 +28,7 @@ void quantized_linear_asym8uxasym8u_asym8u_per_tensor_out( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { // input comes in shape [leading_dims, in_dim] // weight comes in shape [out_dim, in_dim] diff --git a/backends/cadence/hifi/operators/op_quantized_linear_out.cpp b/backends/cadence/hifi/operators/op_quantized_linear_out.cpp index 75d7753e8c4..43b5fa7f2a1 100644 --- a/backends/cadence/hifi/operators/op_quantized_linear_out.cpp +++ b/backends/cadence/hifi/operators/op_quantized_linear_out.cpp @@ -23,7 +23,6 @@ namespace impl::HiFi::native { using ::executorch::aten::Tensor; using ::executorch::runtime::getLeadingDims; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; // The nnlib kernel to compute quantized linear via matmul. @@ -36,7 +35,7 @@ void _quantized_linear_asym8u( const Tensor& out_multiplier, const Tensor& out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { const int64_t leading_dims = getLeadingDims(in, in.dim() - 1); const int64_t out_dim = weight.size(0); // = out_dim @@ -74,7 +73,7 @@ void inline _quantized_linear_asym8s( const Tensor& out_multiplier, const Tensor& out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { // input comes in shape [leading_dims, in_dim] // weight comes in shape [out_dim, in_dim] @@ -119,7 +118,7 @@ void inline _quantized_linear_per_tensor_asym8u( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { // input comes in shape [leading_dims, in_dim] // weight comes in shape [out_dim, in_dim] @@ -167,7 +166,7 @@ void inline _quantized_linear_per_tensor_asym8s( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { // input comes in shape [leading_dims, in_dim] // weight comes in shape [out_dim, in_dim] @@ -216,7 +215,7 @@ void quantized_linear_out( const Tensor& out_multiplier, const Tensor& out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { if (out.scalar_type() == ::executorch::aten::ScalarType::Short && in.scalar_type() == ::executorch::aten::ScalarType::Short && @@ -273,7 +272,7 @@ void quantized_linear_per_tensor_out( const int64_t out_multiplier, const int64_t out_shift, const int64_t out_zero_point, - const optional& offset, + const std::optional& offset, Tensor& out) { if (out.scalar_type() == ::executorch::aten::ScalarType::Short && in.scalar_type() == ::executorch::aten::ScalarType::Short && diff --git a/backends/cadence/hifi/operators/tests/test_op_div.cpp b/backends/cadence/hifi/operators/tests/test_op_div.cpp index 7237e0aeb24..aa66f8aea91 100644 --- a/backends/cadence/hifi/operators/tests/test_op_div.cpp +++ b/backends/cadence/hifi/operators/tests/test_op_div.cpp @@ -27,8 +27,6 @@ namespace { using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::testing::TensorFactory; -using std::optional; -using std::string_view; class HiFiDivTest : public OperatorTest { public: @@ -36,7 +34,7 @@ class HiFiDivTest : public OperatorTest { Tensor& div_out_mode( const Tensor& a, const Tensor& b, - optional mode, + std::optional mode, Tensor& out) { return ::impl::HiFi::native::div_out_mode(context_, a, b, mode, out); } diff --git a/backends/cadence/vision/operators/op_quantized_fully_connected_out.cpp b/backends/cadence/vision/operators/op_quantized_fully_connected_out.cpp index c53f7f7667a..098fb07841f 100644 --- a/backends/cadence/vision/operators/op_quantized_fully_connected_out.cpp +++ b/backends/cadence/vision/operators/op_quantized_fully_connected_out.cpp @@ -16,7 +16,6 @@ namespace native { using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; -using std::optional; void quantized_fully_connected_out( __ET_UNUSED KernelRuntimeContext& ctx, @@ -28,7 +27,7 @@ void quantized_fully_connected_out( const Tensor& out_multiplier, const Tensor& out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { #define typed_quantized_linear(ctype, dtype) \ case ScalarType::dtype: { \ @@ -65,7 +64,7 @@ void quantized_fully_connected_per_tensor_out( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - __ET_UNUSED const optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { #define typed_quantized_linear(ctype, dtype) \ case ScalarType::dtype: { \ diff --git a/devtools/etdump/etdump_filter.h b/devtools/etdump/etdump_filter.h index 64ea09f8bd3..20d2cf90f84 100644 --- a/devtools/etdump/etdump_filter.h +++ b/devtools/etdump/etdump_filter.h @@ -18,7 +18,6 @@ namespace executorch::etdump { using ::executorch::runtime::Result; -using std::string_view; /** * ETDumpFilter is a class that filters intermediate output based on output's @@ -46,7 +45,7 @@ class ETDumpFilter : public ::executorch::runtime::EventTracerFilterBase { * - An error code if number of pattern has reached to cap, or any * error occurs during regex compilation. */ - Result add_regex(string_view pattern); + Result add_regex(std::string_view pattern); /** * Sets the range for the delegate debug index filtering as [start, end). * Note that this function will flush the existing range. diff --git a/extension/kernel_util/test/make_boxed_from_unboxed_functor_test.cpp b/extension/kernel_util/test/make_boxed_from_unboxed_functor_test.cpp index 3bf4e65ffc6..472930dbb2d 100644 --- a/extension/kernel_util/test/make_boxed_from_unboxed_functor_test.cpp +++ b/extension/kernel_util/test/make_boxed_from_unboxed_functor_test.cpp @@ -26,7 +26,6 @@ using executorch::runtime::get_op_function_from_registry; using executorch::runtime::KernelRuntimeContext; using executorch::runtime::registry_has_op_function; using executorch::runtime::Span; -using std::optional; Tensor& my_op_out(KernelRuntimeContext& ctx, const Tensor& a, Tensor& out) { (void)ctx; @@ -55,8 +54,8 @@ add_tensor_out(KernelRuntimeContext& ctx, ArrayRef a, Tensor& out) { Tensor& add_optional_scalar_out( KernelRuntimeContext& ctx, - optional s1, - optional s2, + std::optional s1, + std::optional s2, Tensor& out) { (void)ctx; if (s1.has_value()) { @@ -70,7 +69,7 @@ Tensor& add_optional_scalar_out( Tensor& add_optional_tensor_out( KernelRuntimeContext& ctx, - ArrayRef> a, + ArrayRef> a, Tensor& out) { (void)ctx; for (int i = 0; i < a.size(); i++) { @@ -183,10 +182,10 @@ TEST_F(MakeBoxedFromUnboxedFunctorTest, UnboxOptionalArrayRef) { // prepare optional tensors. torch::executor::testing::TensorFactory tf; - optional storage[2]; + std::optional storage[2]; EValue evalues[2] = {EValue(tf.ones({5})), EValue()}; EValue* values_p[2] = {&evalues[0], &evalues[1]}; - BoxedEvalueList> a_box(values_p, storage, 2); + BoxedEvalueList> a_box(values_p, storage, 2); EValue boxed_array_ref(&a_box); // prepare out tensor. diff --git a/extension/named_data_map/merged_data_map.cpp b/extension/named_data_map/merged_data_map.cpp index d76f741fbf4..49bfc6ff64b 100644 --- a/extension/named_data_map/merged_data_map.cpp +++ b/extension/named_data_map/merged_data_map.cpp @@ -18,7 +18,6 @@ using executorch::runtime::Error; using executorch::runtime::FreeableBuffer; using executorch::runtime::Result; using executorch::runtime::Span; -using std::string_view; namespace executorch::extension { namespace ET_MERGED_DATA_MAP_NAMESPACE { @@ -57,7 +56,7 @@ namespace ET_MERGED_DATA_MAP_NAMESPACE { } ET_NODISCARD Result MergedDataMap::get_tensor_layout( - string_view key) const { + std::string_view key) const { const auto it = key_to_map_index_.find(key.data()); if (it == key_to_map_index_.end()) { ET_LOG(Debug, "Key %s not found in named data maps.", key.data()); @@ -67,7 +66,7 @@ ET_NODISCARD Result MergedDataMap::get_tensor_layout( } ET_NODISCARD -Result MergedDataMap::get_data(string_view key) const { +Result MergedDataMap::get_data(std::string_view key) const { const auto it = key_to_map_index_.find(key.data()); if (it == key_to_map_index_.end()) { ET_LOG(Debug, "Key %s not found in named data maps.", key.data()); @@ -77,7 +76,7 @@ Result MergedDataMap::get_data(string_view key) const { } ET_NODISCARD Error MergedDataMap::load_data_into( - string_view key, + std::string_view key, void* buffer, size_t size) const { const auto it = key_to_map_index_.find(key.data()); diff --git a/kernels/portable/cpu/op_argmax.cpp b/kernels/portable/cpu/op_argmax.cpp index a48c152133b..ecfcf5535df 100644 --- a/kernels/portable/cpu/op_argmax.cpp +++ b/kernels/portable/cpu/op_argmax.cpp @@ -20,12 +20,11 @@ namespace executor { namespace native { using executorch::aten::Tensor; -using std::optional; Tensor& argmax_out( KernelRuntimeContext& ctx, const Tensor& in, - optional dim, + std::optional dim, bool keepdim, Tensor& out) { (void)ctx; diff --git a/kernels/portable/cpu/op_argmin.cpp b/kernels/portable/cpu/op_argmin.cpp index 55f2f82b04b..b1f89be5588 100644 --- a/kernels/portable/cpu/op_argmin.cpp +++ b/kernels/portable/cpu/op_argmin.cpp @@ -20,12 +20,11 @@ namespace executor { namespace native { using executorch::aten::Tensor; -using std::optional; Tensor& argmin_out( KernelRuntimeContext& ctx, const Tensor& in, - optional dim, + std::optional dim, bool keepdim, Tensor& out) { (void)ctx; diff --git a/kernels/portable/cpu/op_cdist_forward.cpp b/kernels/portable/cpu/op_cdist_forward.cpp index c4a026f9e29..62151f2144d 100644 --- a/kernels/portable/cpu/op_cdist_forward.cpp +++ b/kernels/portable/cpu/op_cdist_forward.cpp @@ -16,7 +16,6 @@ namespace executor { namespace native { using executorch::aten::Tensor; -using std::optional; namespace { @@ -120,7 +119,7 @@ Tensor& _cdist_forward_out( const Tensor& x1, const Tensor& x2, double p, - optional compute_mode, + std::optional compute_mode, Tensor& out) { (void)ctx; diff --git a/kernels/portable/cpu/op_upsample_bilinear2d_aa.cpp b/kernels/portable/cpu/op_upsample_bilinear2d_aa.cpp index 143a8162c1d..e9c030439a2 100644 --- a/kernels/portable/cpu/op_upsample_bilinear2d_aa.cpp +++ b/kernels/portable/cpu/op_upsample_bilinear2d_aa.cpp @@ -17,7 +17,6 @@ namespace executor { namespace native { using executorch::aten::ArrayRef; -using std::optional; namespace { diff --git a/kernels/portable/cpu/util/test/reduce_test.cpp b/kernels/portable/cpu/util/test/reduce_test.cpp index f27b53abfa2..eeefbe57082 100644 --- a/kernels/portable/cpu/util/test/reduce_test.cpp +++ b/kernels/portable/cpu/util/test/reduce_test.cpp @@ -20,12 +20,11 @@ using executorch::aten::ArrayRef; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::testing::TensorFactory; -using std::optional; using torch::executor::apply_over_dim; using torch::executor::apply_over_dim_list; using torch::executor::get_out_numel; -void _apply_over_dim(const Tensor& in, const optional& dim) { +void _apply_over_dim(const Tensor& in, const std::optional& dim) { int64_t* in_data = in.mutable_data_ptr(); for (size_t out_ix = 0; out_ix < get_out_numel(in, dim); ++out_ix) { apply_over_dim( @@ -38,7 +37,7 @@ void _apply_over_dim(const Tensor& in, const optional& dim) { void _apply_over_dim_list( const Tensor& in, - const optional>& dim_list) { + const std::optional>& dim_list) { int64_t* in_data = in.mutable_data_ptr(); for (size_t out_ix = 0; out_ix < get_out_numel(in, dim_list); ++out_ix) { apply_over_dim_list( @@ -118,7 +117,7 @@ TEST(ReduceUtilTest, ApplyOverDim) { TEST(ReduceUtilTest, ApplyOverDimListNull) { TensorFactory tf; - optional> null_dim_list; + std::optional> null_dim_list; Tensor in = tf.ones({2, 4, 5, 3}); _apply_over_dim_list(in, null_dim_list); @@ -127,7 +126,7 @@ TEST(ReduceUtilTest, ApplyOverDimListNull) { TEST(ReduceUtilTest, ApplyOverZeroDimListEmpty) { TensorFactory tf; - optional> null_dim_list; + std::optional> null_dim_list; Tensor in = tf.ones({}); _apply_over_dim_list(in, null_dim_list); @@ -136,9 +135,10 @@ TEST(ReduceUtilTest, ApplyOverZeroDimListEmpty) { TEST(ReduceUtilTest, ApplyOverZeroDim) { TensorFactory tf; - optional> dim_list; + std::optional> dim_list; int64_t dim_array_0[1] = {0}; - dim_list = optional>(ArrayRef{dim_array_0, 1}); + dim_list = + std::optional>(ArrayRef{dim_array_0, 1}); Tensor in = tf.ones({}); _apply_over_dim_list(in, dim_list); @@ -147,7 +147,7 @@ TEST(ReduceUtilTest, ApplyOverZeroDim) { TEST(ReduceUtilTest, ApplyOverDimListEmpty) { TensorFactory tf; - optional> empty_dim_list{ArrayRef{}}; + std::optional> empty_dim_list{ArrayRef{}}; Tensor in = tf.ones({2, 4, 5, 3}); _apply_over_dim_list(in, empty_dim_list); @@ -156,11 +156,12 @@ TEST(ReduceUtilTest, ApplyOverDimListEmpty) { TEST(ReduceUtilTest, ApplyOverDimListLength1) { TensorFactory tf; - optional> dim_list; + std::optional> dim_list; Tensor in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_0[1] = {0}; - dim_list = optional>(ArrayRef{dim_array_0, 1}); + dim_list = + std::optional>(ArrayRef{dim_array_0, 1}); _apply_over_dim_list(in, dim_list); // clang-format off EXPECT_TENSOR_EQ(in, tf.make({2, 4, 5, 3}, { @@ -178,7 +179,8 @@ TEST(ReduceUtilTest, ApplyOverDimListLength1) { in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_1[1] = {1}; - dim_list = optional>(ArrayRef{dim_array_1, 1}); + dim_list = + std::optional>(ArrayRef{dim_array_1, 1}); _apply_over_dim_list(in, dim_list); // clang-format off EXPECT_TENSOR_EQ(in, tf.make({2, 4, 5, 3}, { @@ -196,7 +198,8 @@ TEST(ReduceUtilTest, ApplyOverDimListLength1) { in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_2[1] = {2}; - dim_list = optional>(ArrayRef{dim_array_2, 1}); + dim_list = + std::optional>(ArrayRef{dim_array_2, 1}); _apply_over_dim_list(in, dim_list); // clang-format off EXPECT_TENSOR_EQ(in, tf.make({2, 4, 5, 3}, { @@ -214,7 +217,8 @@ TEST(ReduceUtilTest, ApplyOverDimListLength1) { in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_3[1] = {3}; - dim_list = optional>(ArrayRef{dim_array_3, 1}); + dim_list = + std::optional>(ArrayRef{dim_array_3, 1}); _apply_over_dim_list(in, dim_list); // clang-format off EXPECT_TENSOR_EQ(in, tf.make({2, 4, 5, 3}, { @@ -233,11 +237,12 @@ TEST(ReduceUtilTest, ApplyOverDimListLength1) { TEST(ReduceUtilTest, ApplyOverDimListLength2) { TensorFactory tf; - optional> dim_list; + std::optional> dim_list; Tensor in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_01[2] = {0, 1}; - dim_list = optional>(ArrayRef{dim_array_01, 2}); + dim_list = + std::optional>(ArrayRef{dim_array_01, 2}); _apply_over_dim_list(in, dim_list); // clang-format off EXPECT_TENSOR_EQ(in, tf.make({2, 4, 5, 3}, { @@ -255,7 +260,8 @@ TEST(ReduceUtilTest, ApplyOverDimListLength2) { in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_02[2] = {0, 2}; - dim_list = optional>(ArrayRef{dim_array_02, 2}); + dim_list = + std::optional>(ArrayRef{dim_array_02, 2}); _apply_over_dim_list(in, dim_list); // clang-format off EXPECT_TENSOR_EQ(in, tf.make({2, 4, 5, 3}, { @@ -273,7 +279,8 @@ TEST(ReduceUtilTest, ApplyOverDimListLength2) { in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_03[2] = {0, 3}; - dim_list = optional>(ArrayRef{dim_array_03, 2}); + dim_list = + std::optional>(ArrayRef{dim_array_03, 2}); _apply_over_dim_list(in, dim_list); // clang-format off EXPECT_TENSOR_EQ(in, tf.make({2, 4, 5, 3}, { @@ -291,7 +298,8 @@ TEST(ReduceUtilTest, ApplyOverDimListLength2) { in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_12[2] = {1, 2}; - dim_list = optional>(ArrayRef{dim_array_12, 2}); + dim_list = + std::optional>(ArrayRef{dim_array_12, 2}); _apply_over_dim_list(in, dim_list); // clang-format off EXPECT_TENSOR_EQ(in, tf.make({2, 4, 5, 3}, { @@ -309,7 +317,8 @@ TEST(ReduceUtilTest, ApplyOverDimListLength2) { in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_13[2] = {1, 3}; - dim_list = optional>(ArrayRef{dim_array_13, 2}); + dim_list = + std::optional>(ArrayRef{dim_array_13, 2}); _apply_over_dim_list(in, dim_list); // clang-format off EXPECT_TENSOR_EQ(in, tf.make({2, 4, 5, 3}, { @@ -327,7 +336,8 @@ TEST(ReduceUtilTest, ApplyOverDimListLength2) { in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_23[2] = {2, 3}; - dim_list = optional>(ArrayRef{dim_array_23, 2}); + dim_list = + std::optional>(ArrayRef{dim_array_23, 2}); _apply_over_dim_list(in, dim_list); // clang-format off EXPECT_TENSOR_EQ(in, tf.make({2, 4, 5, 3}, { @@ -346,11 +356,12 @@ TEST(ReduceUtilTest, ApplyOverDimListLength2) { TEST(ReduceUtilTest, ApplyOverDimListLength3) { TensorFactory tf; - optional> dim_list; + std::optional> dim_list; Tensor in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_012[3] = {0, 1, 2}; - dim_list = optional>(ArrayRef{dim_array_012, 3}); + dim_list = + std::optional>(ArrayRef{dim_array_012, 3}); _apply_over_dim_list(in, dim_list); // clang-format off EXPECT_TENSOR_EQ(in, tf.make({2, 4, 5, 3}, { @@ -368,7 +379,8 @@ TEST(ReduceUtilTest, ApplyOverDimListLength3) { in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_013[3] = {0, 1, 3}; - dim_list = optional>(ArrayRef{dim_array_013, 3}); + dim_list = + std::optional>(ArrayRef{dim_array_013, 3}); _apply_over_dim_list(in, dim_list); // clang-format off EXPECT_TENSOR_EQ(in, tf.make({2, 4, 5, 3}, { @@ -386,7 +398,8 @@ TEST(ReduceUtilTest, ApplyOverDimListLength3) { in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_023[3] = {0, 2, 3}; - dim_list = optional>(ArrayRef{dim_array_023, 3}); + dim_list = + std::optional>(ArrayRef{dim_array_023, 3}); _apply_over_dim_list(in, dim_list); // clang-format off EXPECT_TENSOR_EQ(in, tf.make({2, 4, 5, 3}, { @@ -404,7 +417,8 @@ TEST(ReduceUtilTest, ApplyOverDimListLength3) { in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_123[3] = {1, 2, 3}; - dim_list = optional>(ArrayRef{dim_array_123, 3}); + dim_list = + std::optional>(ArrayRef{dim_array_123, 3}); _apply_over_dim_list(in, dim_list); // clang-format off EXPECT_TENSOR_EQ(in, tf.make({2, 4, 5, 3}, { @@ -423,11 +437,12 @@ TEST(ReduceUtilTest, ApplyOverDimListLength3) { TEST(ReduceUtilTest, ApplyOverDimListLength4) { TensorFactory tf; - optional> dim_list; + std::optional> dim_list; Tensor in = tf.ones({2, 4, 5, 3}); int64_t dim_array_0123[4] = {0, 1, 2, 3}; - dim_list = optional>(ArrayRef{dim_array_0123, 4}); + dim_list = + std::optional>(ArrayRef{dim_array_0123, 4}); _apply_over_dim_list(in, dim_list); EXPECT_TENSOR_EQ(in, tf.zeros({2, 4, 5, 3})); } @@ -442,7 +457,7 @@ TEST(ReduceUtilTest, ApplyOnZeroDimTensorOverDim) { TEST(ReduceUtilTest, ApplyOnZeroDimTensorOverDimListNull) { TensorFactory tf; - optional> null_dim_list; + std::optional> null_dim_list; Tensor in = tf.ones({}); _apply_over_dim_list(in, null_dim_list); @@ -451,7 +466,7 @@ TEST(ReduceUtilTest, ApplyOnZeroDimTensorOverDimListNull) { TEST(ReduceUtilTest, ApplyOnZeroDimTensorOverDimListEmpty) { TensorFactory tf; - optional> empty_dim_list{ArrayRef{}}; + std::optional> empty_dim_list{ArrayRef{}}; Tensor in = tf.ones({}); _apply_over_dim_list(in, empty_dim_list); @@ -461,8 +476,8 @@ TEST(ReduceUtilTest, ApplyOnZeroDimTensorOverDimListEmpty) { TEST(ReduceUtilTest, ApplyOnZeroDimTensorOverDimListNonEmpty) { TensorFactory tf; int64_t dim_array_0[1] = {0}; - optional> dim_list = - optional>(ArrayRef{dim_array_0, 1}); + std::optional> dim_list = + std::optional>(ArrayRef{dim_array_0, 1}); Tensor in = tf.ones({}); _apply_over_dim_list(in, dim_list); @@ -471,7 +486,7 @@ TEST(ReduceUtilTest, ApplyOnZeroDimTensorOverDimListNonEmpty) { TEST(ReduceUtilTest, ApplyOnEmptyTensorOverDim) { TensorFactory tf; - optional> dim_list; + std::optional> dim_list; Tensor in = tf.zeros({2, 0, 5, 3}); Tensor out = tf.zeros({2, 5, 3}); @@ -508,14 +523,15 @@ TEST(ReduceUtilTest, ApplyOnEmptyTensorOverDim) { TEST(ReduceUtilTest, ApplyOnEmptyTensorOverDimList) { TensorFactory tf; - optional> dim_list; + std::optional> dim_list; Tensor in = tf.zeros({2, 0, 5, 3}); Tensor out = tf.zeros({5, 3}); // dim list = {0, 1} int64_t dim_array_01[2] = {0, 1}; - dim_list = optional>(ArrayRef{dim_array_01, 2}); + dim_list = + std::optional>(ArrayRef{dim_array_01, 2}); EXPECT_TRUE(in.numel() == 0); EXPECT_TRUE(out.numel() == 15 && out.numel() == get_out_numel(in, dim_list)); @@ -537,7 +553,8 @@ TEST(ReduceUtilTest, ApplyOnEmptyTensorOverDimList) { // dim list = {0, 2} int64_t dim_array_02[2] = {0, 2}; - dim_list = optional>(ArrayRef{dim_array_02, 2}); + dim_list = + std::optional>(ArrayRef{dim_array_02, 2}); EXPECT_TRUE(in.numel() == 0); EXPECT_TRUE(get_out_numel(in, dim_list) == 0); @@ -549,29 +566,33 @@ TEST(ReduceUtilTest, ApplyOnEmptyTensorOverDimList) { TEST(ReduceUtilTest, ApplyOverDimListInvalid) { TensorFactory tf; - optional> dim_list; + std::optional> dim_list; Tensor in = tf.zeros({2, 4, 5, 3}); int64_t dim_array_09[2] = {0, 9}; - dim_list = optional>(ArrayRef{dim_array_09, 2}); + dim_list = + std::optional>(ArrayRef{dim_array_09, 2}); ET_EXPECT_DEATH( apply_over_dim_list([](size_t in_ix) { return; }, in, dim_list, 0), ""); int64_t dim_array_neg[3] = {0, -5, 3}; - dim_list = optional>(ArrayRef{dim_array_neg, 3}); + dim_list = + std::optional>(ArrayRef{dim_array_neg, 3}); ET_EXPECT_DEATH( apply_over_dim_list([](size_t in_ix) { return; }, in, dim_list, 0), ""); int64_t dim_array_011[3] = {0, 1, 1}; - dim_list = optional>(ArrayRef{dim_array_011, 3}); + dim_list = + std::optional>(ArrayRef{dim_array_011, 3}); ET_EXPECT_DEATH( apply_over_dim_list([](size_t in_ix) { return; }, in, dim_list, 0), ""); int64_t dim_array_1_3[2] = {1, -3}; - dim_list = optional>(ArrayRef{dim_array_1_3, 2}); + dim_list = + std::optional>(ArrayRef{dim_array_1_3, 2}); ET_EXPECT_DEATH( apply_over_dim_list([](size_t in_ix) { return; }, in, dim_list, 0), ""); diff --git a/kernels/quantized/test/op_add_test.cpp b/kernels/quantized/test/op_add_test.cpp index cd650de38c7..71c935b12f4 100644 --- a/kernels/quantized/test/op_add_test.cpp +++ b/kernels/quantized/test/op_add_test.cpp @@ -22,7 +22,6 @@ using namespace ::testing; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::ET_RUNTIME_NAMESPACE::KernelRuntimeContext; -using std::optional; using torch::executor::native::add_out; using torch::executor::native::dequantize_per_tensor_out; using torch::executor::native::quantize_per_tensor_out; @@ -189,7 +188,7 @@ TEST(OpQuantizeAddTest, ConsitencyWithReferencePattern) { Tensor qinput2 = tfo.zeros({3, 5}); Tensor qoutput = tfo.zeros({3, 5}); - optional out_dtype = optional(); + std::optional out_dtype = std::optional(); KernelRuntimeContext context{}; // q -> qadd -> dq diff --git a/kernels/quantized/test/op_dequantize_test.cpp b/kernels/quantized/test/op_dequantize_test.cpp index 407e04d9ff8..29676a1b85e 100644 --- a/kernels/quantized/test/op_dequantize_test.cpp +++ b/kernels/quantized/test/op_dequantize_test.cpp @@ -20,7 +20,6 @@ using namespace ::testing; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::native::dequantize_per_channel_out; using torch::executor::native::dequantize_per_tensor_out; using torch::executor::native::dequantize_per_tensor_tensor_args_out; @@ -49,7 +48,7 @@ void test_dtype() { quant_min, quant_max, DTYPE, - optional(), + std::optional(), out); EXPECT_TENSOR_EQ(out, expected); @@ -87,7 +86,7 @@ void test_output_dtype() { quant_min, quant_max, ScalarType::Byte, - optional(OUT_DTYPE), + std::optional(OUT_DTYPE), out); EXPECT_TENSOR_EQ(out, expected); @@ -120,7 +119,7 @@ TEST(OpDequantizeOutTest, HalfOutput) { quant_min, quant_max, ScalarType::Byte, - optional(ScalarType::Half), + std::optional(ScalarType::Half), out); // The expected result should be (10 - 100000) * 0.5 = -49995 @@ -147,7 +146,7 @@ TEST(OpDequantizeOutTest, DoubleOutput) { quant_min, quant_max, ScalarType::Byte, - optional(ScalarType::Double), + std::optional(ScalarType::Double), out); // The expected result should be (10 - 100000) * 0.5 = -49995 @@ -176,7 +175,7 @@ TEST(OpDequantizeOutTest, NonWholeNumbers) { quant_min, quant_max, ScalarType::Byte, - optional(), + std::optional(), out); EXPECT_TENSOR_EQ(out, expected); @@ -205,7 +204,7 @@ TEST(OpDequantizeOutTest, TensorArgOverload) { quant_min, quant_max, ScalarType::Byte, - optional(), + std::optional(), out); EXPECT_TENSOR_EQ(out, expected); @@ -236,7 +235,7 @@ void test_per_channel_dtype() { quant_min, quant_max, DTYPE, - optional(), + std::optional(), out); EXPECT_TENSOR_EQ(out, expected); @@ -257,7 +256,7 @@ void test_per_channel_dtype() { quant_min, quant_max, DTYPE, - optional(), + std::optional(), out); EXPECT_TENSOR_EQ(out, expected); @@ -279,7 +278,7 @@ void test_per_channel_dtype() { quant_min, quant_max, DTYPE, - optional(), + std::optional(), out); EXPECT_TENSOR_EQ(out, expected); @@ -306,7 +305,7 @@ void test_per_channel_dtype() { quant_min, quant_max, DTYPE, - optional(), + std::optional(), out); EXPECT_TENSOR_EQ(out, expected); diff --git a/kernels/quantized/test/op_embedding_test.cpp b/kernels/quantized/test/op_embedding_test.cpp index ad27daf866e..45dfee572e8 100644 --- a/kernels/quantized/test/op_embedding_test.cpp +++ b/kernels/quantized/test/op_embedding_test.cpp @@ -22,7 +22,6 @@ using namespace ::testing; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::ET_RUNTIME_NAMESPACE::KernelRuntimeContext; -using std::optional; using torch::executor::native::dequantize_per_tensor_out; using torch::executor::native::embedding_out; using torch::executor::native::quantize_per_tensor_out; @@ -149,7 +148,7 @@ TEST(OpQuantizedEmbeddingTest, ConsitencyWithReferencePattern) { quant_min, quant_max, ScalarType::Byte, - optional(), + std::optional(), weight); embedding_out( diff --git a/kernels/quantized/test/op_mixed_linear_test.cpp b/kernels/quantized/test/op_mixed_linear_test.cpp index e659b41151e..e7dafec3e31 100644 --- a/kernels/quantized/test/op_mixed_linear_test.cpp +++ b/kernels/quantized/test/op_mixed_linear_test.cpp @@ -20,7 +20,6 @@ using namespace ::testing; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::ET_RUNTIME_NAMESPACE::KernelRuntimeContext; -using std::optional; using torch::executor::native::quantized_mixed_linear_out; using torch::executor::testing::TensorFactory; @@ -48,8 +47,8 @@ void test_dtype() { Tensor weight_scales = tf.make( /*sizes=*/{2}, /*data=*/{0.2, 0.4}); - const optional opt_weight_zp{}; - const optional opt_dtype_out{}; + const std::optional opt_weight_zp{}; + const std::optional opt_dtype_out{}; Tensor out = tf_out.zeros({1, 2}); @@ -101,8 +100,8 @@ void test_dtype_partials() { Tensor weight_scales = tf.make( /*sizes=*/{2, 2}, /*data=*/{0.2, 1, 0.4, 0.5}); - const optional opt_weight_zp{}; - const optional opt_dtype_out{}; + const std::optional opt_weight_zp{}; + const std::optional opt_dtype_out{}; Tensor out = tf_out.zeros({1, 2}); diff --git a/kernels/quantized/test/op_mixed_mm_test.cpp b/kernels/quantized/test/op_mixed_mm_test.cpp index 8051f299fbd..5382c427871 100644 --- a/kernels/quantized/test/op_mixed_mm_test.cpp +++ b/kernels/quantized/test/op_mixed_mm_test.cpp @@ -20,7 +20,6 @@ using namespace ::testing; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::ET_RUNTIME_NAMESPACE::KernelRuntimeContext; -using std::optional; using torch::executor::native::quantized_mixed_mm_out; using torch::executor::testing::TensorFactory; @@ -47,7 +46,7 @@ void test_dtype() { Tensor weight_scales = tf.make( /*sizes=*/{3}, /*data=*/{0.2, 0.4, 0.5}); - const optional opt_weight_zp{}; + const std::optional opt_weight_zp{}; Tensor out = tf.zeros({1, 2}); diff --git a/kernels/test/op__to_dim_order_copy_test.cpp b/kernels/test/op__to_dim_order_copy_test.cpp index 2d562defce7..caa788a9187 100644 --- a/kernels/test/op__to_dim_order_copy_test.cpp +++ b/kernels/test/op__to_dim_order_copy_test.cpp @@ -25,7 +25,6 @@ using namespace ::testing; using executorch::aten::ArrayRef; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; // To further emphasize the accuracy of our op_to, we TEST_F the conversion @@ -203,7 +202,7 @@ class OpToDimOrderCopyTest : public OperatorTest { op = "op__to_dim_order_copy_out" opt_setup_params = """ bool non_blocking = false; - optional memory_format; + std::optional memory_format; """ opt_extra_params = "non_blocking, memory_format," out_args = "out_shape, dynamism" diff --git a/kernels/test/op_any_test.cpp b/kernels/test/op_any_test.cpp index cb831bffa8a..99a4fe6f1cc 100644 --- a/kernels/test/op_any_test.cpp +++ b/kernels/test/op_any_test.cpp @@ -21,7 +21,6 @@ using namespace ::testing; using executorch::aten::ArrayRef; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; class OpAnyOutTest : public OperatorTest { @@ -32,7 +31,7 @@ class OpAnyOutTest : public OperatorTest { Tensor& op_any_dims_out( const Tensor& input, - optional> dim, + std::optional> dim, bool keepdim, Tensor& out) { return torch::executor::aten::any_outf(context_, input, dim, keepdim, out); @@ -130,7 +129,7 @@ TEST_F(OpAnyOutTest, SmokeTestDims) { Tensor self = tfBool.make({2, 3, 1}, {true, false, true, true, false, false}); int64_t dims[3] = {0, 2}; - optional> opt_dim_list{ArrayRef{dims, 2}}; + std::optional> opt_dim_list{ArrayRef{dims, 2}}; bool keepdim = true; Tensor out = tfBool.zeros({1, 3, 1}); Tensor out_expected = tfBool.make({1, 3, 1}, {true, false, true}); @@ -155,7 +154,7 @@ TEST_F(OpAnyOutTest, EmptyInput) { TensorFactory tfBool; Tensor x = tf.make({2, 0, 3}, {}); - optional> dim_list = ArrayRef{}; + std::optional> dim_list = ArrayRef{}; Tensor out = tfBool.make({2, 0, 3}, {}); op_any_dims_out(x, dim_list, /*keepdim=*/true, out); @@ -183,7 +182,7 @@ TEST_F(OpAnyOutTest, TestAnyDimsOutNullDimList) { TensorFactory tfBool; Tensor self = tfInt.make({2, 6}, {0, 2, 0, 3, 0, 1, 5, 0, 2, 0, 4, 0}); - optional> opt_dim_list = std::nullopt; + std::optional> opt_dim_list = std::nullopt; bool keepdim = false; Tensor out = tfBool.zeros({}); Tensor out_expected = tfBool.make({}, {true}); @@ -199,7 +198,8 @@ TEST_F(OpAnyOutTest, TestAnyDimsOutEmptyDimList) { Tensor self = tfInt.make({2, 3}, {0, 2, 0, 0, 1, 5}); int64_t dims[0] = {}; size_t dims_size = 0; - optional> opt_dim_list{ArrayRef{dims, dims_size}}; + std::optional> opt_dim_list{ + ArrayRef{dims, dims_size}}; bool keepdim = false; Tensor out = tfBool.zeros({2, 3}); Tensor out_expected = diff --git a/kernels/test/op_argmax_test.cpp b/kernels/test/op_argmax_test.cpp index 50bc10dde36..f14ee133f27 100644 --- a/kernels/test/op_argmax_test.cpp +++ b/kernels/test/op_argmax_test.cpp @@ -18,14 +18,13 @@ using namespace ::testing; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; class OpArgmaxTest : public OperatorTest { protected: Tensor& op_argmax_out( const Tensor& in, - optional dim, + std::optional dim, bool keepdim, Tensor& out) { return torch::executor::aten::argmax_outf(context_, in, dim, keepdim, out); @@ -82,7 +81,7 @@ TEST_F(OpArgmaxTest, SanityCheckNullDim) { Tensor out = tf.zeros({}); Tensor expected = tf.make({}, {0}); - optional dim; + std::optional dim; Tensor ret = op_argmax_out(in, dim, false, out); EXPECT_TENSOR_EQ(out, ret); diff --git a/kernels/test/op_argmin_test.cpp b/kernels/test/op_argmin_test.cpp index c9e1c17c01e..4a0f49a82f5 100644 --- a/kernels/test/op_argmin_test.cpp +++ b/kernels/test/op_argmin_test.cpp @@ -18,14 +18,13 @@ using namespace ::testing; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; class OpArgminTest : public OperatorTest { protected: Tensor& op_argmin_out( const Tensor& in, - optional dim, + std::optional dim, bool keepdim, Tensor& out) { return torch::executor::aten::argmin_outf(context_, in, dim, keepdim, out); @@ -82,7 +81,7 @@ TEST_F(OpArgminTest, SanityCheckNullDim) { Tensor out = tf.zeros({}); Tensor expected = tf.make({}, {2}); - optional dim; + std::optional dim; Tensor ret = op_argmin_out(in, dim, false, out); EXPECT_TENSOR_EQ(out, ret); diff --git a/kernels/test/op_as_strided_copy_test.cpp b/kernels/test/op_as_strided_copy_test.cpp index fbae3c7acd4..4449009a3d5 100644 --- a/kernels/test/op_as_strided_copy_test.cpp +++ b/kernels/test/op_as_strided_copy_test.cpp @@ -22,7 +22,6 @@ using namespace ::testing; using executorch::aten::ArrayRef; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; class OpAsStridedCopyOutTest : public OperatorTest { @@ -31,7 +30,7 @@ class OpAsStridedCopyOutTest : public OperatorTest { const Tensor& self, ArrayRef size, ArrayRef stride, - optional storage_offset, + std::optional storage_offset, Tensor& out) { return torch::executor::aten::as_strided_copy_outf( context_, self, size, stride, storage_offset, out); @@ -48,7 +47,7 @@ class OpAsStridedCopyOutTest : public OperatorTest { Tensor out = tf.zeros(out_sizes); // Valid input should give the expected output - optional storage_offset; + std::optional storage_offset; int64_t sizes[3] = {2, 2, 2}; int64_t stride[3] = {1, 2, 3}; op_as_strided_copy_out( @@ -78,7 +77,7 @@ class OpAsStridedCopyOutTest : public OperatorTest { Tensor in = tf.ones(in_sizes); Tensor out = tf.zeros(out_sizes); - optional storage_offset; + std::optional storage_offset; int64_t sizes[3] = {2, 2, 2}; int64_t stride[3] = {1, 2, 3}; @@ -149,7 +148,7 @@ void OpAsStridedCopyOutTest::test_detach_copy_out() { Tensor out = tf.zeros(out_sizes); // Valid input should give the expected output - optional storage_offset = 2; + std::optional storage_offset = 2; int64_t sizes[3] = {2, 2, 2}; int64_t stride[3] = {1, 2, 3}; op_as_strided_copy_out( @@ -174,7 +173,7 @@ void OpAsStridedCopyOutTest::test_detach_copy_out() { Tensor out = tf.zeros(out_sizes); // Valid input should give the expected output - optional storage_offset = 2; + std::optional storage_offset = 2; int64_t sizes[3] = {2, 2, 2}; int64_t stride[3] = {1, 2, 3}; op_as_strided_copy_out( @@ -214,7 +213,7 @@ TEST_F(OpAsStridedCopyOutTest, MismatchedInputDtypesDies) { Tensor in = tf_byte.make(in_sizes, {1, 2, 3, 4, 5, 6, 7, 8, 9}); Tensor out = tf_char.zeros(out_sizes); - optional storage_offset; + std::optional storage_offset; int64_t sizes[3] = {2, 2, 2}; int64_t stride[3] = {1, 2, 3}; @@ -237,7 +236,7 @@ op = "op_as_strided_copy_out" opt_setup_params = f""" {declare_array_ref([2, 2, 2], "int64_t", "size")} {declare_array_ref([1, 2, 3], "int64_t", "stride")} - optional storage_offset; + std::optional storage_offset; """ opt_extra_params = "size, stride, storage_offset," dtype = "ScalarType::Float" @@ -276,7 +275,7 @@ TEST_F(OpAsStridedCopyOutTest, DynamicShapeUpperBoundSameAsExpected) { ArrayRef size(sizev.data(), sizev.size()); std::vector stridev = {1, 2, 3}; ArrayRef stride(stridev.data(), stridev.size()); - optional storage_offset; + std::optional storage_offset; Tensor out = tf.zeros({2, 2, 2}, torch::executor::TensorShapeDynamism::DYNAMIC_BOUND); @@ -317,7 +316,7 @@ TEST_F(OpAsStridedCopyOutTest, DynamicShapeUpperBoundLargerThanExpected) { ArrayRef size(sizev.data(), sizev.size()); std::vector stridev = {1, 2, 3}; ArrayRef stride(stridev.data(), stridev.size()); - optional storage_offset; + std::optional storage_offset; Tensor out = tf.zeros({5, 5, 5}, torch::executor::TensorShapeDynamism::DYNAMIC_BOUND); @@ -361,7 +360,7 @@ TEST_F(OpAsStridedCopyOutTest, DynamicShapeUnbound) { ArrayRef size(sizev.data(), sizev.size()); std::vector stridev = {1, 2, 3}; ArrayRef stride(stridev.data(), stridev.size()); - optional storage_offset; + std::optional storage_offset; Tensor out = tf.zeros( {1, 1, 1}, torch::executor::TensorShapeDynamism::DYNAMIC_UNBOUND); diff --git a/kernels/test/op_cdist_forward_test.cpp b/kernels/test/op_cdist_forward_test.cpp index 6cff7ad2c5a..eb58b053f74 100644 --- a/kernels/test/op_cdist_forward_test.cpp +++ b/kernels/test/op_cdist_forward_test.cpp @@ -20,14 +20,13 @@ using namespace ::testing; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::ET_RUNTIME_NAMESPACE::KernelRuntimeContext; -using std::optional; using torch::executor::testing::TensorFactory; Tensor& op_cdist_forward_out( const Tensor& x1, const Tensor& x2, double p, - optional compute_mode, + std::optional compute_mode, Tensor& out) { KernelRuntimeContext context{}; return torch::executor::aten::_cdist_forward_outf( @@ -57,7 +56,7 @@ class OpCdistForwardOutTest : public ::testing::Test { Tensor x2 = tf.make( {1, 2, 5, 3}, {0, 1, 2, 3, 5, -3, 7, 1, 6, 2, -1, 5, 1, 1, -2, 4, 3, 2, -1, 5, 1, 1, -2, 1, 5, 4, 3, 2, -1, 5}); - optional compute_mode = optional(); + std::optional compute_mode = std::optional(); Tensor out = tf.zeros({2, 2, 4, 5}); diff --git a/kernels/test/op_clamp_test.cpp b/kernels/test/op_clamp_test.cpp index 957357e96db..bdb174ecf4c 100644 --- a/kernels/test/op_clamp_test.cpp +++ b/kernels/test/op_clamp_test.cpp @@ -26,7 +26,6 @@ using executorch::aten::nullopt; using executorch::aten::Scalar; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; using OptScalar = std::optional; @@ -44,8 +43,8 @@ class OpClampOutTest : public OperatorTest { protected: Tensor& op_clamp_out( const Tensor& self, - const optional& min, - const optional& max, + const std::optional& min, + const std::optional& max, Tensor& out) { return torch::executor::aten::clamp_outf(context_, self, min, max, out); } @@ -291,8 +290,8 @@ class OpClampTensorOutTest : public OperatorTest { protected: Tensor& op_clamp_tensor_out( const Tensor& self, - const optional& min, - const optional& max, + const std::optional& min, + const std::optional& max, Tensor& out) { executorch::ET_RUNTIME_NAMESPACE::KernelRuntimeContext context{}; return torch::executor::aten::clamp_outf(context, self, min, max, out); diff --git a/kernels/test/op_clone_test.cpp b/kernels/test/op_clone_test.cpp index aec1c473f18..42858732473 100644 --- a/kernels/test/op_clone_test.cpp +++ b/kernels/test/op_clone_test.cpp @@ -20,14 +20,13 @@ using namespace ::testing; using executorch::aten::MemoryFormat; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; class OpCloneTest : public OperatorTest { protected: Tensor& op_clone_out( const Tensor& self, - optional memory_format, + std::optional memory_format, Tensor& out) { return torch::executor::aten::clone_outf( context_, self, memory_format, out); diff --git a/kernels/test/op_convolution_test.cpp b/kernels/test/op_convolution_test.cpp index c8b885cc76a..2261bb3c5a3 100644 --- a/kernels/test/op_convolution_test.cpp +++ b/kernels/test/op_convolution_test.cpp @@ -20,7 +20,6 @@ using namespace ::testing; using executorch::aten::ArrayRef; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; class OpConvOutTest : public OperatorTest { @@ -28,7 +27,7 @@ class OpConvOutTest : public OperatorTest { Tensor& op_convolution_out( const Tensor& input, const Tensor& weight, - const optional& bias, + const std::optional& bias, ArrayRef stride, ArrayRef padding, ArrayRef dilation, @@ -114,7 +113,7 @@ class OpConvOutTest : public OperatorTest { tf.make({4, 2, 3}, {8.1, 6.6, 1.6, 4.9, 3.8, 6.6, 4.6, 2.8, 2.4, 1.3, 3.6, 3.9, 8.1, 8.4, 5.4, 5.1, 8.9, 9.9, 7.9, 1.0, 1.1, 8.2, 6.3, 7.0}); - optional bias(tf.make({4}, {1.0, 1.0, 1.0, 1.0})); + std::optional bias(tf.make({4}, {1.0, 1.0, 1.0, 1.0})); Tensor expected = tf.make( {1, 4, 2}, {172.11, 237.72, 102.24, 132.28, 248.51, 320.18, 189.38, 236.07}); @@ -206,7 +205,7 @@ TEST_F(OpConvCorrectnessTest, NonZeroPadding) { Tensor weight = tf.make( {4, 2, 3}, {8.1, 6.6, 1.6, 4.9, 3.8, 6.6, 4.6, 2.8, 2.4, 1.3, 3.6, 3.9, 8.1, 8.4, 5.4, 5.1, 8.9, 9.9, 7.9, 1.0, 1.1, 8.2, 6.3, 7.0}); - optional bias(tf.make({4}, {1.0, 1.0, 1.0, 1.0})); + std::optional bias(tf.make({4}, {1.0, 1.0, 1.0, 1.0})); Tensor expected = tf.make( {1, 4, 4}, {61.78, @@ -279,7 +278,7 @@ TEST_F(OpConvCorrectnessTest, MultipleInputBatches) { Tensor weight = tf.make( {4, 2, 3}, {1.1, 8.2, 6.3, 7.0, 6.5, 2.5, 9.2, 9.9, 8.1, 9.8, 4.8, 1.3, 2.6, 8.9, 1.1, 8.7, 2.3, 3.5, 4.2, 7.1, 5.0, 3.9, 3.3, 4.1}); - optional bias(tf.make({4}, {1.0, 1.0, 1.0, 1.0})); + std::optional bias(tf.make({4}, {1.0, 1.0, 1.0, 1.0})); Tensor expected = tf.make( {3, 4, 4}, {54.77, 168.21, 208.92, 57.93, 55.01, 241.19, 312.18, 121.3, 34.59, 143.87, 201.88, 78.29, 60.39, 154.12, 194.07, 51.73, @@ -363,7 +362,7 @@ TEST_F(OpConvCorrectnessTest, 2DSanityCheck) { 4.0, 8.3, 5.2, 4.0, 4.8, 7.6, 7.1, 5.9, 9.1, 9.6, 3.9, 6.8, 7.6, 2.5, 8.1, 7.3, 7.5, 7.5, 9.3, 5.6, 5.2, 4.7, 4.5, 8.7, 8.7, 1.3, 4.1, 4.5, 4.9, 6.5, 7.9, 4.6, 7.0, 8.0, 1.6, 3.5}); - optional bias(tf.make({2}, {1.0, 1.0})); + std::optional bias(tf.make({2}, {1.0, 1.0})); Tensor expected = tf.make( {1, 2, 4, 4}, {642.33, 714.6, 687.96, 717.12, 859.79, 939.27, 996.79, 1189.59, @@ -427,7 +426,7 @@ TEST_F(OpConvCorrectnessTest, 2DSanityCheckChannelsLast) { 4.0, 8.3, 5.2, 4.0, 4.8, 7.6, 7.1, 5.9, 9.1, 9.6, 3.9, 6.8, 7.6, 2.5, 8.1, 7.3, 7.5, 7.5, 9.3, 5.6, 5.2, 4.7, 4.5, 8.7, 8.7, 1.3, 4.1, 4.5, 4.9, 6.5, 7.9, 4.6, 7.0, 8.0, 1.6, 3.5}); - optional bias(tf.make({2}, {1.0, 1.0})); + std::optional bias(tf.make({2}, {1.0, 1.0})); Tensor expected = tf.make_channels_last( {1, 2, 4, 4}, {624.92, 656.07, 710.91, 800.45, 622.48, 596.14, 831.26, 882.43, @@ -479,7 +478,7 @@ TEST_F(OpConvCorrectnessTest, InvalidInputShape) { Tensor input = tf.ones({2, 4, 4, 5}); Tensor weight = tf.ones({8, 3, 2, 2}); - optional bias; + std::optional bias; Tensor out = tf.zeros({2, 8, 3, 4}); int64_t stride[1] = {1}; @@ -522,7 +521,7 @@ TEST_F(OpConvCorrectnessTest, TransposedDefaultParams) { Tensor input = tf.full({2, 4, 3, 2}, 2.0); Tensor weight = tf.full({4, 1, 2, 2}, 0.5); - optional bias; + std::optional bias; Tensor out = tf.full({2, 2, 4, 3}, 0.7); Tensor expected = tf.make({2, 2, 4, 3}, {2, 4, 2, 4, 8, 4, 4, 8, 4, 2, 4, 2, 2, 4, 2, 4, @@ -620,7 +619,7 @@ TEST_F(OpConvCorrectnessTest, TransposedDefaultParamsChannelsLast) { Tensor input = tf.full_channels_last({2, 4, 3, 2}, 2.0); Tensor weight = tf.full_channels_last({4, 1, 2, 2}, 0.5); - optional bias; + std::optional bias; Tensor out = tf.full_channels_last({2, 2, 4, 3}, 0.7); Tensor expected = tf.make({2, 2, 4, 3}, {2, 4, 2, 4, 8, 4, 4, 8, 4, 2, 4, 2, 2, 4, 2, 4, @@ -735,7 +734,7 @@ TEST_F(OpConvCorrectnessTest, HalfTypeSmokeTest) { auto input = tf.make({1, 2, 3}, {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}); auto weight = tf.make({2, 2, 2}, {0.5, 0.5, 0.5, 0.5, 1.0, 1.0, 1.0, 1.0}); - optional bias; + std::optional bias; auto expected = tf.make({1, 2, 2}, {6.0, 8.0, 12.0, 16.0}); auto out = tf.zeros({1, 2, 2}); @@ -763,7 +762,7 @@ TEST_F(OpConvCorrectnessTest, BFloat16TypeSmokeTest) { auto input = tf.make({1, 2, 3}, {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}); auto weight = tf.make({2, 2, 2}, {0.5, 0.5, 0.5, 0.5, 1.0, 1.0, 1.0, 1.0}); - optional bias; + std::optional bias; auto expected = tf.make({1, 2, 2}, {6.0, 8.0, 12.0, 16.0}); auto out = tf.zeros({1, 2, 2}); diff --git a/kernels/test/op_cumsum_test.cpp b/kernels/test/op_cumsum_test.cpp index 8ddc197217b..8a81ae236e3 100644 --- a/kernels/test/op_cumsum_test.cpp +++ b/kernels/test/op_cumsum_test.cpp @@ -20,7 +20,6 @@ using namespace ::testing; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; class OpCumSumOutTest : public OperatorTest { @@ -28,7 +27,7 @@ class OpCumSumOutTest : public OperatorTest { Tensor& op_cumsum_out( const Tensor& self, int64_t dim, - optional enforced_dtype, + std::optional enforced_dtype, Tensor& out) { return torch::executor::aten::cumsum_outf( context_, self, dim, enforced_dtype, out); @@ -48,7 +47,7 @@ class OpCumSumOutTest : public OperatorTest { // clang-format on Tensor out = tf_out.zeros({2, 4}); - optional enforced_dtype = OUT_DTYPE; + std::optional enforced_dtype = OUT_DTYPE; op_cumsum_out(in, /*dim=*/1, enforced_dtype, out); // clang-format off @@ -85,7 +84,7 @@ class OpCumSumOutTest : public OperatorTest { Tensor in = tf_float.make({1, 2}, {1, INFINITY}); Tensor out = tf_out.zeros({1, 2}); - optional enforced_dtype = OUT_DTYPE; + std::optional enforced_dtype = OUT_DTYPE; op_cumsum_out(in, /*dim=*/1, enforced_dtype, out); EXPECT_TENSOR_CLOSE(out, tf_out.make({1, 2}, {1, INFINITY})); @@ -115,7 +114,7 @@ TEST_F(OpCumSumOutTest, MismatchedDimensionsDies) { Tensor out = tff.zeros({1, 3}); // Dim out of bounds - optional enforced_dtype; + std::optional enforced_dtype; ET_EXPECT_KERNEL_FAILURE( context_, op_cumsum_out(in, /*dim=*/3, enforced_dtype, out)); @@ -149,7 +148,7 @@ TEST_F(OpCumSumOutTest, TypeCastCornerCases) { // Cast floating point to int Tensor in = tf_float.make({1, 2}, {1.1, 2.2}); Tensor out = tf_int.zeros({1, 2}); - optional enforced_dtype = ScalarType::Int; + std::optional enforced_dtype = ScalarType::Int; op_cumsum_out(in, /*dim=*/1, enforced_dtype, out); EXPECT_TENSOR_CLOSE(out, tf_int.make({1, 2}, {1, 3})); diff --git a/kernels/test/op_empty_test.cpp b/kernels/test/op_empty_test.cpp index e7bbf1f9dfb..c1019543d5d 100644 --- a/kernels/test/op_empty_test.cpp +++ b/kernels/test/op_empty_test.cpp @@ -22,14 +22,13 @@ using executorch::aten::IntArrayRef; using executorch::aten::MemoryFormat; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; class OpEmptyOutTest : public OperatorTest { protected: Tensor& op_empty_out( IntArrayRef size, - optional memory_format, + std::optional memory_format, Tensor& out) { return torch::executor::aten::empty_outf( context_, size, memory_format, out); @@ -40,7 +39,7 @@ class OpEmptyOutTest : public OperatorTest { TensorFactory tf; std::vector sizes(size_int32_t.begin(), size_int32_t.end()); auto aref = executorch::aten::ArrayRef(sizes.data(), sizes.size()); - optional memory_format; + std::optional memory_format; Tensor out = tf.ones(size_int32_t); op_empty_out(aref, memory_format, out); @@ -61,7 +60,7 @@ TEST_F(OpEmptyOutTest, DynamicShapeUpperBoundSameAsExpected) { int64_t sizes[2] = {3, 2}; auto sizes_aref = executorch::aten::ArrayRef(sizes); - optional memory_format; + std::optional memory_format; Tensor out = tf.ones({3, 2}, torch::executor::TensorShapeDynamism::DYNAMIC_BOUND); op_empty_out(sizes_aref, memory_format, out); @@ -72,7 +71,7 @@ TEST_F(OpEmptyOutTest, DynamicShapeUpperBoundLargerThanExpected) { int64_t sizes[2] = {3, 2}; auto sizes_aref = executorch::aten::ArrayRef(sizes); - optional memory_format; + std::optional memory_format; Tensor out = tf.ones({10, 10}, torch::executor::TensorShapeDynamism::DYNAMIC_BOUND); op_empty_out(sizes_aref, memory_format, out); @@ -86,7 +85,7 @@ TEST_F(OpEmptyOutTest, DynamicShapeUnbound) { int64_t sizes[2] = {3, 2}; auto sizes_aref = executorch::aten::ArrayRef(sizes); - optional memory_format; + std::optional memory_format; Tensor out = tf.ones({1, 1}, torch::executor::TensorShapeDynamism::DYNAMIC_UNBOUND); op_empty_out(sizes_aref, memory_format, out); diff --git a/kernels/test/op_full_like_test.cpp b/kernels/test/op_full_like_test.cpp index 4f9ab255708..d50b248cbb7 100644 --- a/kernels/test/op_full_like_test.cpp +++ b/kernels/test/op_full_like_test.cpp @@ -23,7 +23,6 @@ using executorch::aten::MemoryFormat; using executorch::aten::Scalar; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; class OpFullLikeTest : public OperatorTest { @@ -31,7 +30,7 @@ class OpFullLikeTest : public OperatorTest { Tensor& op_full_like_out( const Tensor& self, const Scalar& fill_value, - optional memory_format, + std::optional memory_format, Tensor& out) { return torch::executor::aten::full_like_outf( context_, self, fill_value, memory_format, out); @@ -74,7 +73,7 @@ class OpFullLikeTest : public OperatorTest { const std::vector sizes = {2, 2}; Tensor in = tf.zeros(sizes); Tensor out = tf.zeros(sizes); - optional memory_format; + std::optional memory_format; ET_EXPECT_KERNEL_FAILURE( context_, op_full_like_out(in, bad_value, memory_format, out)); @@ -204,7 +203,7 @@ TEST_F(OpFullLikeTest, DISABLED_DynamicShapeUnbound) { TEST_F(OpFullLikeTest, HalfSupport) { TensorFactory tf; - optional memory_format; + std::optional memory_format; Tensor in = tf.ones({2, 3}); Tensor out = tf.zeros({2, 3}); diff --git a/kernels/test/op_index_put_test.cpp b/kernels/test/op_index_put_test.cpp index 1c3ef58eb6b..a0b9ba5bb38 100644 --- a/kernels/test/op_index_put_test.cpp +++ b/kernels/test/op_index_put_test.cpp @@ -21,10 +21,9 @@ using namespace ::testing; using executorch::aten::ArrayRef; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; -using OptTensorArrayRef = ArrayRef>; +using OptTensorArrayRef = ArrayRef>; class OpIndexPutOutTest : public OperatorTest { protected: @@ -73,14 +72,14 @@ class OpIndexPutOutTest : public OperatorTest { // First, index_put to make everything equal to 1 // indices [0, 1, :], [1, 1, :], [2, 1, :] - optional indices[] = { - optional(tfl.make({1, 3}, {0, 1, 2})), - optional(tfl.make({1, 3}, {1, 1, 1})), + std::optional indices[] = { + std::optional(tfl.make({1, 3}, {0, 1, 2})), + std::optional(tfl.make({1, 3}, {1, 1, 1})), }; // bool representation of the same index list - optional indices_bool[] = { - optional(tfb.make({3}, {true, true, true})), - optional(tfb.make({2}, {false, true})), + std::optional indices_bool[] = { + std::optional(tfb.make({3}, {true, true, true})), + std::optional(tfb.make({2}, {false, true})), }; Tensor values = tf.ones({3, 4}); @@ -105,14 +104,14 @@ class OpIndexPutOutTest : public OperatorTest { // Then, index_put to make everything equal to 0 // indices [0, 1, :], [1, 0, :], [2, 0, :] - optional indices_alt[] = { - optional(tfl.make({1, 3}, {0, 1, 2})), - optional(tfl.make({1, 3}, {0, 0, 0})), + std::optional indices_alt[] = { + std::optional(tfl.make({1, 3}, {0, 1, 2})), + std::optional(tfl.make({1, 3}, {0, 0, 0})), }; // bool representation of the same index list - optional indices_alt_bool[] = { - optional(tfb.make({3}, {true, true, true})), - optional(tfb.make({2}, {true, false})), + std::optional indices_alt_bool[] = { + std::optional(tfb.make({3}, {true, true, true})), + std::optional(tfb.make({2}, {true, false})), }; Tensor values_alt = tf.zeros({3, 4}); @@ -178,10 +177,10 @@ class OpIndexPutOutTest : public OperatorTest { 0.518521785736084, 0.6976675987243652, 0.800011396408081, 0.16102945804595947, 0.28226858377456665, 0.6816085577011108, 0.9151939749717712, 0.39709991216659546, 0.8741558790206909}); - optional indices[] = { - optional(tf_indices.make({1}, {1})), - optional(tf_indices.make({1}, {0})), - optional(tf_indices.make({2}, {1, 2}))}; + std::optional indices[] = { + std::optional(tf_indices.make({1}, {1})), + std::optional(tf_indices.make({1}, {0})), + std::optional(tf_indices.make({2}, {1, 2}))}; Tensor values = tf.make({2}, {0.41940832138061523, 0.5529070496559143}); Tensor expected = tf.make( {2, 3, 4}, @@ -413,30 +412,30 @@ TEST_F(OpIndexPutOutTest, PutFrontDimAllIndexes) { // [1, 0, 1], [1, 0, 2]. This is expressed in various ways to test different // indexing expressions. - optional indices_long[] = { - optional(tfl.make({1}, {1})), - optional(tfl.make({1}, {0})), - optional(tfl.make({2}, {1, 2}))}; + std::optional indices_long[] = { + std::optional(tfl.make({1}, {1})), + std::optional(tfl.make({1}, {0})), + std::optional(tfl.make({2}, {1, 2}))}; - optional indices_int[] = { - optional(tfi.make({1}, {1})), - optional(tfi.make({1}, {0})), - optional(tfi.make({2}, {1, 2}))}; + std::optional indices_int[] = { + std::optional(tfi.make({1}, {1})), + std::optional(tfi.make({1}, {0})), + std::optional(tfi.make({2}, {1, 2}))}; - optional indices_negative[] = { - optional(tfl.make({1}, {-1})), - optional(tfl.make({1}, {0})), - optional(tfl.make({2}, {-3, -2}))}; + std::optional indices_negative[] = { + std::optional(tfl.make({1}, {-1})), + std::optional(tfl.make({1}, {0})), + std::optional(tfl.make({2}, {-3, -2}))}; - optional indices_bool[] = { - optional(tfb.make({2}, {false, true})), - optional(tfb.make({3}, {true, false, false})), - optional(tfl.make({2}, {-3, -2}))}; + std::optional indices_bool[] = { + std::optional(tfb.make({2}, {false, true})), + std::optional(tfb.make({3}, {true, false, false})), + std::optional(tfl.make({2}, {-3, -2}))}; - optional indices_mixed[] = { - optional(tfb.make({2}, {false, true})), - optional(tfl.make({1}, {0})), - optional(tfl.make({2}, {-3, -2}))}; + std::optional indices_mixed[] = { + std::optional(tfb.make({2}, {false, true})), + std::optional(tfl.make({1}, {0})), + std::optional(tfl.make({2}, {-3, -2}))}; // clang-format off Tensor values = tf.make( @@ -504,10 +503,10 @@ TEST_F(OpIndexPutOutTest, PutTwoValuesAtSameIndex) { // clang-format on // Try to select the value at the same index - optional indices[] = { - optional(tfl.make({1, 2}, {0, 0})), - optional(tfl.make({1, 2}, {1, 1})), - optional(tfl.make({1, 2}, {2, 2}))}; + std::optional indices[] = { + std::optional(tfl.make({1, 2}, {0, 0})), + std::optional(tfl.make({1, 2}, {1, 1})), + std::optional(tfl.make({1, 2}, {2, 2}))}; // clang-format off Tensor values = tf.make( @@ -576,13 +575,13 @@ TEST_F(OpIndexPutOutTest, IndicesFewerThanInputDimSupported) { // [1, 0, :], [1, 1, :]. This is expressed in various ways to test different // indexing expressions. - optional indices_long[] = { - optional(tfl.make({1}, {1})), - optional(tfl.make({2}, {0, 1}))}; + std::optional indices_long[] = { + std::optional(tfl.make({1}, {1})), + std::optional(tfl.make({2}, {0, 1}))}; - optional indices_mixed[] = { - optional(tfi.make({1}, {-1})), - optional(tfb.make({3}, {true, true, false}))}; + std::optional indices_mixed[] = { + std::optional(tfi.make({1}, {-1})), + std::optional(tfb.make({3}, {true, true, false}))}; // clang-format off Tensor values = tf.make( @@ -651,9 +650,9 @@ TEST_F(OpIndexPutOutTest, IndicesFewerThanInputDimSupportedSameValue) { // Try to select the input value at indices // [1, 0, :], [1, 1, :] - optional indices[] = { - optional(tfl.make({1}, {1})), - optional(tfl.make({2}, {0, 1}))}; + std::optional indices[] = { + std::optional(tfl.make({1}, {1})), + std::optional(tfl.make({2}, {0, 1}))}; // clang-format off Tensor values = tf.make( @@ -913,9 +912,9 @@ TEST_F(OpIndexPutOutTest, InvalidIndicesDtypeDies) { Tensor x = tf.zeros({2, 4, 7, 5}); // clang-format off - optional indices[] = { - optional(tff.make({3}, {1, 1, 1,})), - optional(tff.make({2}, {1, 2}))}; + std::optional indices[] = { + std::optional(tff.make({3}, {1, 1, 1,})), + std::optional(tff.make({2}, {1, 2}))}; // clang-format on Tensor out = tf.ones({2, 4, 7, 5}); @@ -939,9 +938,9 @@ TEST_F(OpIndexPutOutTest, InvalidIndicesShapesDies) { Tensor x = tf.zeros({2, 4, 7, 5}); // clang-format off - optional indices[] = { - optional(tfl.make({3}, {1, 1, 1,})), - optional(tfl.make({2}, {1, 2}))}; + std::optional indices[] = { + std::optional(tfl.make({3}, {1, 1, 1,})), + std::optional(tfl.make({2}, {1, 2}))}; Tensor out = tf.ones({2, 4, 7, 5}); // clang-format on @@ -965,9 +964,9 @@ TEST_F(OpIndexPutOutTest, NonLinearIndices) { Tensor x = tf.zeros({4, 4}); // clang-format off - optional indices[] = { - optional(tfl.make({2, 2}, {1, 1, 1, 1,})), - optional(tfl.make({1, 2}, {3, 0,}))}; + std::optional indices[] = { + std::optional(tfl.make({2, 2}, {1, 1, 1, 1,})), + std::optional(tfl.make({1, 2}, {3, 0,}))}; Tensor out = tf.ones({4, 4}); // clang-format on @@ -1053,9 +1052,9 @@ class OpIndexPutInplaceTest : public OperatorTest { }); // clang-format on - optional indices[] = { - optional(), - optional(tfl.make({2}, {0, 2})), + std::optional indices[] = { + std::optional(), + std::optional(tfl.make({2}, {0, 2})), }; // clang-format off diff --git a/kernels/test/op_index_test.cpp b/kernels/test/op_index_test.cpp index 48d0b0b80b1..4c8b9772ab3 100644 --- a/kernels/test/op_index_test.cpp +++ b/kernels/test/op_index_test.cpp @@ -23,10 +23,9 @@ using namespace ::testing; using executorch::aten::ArrayRef; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; -using OptTensorArrayRef = ArrayRef>; +using OptTensorArrayRef = ArrayRef>; class OpIndexTensorOutTest : public OperatorTest { protected: @@ -74,15 +73,15 @@ class OpIndexTensorOutTest : public OperatorTest { // clang-format on // indices [0, 1, 2], [1, 0, 3], expressed two different ways - std::array, 3> indices = { - optional(tfl.make({2}, {0, 1})), - optional(tfl.make({2}, {1, 0})), - optional(tfl.make({2}, {2, 3}))}; + std::array, 3> indices = { + std::optional(tfl.make({2}, {0, 1})), + std::optional(tfl.make({2}, {1, 0})), + std::optional(tfl.make({2}, {2, 3}))}; - std::array, 3> indices_mixed = { - optional(tfl.make({2}, {0, 1})), - optional(tfb.make({2}, {false, true})), - optional(tfl.make({2}, {2, 3}))}; + std::array, 3> indices_mixed = { + std::optional(tfl.make({2}, {0, 1})), + std::optional(tfb.make({2}, {false, true})), + std::optional(tfl.make({2}, {2, 3}))}; std::vector out_size{2}; @@ -121,13 +120,13 @@ class OpIndexTensorOutTest : public OperatorTest { Tensor x = tf.make({2, 3}, {1, 2, 3, 4, 5, 6}); Tensor out = tf.zeros({2, 3}); - std::array, 1> indices1 = {optional()}; + std::array, 1> indices1 = {std::optional()}; op_index_tensor_out(x, indices1, out); EXPECT_TENSOR_EQ(out, x); out = tf.zeros({2, 3}); - std::array, 2> indices2 = { - optional(), std::optional()}; + std::array, 2> indices2 = { + std::optional(), std::optional()}; op_index_tensor_out(x, indices2, out); EXPECT_TENSOR_EQ(out, x); } @@ -235,30 +234,30 @@ TEST_F(OpIndexTensorOutTest, SelectFrontDimAllIndexes) { // Try to select the input value at indices // [1, 0, 1], [1, 0, 2]. This is expressed in various ways to test different // indexing expressions. - std::array, 3> indices = { - optional(tfl.make({1}, {1})), - optional(tfl.make({1}, {0})), - optional(tfl.make({2}, {1, 2}))}; - - std::array, 3> indices_int = { - optional(tfi.make({1}, {1})), - optional(tfi.make({1}, {0})), - optional(tfi.make({2}, {1, 2}))}; - - std::array, 3> indices_negative = { - optional(tfl.make({1}, {-1})), - optional(tfl.make({1}, {0})), - optional(tfl.make({2}, {-3, -2}))}; - - std::array, 3> indices_bool = { - optional(tfb.make({2}, {false, true})), - optional(tfb.make({3}, {true, false, false})), - optional(tfl.make({2}, {-3, -2}))}; - - std::array, 3> indices_mixed = { - optional(tfb.make({2}, {false, true})), - optional(tfl.make({1}, {0})), - optional(tfl.make({2}, {-3, -2}))}; + std::array, 3> indices = { + std::optional(tfl.make({1}, {1})), + std::optional(tfl.make({1}, {0})), + std::optional(tfl.make({2}, {1, 2}))}; + + std::array, 3> indices_int = { + std::optional(tfi.make({1}, {1})), + std::optional(tfi.make({1}, {0})), + std::optional(tfi.make({2}, {1, 2}))}; + + std::array, 3> indices_negative = { + std::optional(tfl.make({1}, {-1})), + std::optional(tfl.make({1}, {0})), + std::optional(tfl.make({2}, {-3, -2}))}; + + std::array, 3> indices_bool = { + std::optional(tfb.make({2}, {false, true})), + std::optional(tfb.make({3}, {true, false, false})), + std::optional(tfl.make({2}, {-3, -2}))}; + + std::array, 3> indices_mixed = { + std::optional(tfb.make({2}, {false, true})), + std::optional(tfl.make({1}, {0})), + std::optional(tfl.make({2}, {-3, -2}))}; std::vector out_size{2}; @@ -296,10 +295,10 @@ TEST_F(OpIndexTensorOutTest, SelectTwoValuesAtSameIndex) { // clang-format on // Try to select the value at the same index - std::array, 3> indices = { - optional(tfl.make({1, 2}, {0, 0})), - optional(tfl.make({1, 2}, {1, 1})), - optional(tfl.make({1, 2}, {2, 2}))}; + std::array, 3> indices = { + std::optional(tfl.make({1, 2}, {0, 0})), + std::optional(tfl.make({1, 2}, {1, 1})), + std::optional(tfl.make({1, 2}, {2, 2}))}; std::vector out_size{1, 2}; // In ATen the size is (1, 2) @@ -338,13 +337,13 @@ TEST_F(OpIndexTensorOutTest, IndicesFewerThanInputDimSupported) { // [1, 0, :], [1, 1, :]. This is expressed in various ways to test different // indexing expressions. - std::array, 2> indices = { - optional(tfl.make({1}, {1})), - optional(tfl.make({2}, {0, 1}))}; + std::array, 2> indices = { + std::optional(tfl.make({1}, {1})), + std::optional(tfl.make({2}, {0, 1}))}; - std::array, 2> indices_mixed = { - optional(tfi.make({1}, {-1})), - optional(tfb.make({3}, {true, true, false}))}; + std::array, 2> indices_mixed = { + std::optional(tfi.make({1}, {-1})), + std::optional(tfb.make({3}, {true, true, false}))}; std::vector out_size{2, 4}; @@ -381,10 +380,10 @@ TEST_F(OpIndexTensorOutTest, IndicesWithNullTensorsSupported) { }); // clang-format on - std::array, 3> indices0 = { - optional(), - optional(tfl.make({1}, {1})), - optional(tfl.make({2}, {0, 1}))}; + std::array, 3> indices0 = { + std::optional(), + std::optional(tfl.make({1}, {1})), + std::optional(tfl.make({2}, {0, 1}))}; // clang-format off Tensor expected0 = tf.make( @@ -398,10 +397,10 @@ TEST_F(OpIndexTensorOutTest, IndicesWithNullTensorsSupported) { run_test_cases(x, /*indices=*/indices0, expected0); - std::array, 3> indices1 = { - optional(tfl.make({1}, {1})), - optional(), - optional(tfl.make({2}, {0, 1}))}; + std::array, 3> indices1 = { + std::optional(tfl.make({1}, {1})), + std::optional(), + std::optional(tfl.make({2}, {0, 1}))}; // clang-format off Tensor expected1 = tf.make( @@ -415,10 +414,10 @@ TEST_F(OpIndexTensorOutTest, IndicesWithNullTensorsSupported) { run_test_cases(x, /*indices=*/indices1, expected1); - std::array, 3> indices2 = { - optional(tfl.make({1}, {1})), - optional(tfl.make({2}, {0, 1})), - optional()}; + std::array, 3> indices2 = { + std::optional(tfl.make({1}, {1})), + std::optional(tfl.make({2}, {0, 1})), + std::optional()}; // clang-format off Tensor expected2 = tf.make( @@ -443,8 +442,10 @@ TEST_F(OpIndexTensorOutTest, IndicesWithOnlyNullTensorsSupported) { TEST_F(OpIndexTensorOutTest, TooManyNullIndices) { TensorFactory tf; Tensor x = tf.make({2, 3}, {1., 2., 3., 4., 5., 6.}); - std::array, 3> indices = { - optional(), std::optional(), std::optional()}; + std::array, 3> indices = { + std::optional(), + std::optional(), + std::optional()}; Tensor out = tf.ones({2, 3}); ET_EXPECT_KERNEL_FAILURE_WITH_MSG( context_, @@ -490,8 +491,8 @@ TEST_F(OpIndexTensorOutTest, NegativeIndexSupportedForLong) { Tensor out = tf.zeros({1}); Tensor expected = tf.make({1}, {3.}); - std::array, 1> indices = { - optional(tfl.make({1}, {-1}))}; + std::array, 1> indices = { + std::optional(tfl.make({1}, {-1}))}; Tensor ret = op_index_tensor_out(x, indices, out); EXPECT_TENSOR_EQ(ret, expected); @@ -505,8 +506,8 @@ TEST_F(OpIndexTensorOutTest, NegativeIndexSupportedForInt) { Tensor out = tf.zeros({1}); Tensor expected = tf.make({1}, {3.}); - std::array, 1> indices = { - optional(tfi.make({1}, {-1}))}; + std::array, 1> indices = { + std::optional(tfi.make({1}, {-1}))}; Tensor ret = op_index_tensor_out(x, indices, out); EXPECT_TENSOR_EQ(ret, expected); @@ -611,9 +612,9 @@ TEST_F(OpIndexTensorOutTest, InvalidIndicesShapesDies) { Tensor x = tf.zeros({2, 4, 7, 5}); // clang-format off - std::array, 2> indices = { - optional(tfl.make({3}, {1, 1, 1,})), - optional(tfl.make({2}, {1, 2}))}; + std::array, 2> indices = { + std::optional(tfl.make({3}, {1, 1, 1,})), + std::optional(tfl.make({2}, {1, 2}))}; Tensor out = tf.ones({3, 7, 5}); // clang-format on @@ -629,9 +630,9 @@ TEST_F(OpIndexTensorOutTest, InvalidIndicesShapeDies2) { Tensor x = tf.zeros({4, 4}); // clang-format off - std::array, 2> indices = { - optional(tfl.make({2, 2}, {1, 1, 1, 1,})), - optional(tfl.make({1, 2}, {3, 0,}))}; + std::array, 2> indices = { + std::optional(tfl.make({2, 2}, {1, 1, 1, 1,})), + std::optional(tfl.make({1, 2}, {3, 0,}))}; Tensor out = tf.ones({4}); // clang-format on @@ -666,10 +667,10 @@ TEST_F(OpIndexTensorOutTest, UpperBoundOutTensor) { // Try to select the tensor from the input // indices [0, 2, 2], [1, 1, 2] - std::array, 3> indices = { - optional(tfl.make({1, 2}, {0, 1})), - optional(tfl.make({1, 2}, {2, 1})), - optional(tfl.make({1, 2}, {2, 2}))}; + std::array, 3> indices = { + std::optional(tfl.make({1, 2}, {0, 1})), + std::optional(tfl.make({1, 2}, {2, 1})), + std::optional(tfl.make({1, 2}, {2, 2}))}; Tensor out = tf.zeros({5, 5}, torch::executor::TensorShapeDynamism::DYNAMIC_BOUND); @@ -711,10 +712,10 @@ TEST_F(OpIndexTensorOutTest, FastPathFirstDim) { }); // clang-format on - std::array, 3> indices = { - optional(tfl.make({3}, {1, 0, 1})), - optional(), - optional()}; + std::array, 3> indices = { + std::optional(tfl.make({3}, {1, 0, 1})), + std::optional(), + std::optional()}; Tensor out = tf.zeros({3, 3, 4}); // clang-format off @@ -763,8 +764,9 @@ TEST_F(OpIndexTensorOutTest, FastPathMiddleDim) { }); // clang-format on - std::array, 2> indices = { - optional(), optional(tfl.make({5}, {2, 0, 1, 0, 2}))}; + std::array, 2> indices = { + std::optional(), + std::optional(tfl.make({5}, {2, 0, 1, 0, 2}))}; Tensor out = tf.zeros({2, 5, 4}); // clang-format off @@ -812,10 +814,10 @@ TEST_F(OpIndexTensorOutTest, FastPathLastDim) { }); // clang-format on - std::array, 3> indices = { - optional(), - optional(), - optional(tfl.make({3}, {2, 0, 1}))}; + std::array, 3> indices = { + std::optional(), + std::optional(), + std::optional(tfl.make({3}, {2, 0, 1}))}; Tensor out = tf.zeros({2, 3, 3}); // clang-format off @@ -842,7 +844,8 @@ TEST_F(OpIndexTensorOutTest, FastPathZeroDim) { TensorFactory tfl; Tensor x = tf.ones({0}); - std::array, 1> indices = {optional(tfl.zeros({0}))}; + std::array, 1> indices = { + std::optional(tfl.zeros({0}))}; Tensor out = tf.zeros({0}); Tensor expected = tf.ones({0}); op_index_tensor_out(x, indices, out); @@ -855,8 +858,8 @@ TEST_F(OpIndexTensorOutTest, FastPath1DLessElements) { TensorFactory tfl; Tensor x = tf.make({5}, {1., 2., 3., 4., 5.}); - std::array, 1> indices = { - optional(tfl.make({3}, {2, 0, 1}))}; + std::array, 1> indices = { + std::optional(tfl.make({3}, {2, 0, 1}))}; Tensor out = tf.zeros({3}); Tensor expected = tf.make({3}, {3., 1., 2.}); op_index_tensor_out(x, indices, out); @@ -869,8 +872,8 @@ TEST_F(OpIndexTensorOutTest, FastPath1DMoreElements) { TensorFactory tfl; Tensor x = tf.make({5}, {1., 2., 3., 4., 5.}); - std::array, 1> indices = { - optional(tfl.make({7}, {2, 0, 1, 3, 3, 4, 1}))}; + std::array, 1> indices = { + std::optional(tfl.make({7}, {2, 0, 1, 3, 3, 4, 1}))}; Tensor out = tf.zeros({7}); Tensor expected = tf.make({7}, {3., 1., 2., 4., 4., 5., 2.}); op_index_tensor_out(x, indices, out); @@ -898,10 +901,10 @@ TEST_F(OpIndexTensorOutTest, FastPathUpperBoundOutTensor) { }); // clang-format on - std::array, 3> indices = { - optional(), - optional(tfl.make({5}, {2, 0, 1, 0, 2})), - optional()}; + std::array, 3> indices = { + std::optional(), + std::optional(tfl.make({5}, {2, 0, 1, 0, 2})), + std::optional()}; Tensor out = tf.zeros({5, 5, 5}, torch::executor::TensorShapeDynamism::DYNAMIC_BOUND); @@ -935,10 +938,10 @@ TEST_F(OpIndexTensorOutTest, FastPathEmptyInput) { TensorFactory tfl; Tensor x = tf.ones({2, 3, 0, 4}); - std::array, 3> indices = { - optional(), - optional(tfl.make({5}, {2, 0, 1, 0, 2})), - optional()}; + std::array, 3> indices = { + std::optional(), + std::optional(tfl.make({5}, {2, 0, 1, 0, 2})), + std::optional()}; Tensor out = tf.zeros( {5, 5, 5, 5}, torch::executor::TensorShapeDynamism::DYNAMIC_BOUND); Tensor expected = tf.ones({2, 5, 0, 4}); @@ -968,10 +971,10 @@ TEST_F(OpIndexTensorOutTest, FastPathNegativeIndex) { // clang-format on // Use negative indices in the first dimension: -1, 0, -2 - std::array, 3> indices = { - optional(tfl.make({3}, {-1, 0, -2})), - optional(), - optional()}; + std::array, 3> indices = { + std::optional(tfl.make({3}, {-1, 0, -2})), + std::optional(), + std::optional()}; Tensor out = tf.zeros({3, 3, 4}); // clang-format off diff --git a/kernels/test/op_mean_test.cpp b/kernels/test/op_mean_test.cpp index f31e098d23c..0811699d9ae 100644 --- a/kernels/test/op_mean_test.cpp +++ b/kernels/test/op_mean_test.cpp @@ -22,16 +22,16 @@ using namespace ::testing; using executorch::aten::ArrayRef; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; +using executorch::runtime::Error; using torch::executor::testing::TensorFactory; class OpMeanOutTest : public OperatorTest { protected: Tensor& op_mean_out( const Tensor& self, - optional> dim, + std::optional> dim, bool keepdim, - optional dtype, + std::optional dtype, Tensor& out) { return torch::executor::aten::mean_outf( context_, self, dim, keepdim, dtype, out); @@ -39,7 +39,7 @@ class OpMeanOutTest : public OperatorTest { Tensor& op_mean_dtype_out( const Tensor& self, - optional dtype, + std::optional dtype, Tensor& out) { return torch::executor::aten::mean_outf(context_, self, dtype, out); } @@ -63,11 +63,12 @@ class OpMeanOutTest : public OperatorTest { }); // clang-format on Tensor out = tf_out.zeros({2, 3, 1}); - optional dtype = OUT_DTYPE; + std::optional dtype = OUT_DTYPE; // out-of-bound dim in dim list int64_t dims_1[1] = {3}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; ET_EXPECT_KERNEL_FAILURE( context_, op_mean_out(self, optional_dim_list, /*keepdim=*/true, dtype, out)); @@ -101,9 +102,10 @@ class OpMeanOutTest : public OperatorTest { // dimension size mismatch when keepdim is true Tensor out = tf_out.zeros({2, 4}); - optional dtype = OUT_DTYPE; + std::optional dtype = OUT_DTYPE; int64_t dims_1[1] = {1}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; ET_EXPECT_KERNEL_FAILURE( context_, op_mean_out(self, optional_dim_list, /*keepdim=*/true, dtype, out)); @@ -136,8 +138,9 @@ class OpMeanOutTest : public OperatorTest { // keepdim=true should work Tensor out = tf_out.zeros({2, 3, 1}); int64_t dims_1[1] = {2}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; - optional dtype = OUT_DTYPE; + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; + std::optional dtype = OUT_DTYPE; op_mean_out(self, optional_dim_list, /*keepdim=*/true, dtype, out); // clang-format off EXPECT_TENSOR_CLOSE(out, tf_out.make( @@ -193,11 +196,11 @@ class OpMeanOutTest : public OperatorTest { // empty/null dim list should work out = tf_out.zeros({1, 1, 1}); - optional> null_dim_list; + std::optional> null_dim_list; op_mean_out(self, null_dim_list, /*keepdim=*/true, dtype, out); EXPECT_TENSOR_CLOSE(out, tf_out.make({1, 1, 1}, {11.5})); - optional> empty_dim_list{ArrayRef{}}; + std::optional> empty_dim_list{ArrayRef{}}; op_mean_out(self, empty_dim_list, /*keepdim=*/true, dtype, out); EXPECT_TENSOR_CLOSE(out, tf_out.make({1, 1, 1}, {11.5})); @@ -229,8 +232,9 @@ class OpMeanOutTest : public OperatorTest { Tensor out = tf_float.zeros({1, 1, 4}); int64_t dims[2] = {0, 1}; - optional> optional_dim_list{ArrayRef{dims, 2}}; - optional dtype = OUT_DTYPE; + std::optional> optional_dim_list{ + ArrayRef{dims, 2}}; + std::optional dtype = OUT_DTYPE; op_mean_out(self, optional_dim_list, /*keepdim=*/true, dtype, out); EXPECT_TENSOR_CLOSE( out, @@ -351,8 +355,9 @@ TEST_F(OpMeanOutTest, MismatchedDTypesDies) { // keepdim=true should work Tensor out = tf_float.zeros({2, 3, 1}); int64_t dims_1[1] = {2}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; - optional dtype; + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; + std::optional dtype; // self tensor must have a floating point dtype when dtype is not specified ET_EXPECT_KERNEL_FAILURE( @@ -412,8 +417,9 @@ TEST_F(OpMeanOutTest, InfinityAndNANTest) { Tensor out = tf_float.zeros({2, 3, 1}); int64_t dims[1] = {-1}; - optional> optional_dim_list{ArrayRef{dims, 1}}; - optional dtype; + std::optional> optional_dim_list{ + ArrayRef{dims, 1}}; + std::optional dtype; op_mean_out(self, optional_dim_list, /*keepdim=*/true, dtype, out); // clang-format off EXPECT_TENSOR_CLOSE(out, tf_float.make( @@ -585,8 +591,8 @@ TEST_F(OpMeanOutTest, EmptyInput) { TensorFactory tf; Tensor x = tf.make({2, 0, 3}, {}); - optional dtype = ScalarType::Float; - optional> dim_list = ArrayRef{}; + std::optional dtype = ScalarType::Float; + std::optional> dim_list = ArrayRef{}; Tensor out = tf.zeros({1, 1, 1}); op_mean_out(x, dim_list, /*keepdim=*/true, dtype, out); EXPECT_TENSOR_CLOSE(out, tf.make({1, 1, 1}, {NAN})); diff --git a/kernels/test/op_native_group_norm_test.cpp b/kernels/test/op_native_group_norm_test.cpp index 2280adf64ee..1aec95a21f8 100644 --- a/kernels/test/op_native_group_norm_test.cpp +++ b/kernels/test/op_native_group_norm_test.cpp @@ -17,15 +17,14 @@ using namespace ::testing; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; class OpNativeGroupNormTest : public OperatorTest { protected: ::std::tuple op_native_group_norm_out( const Tensor& input, - const optional& weight, - const optional& bias, + const std::optional& weight, + const std::optional& bias, int64_t N, int64_t C, int64_t HxW, @@ -74,9 +73,9 @@ class OpNativeGroupNormTest : public OperatorTest { TensorFactory tf; for (const auto& test_case : test_cases) { Tensor in = tf.make(test_case.sizes, test_case.input_data); - optional weight = + std::optional weight = tf.make({static_cast(test_case.C)}, test_case.weight_data); - optional bias = + std::optional bias = tf.make({static_cast(test_case.C)}, test_case.bias_data); Tensor out0 = tf.zeros(test_case.sizes); Tensor out1 = tf.zeros( diff --git a/kernels/test/op_native_layer_norm_test.cpp b/kernels/test/op_native_layer_norm_test.cpp index e1345a10354..5abeafa3d9a 100644 --- a/kernels/test/op_native_layer_norm_test.cpp +++ b/kernels/test/op_native_layer_norm_test.cpp @@ -26,7 +26,6 @@ using executorch::aten::IntArrayRef; using executorch::aten::Scalar; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; using OptScalar = std::optional; @@ -36,8 +35,8 @@ class OpNativeLayerNormTest : public OperatorTest { ::std::tuple op_native_layer_norm_out( const Tensor& input, IntArrayRef normalized_shape, - const optional& weight, - const optional& bias, + const std::optional& weight, + const std::optional& bias, double eps, Tensor& out0, Tensor& out1, @@ -383,8 +382,8 @@ class OpNativeLayerNormTest : public OperatorTest { 0.13203048706054688, 0.30742281675338745, 0.6340786814689636}); - optional weight(tf.make({3}, {1.0, 1.0, 1.0})); - optional bias(tf.make({3}, {0.0, 0.0, 0.0})); + std::optional weight(tf.make({3}, {1.0, 1.0, 1.0})); + std::optional bias(tf.make({3}, {0.0, 0.0, 0.0})); Tensor expected = tf.make( {2, 3}, {0.16205203533172607, diff --git a/kernels/test/op_prod_test.cpp b/kernels/test/op_prod_test.cpp index d385fd7cb48..6b3ad158c26 100644 --- a/kernels/test/op_prod_test.cpp +++ b/kernels/test/op_prod_test.cpp @@ -18,7 +18,6 @@ using namespace ::testing; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; Tensor& @@ -31,7 +30,7 @@ Tensor& op_prod_int_out( const Tensor& self, int64_t dim, bool keepdim, - optional dtype, + std::optional dtype, Tensor& out) { executorch::ET_RUNTIME_NAMESPACE::KernelRuntimeContext context{}; return torch::executor::aten::prod_outf( @@ -56,7 +55,7 @@ class OpProdOutTest : public ::testing::Test { tf_out; Tensor self = tf.make({2, 3}, {1, 2, 3, 4, 5, 6}); - optional dtype{}; + std::optional dtype{}; Tensor out = tf_out.zeros({}); Tensor out_expected = tf_out.make({}, {DTYPE == ScalarType::Bool ? 1 : 720}); @@ -80,7 +79,7 @@ class OpProdIntOutTest : public ::testing::Test { Tensor self = tf.make({2, 3}, {1, 2, 3, 4, 5, 6}); int64_t dim = 0; bool keepdim = false; - optional dtype{}; + std::optional dtype{}; Tensor out = tf.zeros({3}); Tensor out_expected = tf.make({3}, {4, 10, 18}); op_prod_int_out(self, dim, keepdim, dtype, out); @@ -106,7 +105,7 @@ TEST_F(OpProdIntOutTest, SmokeTestKeepdim) { Tensor self = tfFloat.make({2, 3}, {1, 2, 3, 4, 5, 6}); int64_t dim = 0; bool keepdim = true; - optional dtype{}; + std::optional dtype{}; Tensor out = tfFloat.zeros({1, 3}); Tensor out_expected = tfFloat.make({1, 3}, {4, 10, 18}); op_prod_int_out(self, dim, keepdim, dtype, out); diff --git a/kernels/test/op_repeat_interleave_test.cpp b/kernels/test/op_repeat_interleave_test.cpp index 71018667ac7..4fd850bfea7 100644 --- a/kernels/test/op_repeat_interleave_test.cpp +++ b/kernels/test/op_repeat_interleave_test.cpp @@ -15,14 +15,13 @@ using namespace ::testing; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; class OpRepeatInterleaveTensorOutTest : public OperatorTest { protected: Tensor& op_repeat_out( const Tensor& repeats, - optional output_size, + std::optional output_size, Tensor& out) { return torch::executor::aten::repeat_interleave_outf( context_, repeats, output_size, out); diff --git a/kernels/test/op_slice_copy_test.cpp b/kernels/test/op_slice_copy_test.cpp index 719763f78cd..63859a57f4b 100644 --- a/kernels/test/op_slice_copy_test.cpp +++ b/kernels/test/op_slice_copy_test.cpp @@ -20,7 +20,6 @@ using namespace ::testing; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; class OpSliceCopyTensorOutTest : public OperatorTest { @@ -28,8 +27,8 @@ class OpSliceCopyTensorOutTest : public OperatorTest { Tensor& op_slice_copy_tensor_out( const Tensor& self, int64_t dim, - optional start, - optional end, + std::optional start, + std::optional end, int64_t step, Tensor& out) { return torch::executor::aten::slice_copy_outf( diff --git a/kernels/test/op_slice_scatter_test.cpp b/kernels/test/op_slice_scatter_test.cpp index 309f2b8b5f7..b0938cac596 100644 --- a/kernels/test/op_slice_scatter_test.cpp +++ b/kernels/test/op_slice_scatter_test.cpp @@ -20,7 +20,6 @@ using namespace ::testing; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; class OpSliceScatterTensorOutTest : public OperatorTest { @@ -29,8 +28,8 @@ class OpSliceScatterTensorOutTest : public OperatorTest { const Tensor& self, const Tensor& src, int64_t dim, - optional start, - optional end, + std::optional start, + std::optional end, int64_t step, Tensor& out) { return torch::executor::aten::slice_scatter_outf( diff --git a/kernels/test/op_sum_test.cpp b/kernels/test/op_sum_test.cpp index ff71bcdb383..01506b680a7 100644 --- a/kernels/test/op_sum_test.cpp +++ b/kernels/test/op_sum_test.cpp @@ -22,16 +22,15 @@ using namespace ::testing; using executorch::aten::ArrayRef; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; class OpSumOutTest : public OperatorTest { protected: Tensor& op_sum_intlist_out( const Tensor& self, - optional> dim, + std::optional> dim, bool keepdim, - optional dtype, + std::optional dtype, Tensor& out) { return torch::executor::aten::sum_outf( context_, self, dim, keepdim, dtype, out); @@ -56,11 +55,12 @@ class OpSumOutTest : public OperatorTest { }); // clang-format on Tensor out = tf_out.zeros({2, 3, 1}); - optional dtype = OUT_DTYPE; + std::optional dtype = OUT_DTYPE; // out-of-bound dim in dim list int64_t dims_1[1] = {3}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; ET_EXPECT_KERNEL_FAILURE( context_, op_sum_intlist_out( @@ -96,9 +96,10 @@ class OpSumOutTest : public OperatorTest { // dimension size mismatch when keepdim is true Tensor out = tf_out.zeros({2, 4}); - optional dtype = OUT_DTYPE; + std::optional dtype = OUT_DTYPE; int64_t dims_1[1] = {1}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; ET_EXPECT_KERNEL_FAILURE( context_, op_sum_intlist_out( @@ -143,8 +144,8 @@ class OpSumOutTest : public OperatorTest { CTYPE(0, 0), }); int64_t dims_1[1] = {2}; - optional> dim_list1{ArrayRef{dims_1, 1}}; - optional dtype = DTYPE; + std::optional> dim_list1{ArrayRef{dims_1, 1}}; + std::optional dtype = DTYPE; op_sum_intlist_out(self, dim_list1, true, dtype, out1); @@ -169,7 +170,7 @@ class OpSumOutTest : public OperatorTest { CTYPE(0, 0), }); int64_t dims_2[1] = {1}; - optional> dim_list2{ArrayRef{dims_2, 1}}; + std::optional> dim_list2{ArrayRef{dims_2, 1}}; op_sum_intlist_out(self, dim_list2, true, dtype, out2); @@ -182,7 +183,7 @@ class OpSumOutTest : public OperatorTest { { CTYPE(0, 0), }); - optional> null_dim_list; + std::optional> null_dim_list; op_sum_intlist_out(self, null_dim_list, true, dtype, out3); @@ -212,8 +213,9 @@ class OpSumOutTest : public OperatorTest { // keepdim=true should work Tensor out = tf_out.zeros({2, 3, 1}); int64_t dims_1[1] = {2}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; - optional dtype = OUT_DTYPE; + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; + std::optional dtype = OUT_DTYPE; op_sum_intlist_out(self, optional_dim_list, /*keepdim=*/true, dtype, out); // clang-format off EXPECT_TENSOR_CLOSE(out, tf_out.make( @@ -290,11 +292,11 @@ class OpSumOutTest : public OperatorTest { }); // clang-format on out = tf_out.zeros({1, 1, 1}); - optional> null_dim_list; + std::optional> null_dim_list; op_sum_intlist_out(self, null_dim_list, /*keepdim=*/true, dtype, out); EXPECT_TENSOR_CLOSE(out, tf_out.make({1, 1, 1}, {56})); - optional> empty_dim_list{ArrayRef{}}; + std::optional> empty_dim_list{ArrayRef{}}; op_sum_intlist_out(self, empty_dim_list, /*keepdim=*/true, dtype, out); EXPECT_TENSOR_CLOSE(out, tf_out.make({1, 1, 1}, {56})); @@ -395,8 +397,9 @@ TEST_F(OpSumOutTest, MismatchedDTypesDies) { Tensor out = tf_float.zeros({2, 3, 1}); int64_t dims_1[1] = {2}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; - optional dtype = ScalarType::Double; + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; + std::optional dtype = ScalarType::Double; // out tensor should be of the same dtype with dtype when dtype is specified ET_EXPECT_KERNEL_FAILURE( @@ -437,8 +440,9 @@ TEST_F(OpSumOutTest, TypeConversionTest) { // clang-format on int64_t dims_1[1] = {2}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; - optional dtype; + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; + std::optional dtype; // int -> bool conversion should work Tensor out = tf_bool.zeros({2, 3, 1}); @@ -503,8 +507,9 @@ TEST_F(OpSumOutTest, InfinityAndNANTest) { Tensor out = tf_float.zeros({2, 3, 1}); int64_t dims[1] = {-1}; - optional> optional_dim_list{ArrayRef{dims, 1}}; - optional dtype; + std::optional> optional_dim_list{ + ArrayRef{dims, 1}}; + std::optional dtype; op_sum_intlist_out(self, optional_dim_list, /*keepdim=*/true, dtype, out); // clang-format off EXPECT_TENSOR_CLOSE(out, tf_float.make( @@ -525,8 +530,8 @@ TEST_F(OpSumOutTest, EmptyInput) { TensorFactory tf; Tensor x = tf.make({2, 0, 3}, {}); - optional dtype = ScalarType::Float; - optional> dim_list = ArrayRef{}; + std::optional dtype = ScalarType::Float; + std::optional> dim_list = ArrayRef{}; Tensor out = tf.ones({1, 1, 1}); op_sum_intlist_out(x, dim_list, /*keepdim=*/true, dtype, out); EXPECT_TENSOR_CLOSE(out, tf.zeros({1, 1, 1})); diff --git a/kernels/test/op_to_copy_test.cpp b/kernels/test/op_to_copy_test.cpp index 45b2b2f6020..49e73e092f5 100644 --- a/kernels/test/op_to_copy_test.cpp +++ b/kernels/test/op_to_copy_test.cpp @@ -25,7 +25,6 @@ using namespace ::testing; using executorch::aten::MemoryFormat; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; // To further emphasize the accuracy of our op_to, we test the conversion @@ -58,7 +57,7 @@ class OpToTest : public OperatorTest { Tensor& op_to_copy_out( const Tensor& self, bool non_blocking, - optional memory_format, + std::optional memory_format, Tensor& out) { return torch::executor::aten::_to_copy_outf( context_, self, non_blocking, memory_format, out); @@ -225,7 +224,7 @@ class OpToTest : public OperatorTest { op = "op_to_copy_out" opt_setup_params = """ bool non_blocking = false; - optional memory_format; + std::optional memory_format; """ opt_extra_params = "non_blocking, memory_format," out_args = "out_shape, dynamism" @@ -258,7 +257,7 @@ class OpToTest : public OperatorTest { 0.6340786814689636}); bool non_blocking = false; - optional memory_format; + std::optional memory_format; Tensor out = tf.zeros(out_shape, dynamism); op_to_copy_out(x, non_blocking, memory_format, out); diff --git a/kernels/test/op_var_mean_test.cpp b/kernels/test/op_var_mean_test.cpp index 80571518e73..680a9b78e98 100644 --- a/kernels/test/op_var_mean_test.cpp +++ b/kernels/test/op_var_mean_test.cpp @@ -23,7 +23,6 @@ using executorch::aten::ArrayRef; using executorch::aten::Scalar; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; namespace { @@ -43,8 +42,8 @@ class OpVarMeanCorrectionOutTest : public OperatorTest { protected: std::tuple op_var_mean_correction_out( const Tensor& self, - optional> dim, - optional& correction, + std::optional> dim, + std::optional& correction, bool keepdim, Tensor& out0, Tensor& out1) { @@ -59,7 +58,7 @@ class OpVarMeanCorrectionOutTest : public OperatorTest { Tensor x = tf.make({2, 3}, {4.9, 4.0, 5.6, 3.8, 4.9, 5.6}); Tensor expected_var = tf.make({2}, {0.72693, 0.93032}); Tensor expected_mean = tf.make({2}, {4.833333, 4.766667}); - optional correction(1.23); + std::optional correction(1.23); Tensor var_out = tf.zeros({2}); Tensor mean_out = tf.zeros({2}); @@ -97,8 +96,9 @@ class OpVarMeanCorrectionOutTest : public OperatorTest { Tensor var_out = tf_out.zeros({2, 3, 1}); Tensor mean_out = tf_out.zeros({2, 3, 1}); int64_t dims_1[1] = {2}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; - optional correction(1); + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; + std::optional correction(1); op_var_mean_correction_out( self, optional_dim_list, @@ -179,8 +179,9 @@ class OpVarMeanCorrectionOutTest : public OperatorTest { Tensor var_out = tf_out.zeros({1, 1, 4}); Tensor mean_out = tf_out.zeros({1, 1, 4}); int64_t dims[2] = {0, 1}; - optional> optional_dim_list{ArrayRef{dims, 2}}; - optional correction(1); + std::optional> optional_dim_list{ + ArrayRef{dims, 2}}; + std::optional correction(1); op_var_mean_correction_out( self, optional_dim_list, @@ -230,8 +231,9 @@ class OpVarMeanCorrectionOutTest : public OperatorTest { Tensor var_out = tf_out.zeros({2, 1, 4}); Tensor mean_out = tf_out.zeros({2, 1, 4}); int64_t dims[1] = {-2}; - optional> optional_dim_list{ArrayRef{dims, 1}}; - optional correction(0); + std::optional> optional_dim_list{ + ArrayRef{dims, 1}}; + std::optional correction(0); op_var_mean_correction_out( self, optional_dim_list, @@ -279,8 +281,8 @@ class OpVarMeanCorrectionOutTest : public OperatorTest { // null dim list, correction=1 (unbiased), keepdim=true Tensor var_out = tf_out.zeros({1, 1, 1}); Tensor mean_out = tf_out.zeros({1, 1, 1}); - optional> null_dim_list; - optional correction(1); + std::optional> null_dim_list; + std::optional correction(1); op_var_mean_correction_out( self, null_dim_list, correction, /*keepdim=*/true, var_out, mean_out); expect_tensor_close_with_increased_tol( @@ -289,8 +291,8 @@ class OpVarMeanCorrectionOutTest : public OperatorTest { mean_out, tf_out.make({1, 1, 1}, {11.5})); // empty dim list, correction=0 (population), keepdim=true - optional> empty_dim_list{ArrayRef{}}; - optional correction_zero(0); + std::optional> empty_dim_list{ArrayRef{}}; + std::optional correction_zero(0); op_var_mean_correction_out( self, empty_dim_list, @@ -349,11 +351,12 @@ class OpVarMeanCorrectionOutTest : public OperatorTest { // clang-format on Tensor var_out = tf_out.zeros({2, 3, 1}); Tensor mean_out = tf_out.zeros({2, 3, 1}); - optional correction(1); + std::optional correction(1); // out-of-bound dim int64_t dims_1[1] = {3}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; ET_EXPECT_KERNEL_FAILURE( context_, op_var_mean_correction_out( @@ -530,8 +533,9 @@ TEST_F(OpVarMeanCorrectionOutTest, InvalidDTypeDies) { Tensor var_out = tf_float.zeros({2, 3, 1}); Tensor mean_out = tf_float.zeros({2, 3, 1}); int64_t dims_1[1] = {2}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; - optional correction(1); + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; + std::optional correction(1); ET_EXPECT_KERNEL_FAILURE( context_, @@ -548,11 +552,11 @@ TEST_F(OpVarMeanCorrectionOutTest, EmptyInput) { TensorFactory tf; Tensor x = tf.make({2, 0, 3}, {}); - optional correction(1); - optional correction_zero(0); + std::optional correction(1); + std::optional correction_zero(0); // empty dim list, correction=1, keepdim=true - optional> dim_list = ArrayRef{}; + std::optional> dim_list = ArrayRef{}; Tensor var_out = tf.zeros({1, 1, 1}); Tensor mean_out = tf.zeros({1, 1, 1}); op_var_mean_correction_out( @@ -596,7 +600,7 @@ TEST_F(OpVarMeanCorrectionOutTest, DynamicShapeUpperBoundSameAsExpected) { Tensor x = tf.make({3, 2}, {0.49, 0.40, 0.56, 0.38, 0.49, 0.56}); Tensor expected_var = tf.make({3}, {0.004050, 0.016200, 0.002450}); Tensor expected_mean = tf.make({3}, {0.445, 0.47, 0.525}); - optional correction(1); + std::optional correction(1); Tensor var_out = tf.zeros({3}, torch::executor::TensorShapeDynamism::DYNAMIC_BOUND); @@ -619,7 +623,7 @@ TEST_F(OpVarMeanCorrectionOutTest, DynamicShapeUpperBoundLargerThanExpected) { Tensor x = tf.make({3, 2}, {0.49, 0.40, 0.56, 0.38, 0.49, 0.56}); Tensor expected_var = tf.make({3}, {0.004050, 0.016200, 0.002450}); Tensor expected_mean = tf.make({3}, {0.445, 0.47, 0.525}); - optional correction(1); + std::optional correction(1); Tensor var_out = tf.zeros({10}, torch::executor::TensorShapeDynamism::DYNAMIC_BOUND); @@ -643,7 +647,7 @@ TEST_F(OpVarMeanCorrectionOutTest, DISABLED_DynamicShapeUnbound) { Tensor x = tf.make({3, 2}, {0.49, 0.40, 0.56, 0.38, 0.49, 0.56}); Tensor expected_var = tf.make({3}, {0.004050, 0.016200, 0.002450}); Tensor expected_mean = tf.make({3}, {0.445, 0.47, 0.525}); - optional correction(1); + std::optional correction(1); Tensor var_out = tf.zeros({1}, torch::executor::TensorShapeDynamism::DYNAMIC_UNBOUND); @@ -679,8 +683,9 @@ TEST_F(OpVarMeanCorrectionOutTest, InfinityAndNANTest) { Tensor var_out = tf.zeros({2, 3, 1}); Tensor mean_out = tf.zeros({2, 3, 1}); int64_t dims[1] = {-1}; - optional> optional_dim_list{ArrayRef{dims, 1}}; - optional correction(1); + std::optional> optional_dim_list{ + ArrayRef{dims, 1}}; + std::optional correction(1); op_var_mean_correction_out( self, optional_dim_list, diff --git a/kernels/test/op_var_test.cpp b/kernels/test/op_var_test.cpp index ccd0a022af3..9e46a7f5fc6 100644 --- a/kernels/test/op_var_test.cpp +++ b/kernels/test/op_var_test.cpp @@ -23,7 +23,6 @@ using executorch::aten::ArrayRef; using executorch::aten::Scalar; using executorch::aten::ScalarType; using executorch::aten::Tensor; -using std::optional; using torch::executor::testing::TensorFactory; namespace { @@ -43,7 +42,7 @@ class OpVarOutTest : public OperatorTest { protected: Tensor& op_var_out( const Tensor& self, - optional> dim, + std::optional> dim, bool unbiased, bool keepdim, Tensor& out) { @@ -70,11 +69,12 @@ class OpVarOutTest : public OperatorTest { }); // clang-format on Tensor out = tf_out.zeros({2, 3, 1}); - optional dtype = OUT_DTYPE; + std::optional dtype = OUT_DTYPE; // out-of-bound dim in dim list int64_t dims_1[1] = {3}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; ET_EXPECT_KERNEL_FAILURE( context_, op_var_out( @@ -118,9 +118,10 @@ class OpVarOutTest : public OperatorTest { // dimension size mismatch when keepdim is true Tensor out = tf_out.zeros({2, 4}); - optional dtype = OUT_DTYPE; + std::optional dtype = OUT_DTYPE; int64_t dims_1[1] = {1}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; ET_EXPECT_KERNEL_FAILURE( context_, op_var_out( @@ -163,8 +164,9 @@ class OpVarOutTest : public OperatorTest { // keepdim=true should work Tensor out = tf_out.zeros({2, 3, 1}); int64_t dims_1[1] = {2}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; - optional dtype = OUT_DTYPE; + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; + std::optional dtype = OUT_DTYPE; op_var_out( self, optional_dim_list, /*unbiased=*/true, /*keepdim=*/true, out); // clang-format off @@ -239,11 +241,11 @@ class OpVarOutTest : public OperatorTest { // empty/null dim list should work out = tf_out.zeros({1, 1, 1}); - optional> null_dim_list; + std::optional> null_dim_list; op_var_out(self, null_dim_list, /*unbiased=*/true, /*keepdim=*/true, out); expect_tensor_close_with_increased_tol(out, tf_out.make({1, 1, 1}, {50.0})); - optional> empty_dim_list{ArrayRef{}}; + std::optional> empty_dim_list{ArrayRef{}}; op_var_out(self, empty_dim_list, /*unbiased=*/false, /*keepdim=*/true, out); expect_tensor_close_with_increased_tol( out, tf_out.make({1, 1, 1}, {47.916668})); @@ -261,8 +263,8 @@ class OpVarCorrectionOutTest : public OperatorTest { protected: Tensor& op_var_correction_out( const Tensor& self, - optional> dim, - optional& correction, + std::optional> dim, + std::optional& correction, bool keepdim, Tensor& out) { return torch::executor::aten::var_outf( @@ -275,7 +277,7 @@ class OpVarCorrectionOutTest : public OperatorTest { Tensor x = tf.make({2, 3}, {4.9, 4.0, 5.6, 3.8, 4.9, 5.6}); Tensor expected = tf.make({2}, {0.72693, 0.93032}); - optional correction(1.23); + std::optional correction(1.23); Tensor out = tf.zeros({2}); op_var_correction_out( @@ -344,7 +346,8 @@ TEST_F(OpVarOutTest, InvalidDTypeDies) { // keepdim=true should work Tensor out = tf_float.zeros({2, 3, 1}); int64_t dims_1[1] = {2}; - optional> optional_dim_list{ArrayRef{dims_1, 1}}; + std::optional> optional_dim_list{ + ArrayRef{dims_1, 1}}; ET_EXPECT_KERNEL_FAILURE( context_, @@ -406,8 +409,9 @@ TEST_F(OpVarOutTest, InfinityAndNANTest) { Tensor out = tf_float.zeros({2, 3, 1}); int64_t dims[1] = {-1}; - optional> optional_dim_list{ArrayRef{dims, 1}}; - optional dtype; + std::optional> optional_dim_list{ + ArrayRef{dims, 1}}; + std::optional dtype; op_var_out(self, optional_dim_list, /*unbiased=*/true, /*keepdim=*/true, out); // clang-format off EXPECT_TENSOR_CLOSE(out, tf_float.make( @@ -475,7 +479,7 @@ TEST_F(OpVarOutTest, EmptyInput) { Tensor x = tf.make({2, 0, 3}, {}); bool unbiased = true; - optional> dim_list = ArrayRef{}; + std::optional> dim_list = ArrayRef{}; Tensor out = tf.zeros({1, 1, 1}); op_var_out(x, dim_list, unbiased, /*keepdim=*/true, out); EXPECT_TENSOR_CLOSE(out, tf.make({1, 1, 1}, {NAN}));