diff --git a/backends/cadence/fused_quant/op_add.cpp b/backends/cadence/fused_quant/op_add.cpp index 62e58c71c83..1aea2ccfb6c 100644 --- a/backends/cadence/fused_quant/op_add.cpp +++ b/backends/cadence/fused_quant/op_add.cpp @@ -14,10 +14,10 @@ namespace cadence { namespace fused_quant { namespace native { -using executorch::aten::optional; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::KernelRuntimeContext; +using std::optional; namespace { diff --git a/backends/cadence/fused_quant/op_add.h b/backends/cadence/fused_quant/op_add.h index 9db1e907294..b32710f41de 100644 --- a/backends/cadence/fused_quant/op_add.h +++ b/backends/cadence/fused_quant/op_add.h @@ -19,19 +19,18 @@ executorch::aten::Tensor& add_out( executorch::runtime::KernelRuntimeContext& ctx, const executorch::aten::Tensor& inp, const executorch::aten::Tensor& other, - const executorch::aten::optional& inp_scale, - const executorch::aten::optional& inp_zero_point, + const std::optional& inp_scale, + const std::optional& inp_zero_point, executorch::aten::ScalarType inp_dtype, int64_t inp_quant_min, int64_t inp_quant_max, - const executorch::aten::optional& other_scale, - const executorch::aten::optional& - other_zero_point, + const std::optional& other_scale, + const std::optional& other_zero_point, executorch::aten::ScalarType other_dtype, int64_t other_quant_min, int64_t other_quant_max, - const executorch::aten::optional& out_scale, - const executorch::aten::optional& out_zero_point, + const std::optional& out_scale, + const std::optional& out_zero_point, executorch::aten::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 7204ab6c88f..8d071b48a33 100644 --- a/backends/cadence/fused_quant/op_bmm.cpp +++ b/backends/cadence/fused_quant/op_bmm.cpp @@ -14,10 +14,10 @@ namespace cadence { namespace fused_quant { namespace native { -using executorch::aten::optional; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::KernelRuntimeContext; +using std::optional; namespace { diff --git a/backends/cadence/fused_quant/op_bmm.h b/backends/cadence/fused_quant/op_bmm.h index ef9598eac98..c6a4502983f 100644 --- a/backends/cadence/fused_quant/op_bmm.h +++ b/backends/cadence/fused_quant/op_bmm.h @@ -19,19 +19,18 @@ executorch::aten::Tensor& bmm_out( executorch::runtime::KernelRuntimeContext& ctx, const executorch::aten::Tensor& inp, const executorch::aten::Tensor& other, - const executorch::aten::optional& inp_scale, - const executorch::aten::optional& inp_zero_point, + const std::optional& inp_scale, + const std::optional& inp_zero_point, executorch::aten::ScalarType inp_dtype, int64_t inp_quant_min, int64_t inp_quant_max, - const executorch::aten::optional& other_scale, - const executorch::aten::optional& - other_zero_point, + const std::optional& other_scale, + const std::optional& other_zero_point, executorch::aten::ScalarType other_dtype, int64_t other_quant_min, int64_t other_quant_max, - const executorch::aten::optional& out_scale, - const executorch::aten::optional& out_zero_point, + const std::optional& out_scale, + const std::optional& out_zero_point, executorch::aten::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 452ea90a405..4b968cebe6c 100644 --- a/backends/cadence/fused_quant/op_hardswish.cpp +++ b/backends/cadence/fused_quant/op_hardswish.cpp @@ -16,10 +16,10 @@ namespace cadence { namespace fused_quant { namespace native { -using executorch::aten::optional; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::KernelRuntimeContext; +using std::optional; namespace { diff --git a/backends/cadence/fused_quant/op_hardswish.h b/backends/cadence/fused_quant/op_hardswish.h index ba9e09da23c..de7d88b427b 100644 --- a/backends/cadence/fused_quant/op_hardswish.h +++ b/backends/cadence/fused_quant/op_hardswish.h @@ -18,13 +18,13 @@ namespace native { executorch::aten::Tensor& hardswish_out( executorch::runtime::KernelRuntimeContext& ctx, const executorch::aten::Tensor& inp, - const executorch::aten::optional& inp_scale, - const executorch::aten::optional& inp_zero_point, + const std::optional& inp_scale, + const std::optional& inp_zero_point, executorch::aten::ScalarType inp_dtype, int64_t inp_quant_min, int64_t inp_quant_max, - const executorch::aten::optional& out_scale, - const executorch::aten::optional& out_zero_point, + const std::optional& out_scale, + const std::optional& out_zero_point, executorch::aten::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 3d071f7c2da..a2595104ae8 100644 --- a/backends/cadence/fused_quant/op_mul.cpp +++ b/backends/cadence/fused_quant/op_mul.cpp @@ -14,10 +14,10 @@ namespace cadence { namespace fused_quant { namespace native { -using executorch::aten::optional; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::KernelRuntimeContext; +using std::optional; namespace { diff --git a/backends/cadence/fused_quant/op_mul.h b/backends/cadence/fused_quant/op_mul.h index f7afa016b79..62314c98003 100644 --- a/backends/cadence/fused_quant/op_mul.h +++ b/backends/cadence/fused_quant/op_mul.h @@ -19,19 +19,18 @@ executorch::aten::Tensor& mul_out( executorch::runtime::KernelRuntimeContext& ctx, const executorch::aten::Tensor& inp, const executorch::aten::Tensor& other, - const executorch::aten::optional& inp_scale, - const executorch::aten::optional& inp_zero_point, + const std::optional& inp_scale, + const std::optional& inp_zero_point, executorch::aten::ScalarType inp_dtype, int64_t inp_quant_min, int64_t inp_quant_max, - const executorch::aten::optional& other_scale, - const executorch::aten::optional& - other_zero_point, + const std::optional& other_scale, + const std::optional& other_zero_point, executorch::aten::ScalarType other_dtype, int64_t other_quant_min, int64_t other_quant_max, - const executorch::aten::optional& out_scale, - const executorch::aten::optional& out_zero_point, + const std::optional& out_scale, + const std::optional& out_zero_point, executorch::aten::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 ebe7933a7b9..e8e58522d2e 100644 --- a/backends/cadence/fused_quant/op_relu.cpp +++ b/backends/cadence/fused_quant/op_relu.cpp @@ -16,10 +16,10 @@ namespace cadence { namespace fused_quant { namespace native { -using executorch::aten::optional; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::KernelRuntimeContext; +using std::optional; namespace { diff --git a/backends/cadence/fused_quant/op_relu.h b/backends/cadence/fused_quant/op_relu.h index e8527c7633f..522144eacd0 100644 --- a/backends/cadence/fused_quant/op_relu.h +++ b/backends/cadence/fused_quant/op_relu.h @@ -18,13 +18,13 @@ namespace native { executorch::aten::Tensor& relu_out( executorch::runtime::KernelRuntimeContext& ctx, const executorch::aten::Tensor& inp, - const executorch::aten::optional& inp_scale, - const executorch::aten::optional& inp_zero_point, + const std::optional& inp_scale, + const std::optional& inp_zero_point, executorch::aten::ScalarType inp_dtype, int64_t inp_quant_min, int64_t inp_quant_max, - const executorch::aten::optional& out_scale, - const executorch::aten::optional& out_zero_point, + const std::optional& out_scale, + const std::optional& out_zero_point, executorch::aten::ScalarType out_dtype, int64_t out_quant_min, int64_t out_quant_max, diff --git a/backends/cadence/fused_quant/quant_utils.h b/backends/cadence/fused_quant/quant_utils.h index fff669a9e0e..78884bfcceb 100644 --- a/backends/cadence/fused_quant/quant_utils.h +++ b/backends/cadence/fused_quant/quant_utils.h @@ -64,8 +64,8 @@ struct QParams { }; inline QParams extract_qparams( - const executorch::aten::optional& scale_tensor, - const executorch::aten::optional& zp_tensor, + const std::optional& scale_tensor, + const std::optional& zp_tensor, int64_t quant_min, int64_t quant_max, const executorch::aten::Tensor& data_tensor) { diff --git a/backends/cadence/fused_quant/tests/test_op_add.cpp b/backends/cadence/fused_quant/tests/test_op_add.cpp index dca110cf0e1..61124f0b9b2 100644 --- a/backends/cadence/fused_quant/tests/test_op_add.cpp +++ b/backends/cadence/fused_quant/tests/test_op_add.cpp @@ -14,10 +14,10 @@ #include #include -using executorch::aten::optional; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::testing::TensorFactory; +using std::optional; namespace { diff --git a/backends/cadence/fused_quant/tests/test_op_bmm.cpp b/backends/cadence/fused_quant/tests/test_op_bmm.cpp index 5ede47ea8a9..bae04993a7a 100644 --- a/backends/cadence/fused_quant/tests/test_op_bmm.cpp +++ b/backends/cadence/fused_quant/tests/test_op_bmm.cpp @@ -14,10 +14,10 @@ #include #include -using executorch::aten::optional; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::testing::TensorFactory; +using std::optional; namespace { diff --git a/backends/cadence/fused_quant/tests/test_op_hardswish.cpp b/backends/cadence/fused_quant/tests/test_op_hardswish.cpp index 502d680d2e3..eb6231161f2 100644 --- a/backends/cadence/fused_quant/tests/test_op_hardswish.cpp +++ b/backends/cadence/fused_quant/tests/test_op_hardswish.cpp @@ -14,10 +14,10 @@ #include #include -using executorch::aten::optional; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::testing::TensorFactory; +using std::optional; namespace { diff --git a/backends/cadence/fused_quant/tests/test_op_mul.cpp b/backends/cadence/fused_quant/tests/test_op_mul.cpp index 0b9addabc5e..da27c7287c9 100644 --- a/backends/cadence/fused_quant/tests/test_op_mul.cpp +++ b/backends/cadence/fused_quant/tests/test_op_mul.cpp @@ -14,10 +14,10 @@ #include #include -using executorch::aten::optional; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::testing::TensorFactory; +using std::optional; namespace { diff --git a/backends/cadence/fused_quant/tests/test_op_relu.cpp b/backends/cadence/fused_quant/tests/test_op_relu.cpp index 6b83551fd2b..1096daae202 100644 --- a/backends/cadence/fused_quant/tests/test_op_relu.cpp +++ b/backends/cadence/fused_quant/tests/test_op_relu.cpp @@ -14,10 +14,10 @@ #include #include -using executorch::aten::optional; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::testing::TensorFactory; +using std::optional; namespace { diff --git a/backends/cadence/generic/operators/op_avg_pool2d.cpp b/backends/cadence/generic/operators/op_avg_pool2d.cpp index b04187db62e..c33f91151fb 100644 --- a/backends/cadence/generic/operators/op_avg_pool2d.cpp +++ b/backends/cadence/generic/operators/op_avg_pool2d.cpp @@ -19,11 +19,11 @@ namespace generic { namespace native { using ::executorch::aten::IntArrayRef; -using ::executorch::aten::optional; 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 diff --git a/backends/cadence/generic/operators/op_avg_pool2d.h b/backends/cadence/generic/operators/op_avg_pool2d.h index 05f1810bb61..85b5d55a84b 100644 --- a/backends/cadence/generic/operators/op_avg_pool2d.h +++ b/backends/cadence/generic/operators/op_avg_pool2d.h @@ -23,9 +23,8 @@ ::executorch::aten::Tensor& avg_pool2d_out( ::executorch::aten::IntArrayRef padding, bool ceil_mode, bool count_include_pad, - ::executorch::aten::optional divisor_override, - const ::executorch::aten::optional<::executorch::aten::Tensor>& - in_zero_point_t, + std::optional divisor_override, + const std::optional<::executorch::aten::Tensor>& in_zero_point_t, bool channel_last, ::executorch::aten::Tensor& out); diff --git a/backends/cadence/generic/operators/op_fully_connected.cpp b/backends/cadence/generic/operators/op_fully_connected.cpp index 36befc52102..b65f8016880 100644 --- a/backends/cadence/generic/operators/op_fully_connected.cpp +++ b/backends/cadence/generic/operators/op_fully_connected.cpp @@ -15,10 +15,10 @@ namespace impl { namespace generic { namespace native { -using ::executorch::aten::optional; using ::executorch::aten::Tensor; using ::executorch::runtime::getLeadingDims; using ::executorch::runtime::KernelRuntimeContext; +using std::optional; void linear( const Tensor& input, diff --git a/backends/cadence/generic/operators/op_fully_connected.h b/backends/cadence/generic/operators/op_fully_connected.h index d23bcbeb70c..7e03f5ef664 100644 --- a/backends/cadence/generic/operators/op_fully_connected.h +++ b/backends/cadence/generic/operators/op_fully_connected.h @@ -15,9 +15,9 @@ namespace impl { namespace generic { namespace native { -using ::executorch::aten::optional; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; +using std::optional; Tensor& fully_connected_out( KernelRuntimeContext& ctx, diff --git a/backends/cadence/generic/operators/op_linalg_svd.cpp b/backends/cadence/generic/operators/op_linalg_svd.cpp index 4974b617418..4cb4f6397ea 100644 --- a/backends/cadence/generic/operators/op_linalg_svd.cpp +++ b/backends/cadence/generic/operators/op_linalg_svd.cpp @@ -261,7 +261,7 @@ std::tuple linalg_svd_out( const Tensor& A, bool full_matrices, bool compute_uv, - ::executorch::aten::optional<::executorch::aten::string_view> driver, + std::optional driver, Tensor& U, Tensor& S, Tensor& Vh) { diff --git a/backends/cadence/generic/operators/op_linalg_svd.h b/backends/cadence/generic/operators/op_linalg_svd.h index 7635276c4f5..e8335b7fa0e 100644 --- a/backends/cadence/generic/operators/op_linalg_svd.h +++ b/backends/cadence/generic/operators/op_linalg_svd.h @@ -26,7 +26,7 @@ linalg_svd_out( const ::executorch::aten::Tensor& A, bool full_matrices, bool compute_uv, - ::executorch::aten::optional<::executorch::aten::string_view> driver, + std::optional driver, ::executorch::aten::Tensor& U, ::executorch::aten::Tensor& S, ::executorch::aten::Tensor& Vh); diff --git a/backends/cadence/generic/operators/op_quantized_conv1d_nlc.cpp b/backends/cadence/generic/operators/op_quantized_conv1d_nlc.cpp index 6f42543cfc1..8a427045a83 100644 --- a/backends/cadence/generic/operators/op_quantized_conv1d_nlc.cpp +++ b/backends/cadence/generic/operators/op_quantized_conv1d_nlc.cpp @@ -256,7 +256,7 @@ ::executorch::aten::Tensor& quantized_conv1d_nlc_per_tensor_out( int64_t output_zero_point, __ET_UNUSED int64_t out_multiplier, __ET_UNUSED int64_t out_shift, - __ET_UNUSED const ::executorch::aten::optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { (void)ctx; quantized_conv1d_nlc( diff --git a/backends/cadence/generic/operators/op_quantized_conv1d_nlc.h b/backends/cadence/generic/operators/op_quantized_conv1d_nlc.h index 4f4d2877b27..f1780497f73 100644 --- a/backends/cadence/generic/operators/op_quantized_conv1d_nlc.h +++ b/backends/cadence/generic/operators/op_quantized_conv1d_nlc.h @@ -54,7 +54,7 @@ ::executorch::aten::Tensor& quantized_conv1d_nlc_per_tensor_out( int64_t output_zero_point, int64_t out_multiplier, int64_t out_shift, - const ::executorch::aten::optional& offset, + const std::optional& offset, Tensor& out); } // namespace native diff --git a/backends/cadence/generic/operators/op_quantized_conv2d.cpp b/backends/cadence/generic/operators/op_quantized_conv2d.cpp index 0811267a3b8..f6755f9dda8 100644 --- a/backends/cadence/generic/operators/op_quantized_conv2d.cpp +++ b/backends/cadence/generic/operators/op_quantized_conv2d.cpp @@ -16,11 +16,11 @@ namespace impl { namespace generic { namespace native { -using ::executorch::aten::optional; using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; using ::impl::generic::kernels::quantize; +using std::optional; /* This implements a generic 2d conv kernel that operates on raw pointers. * The quantized version handles quantized convolutions for 2D inputs. @@ -936,7 +936,7 @@ Tensor& quantized_conv2d_nhwc_per_tensor_out( int64_t output_zero_point, ET_UNUSED int64_t out_multiplier, ET_UNUSED int64_t out_shift, - ET_UNUSED const ::executorch::aten::optional& offset, + ET_UNUSED const std::optional& offset, Tensor& out) { quantized_conv2d_nhwc( input, diff --git a/backends/cadence/generic/operators/op_quantized_conv2d.h b/backends/cadence/generic/operators/op_quantized_conv2d.h index bb9476e2644..02740d3afec 100644 --- a/backends/cadence/generic/operators/op_quantized_conv2d.h +++ b/backends/cadence/generic/operators/op_quantized_conv2d.h @@ -205,7 +205,7 @@ ::executorch::aten::Tensor& quantized_conv2d_nhwc_per_tensor_out( int64_t output_zero_point, int64_t out_multiplier, int64_t out_shift, - const ::executorch::aten::optional& offset, + const std::optional& offset, Tensor& out); ::executorch::aten::Tensor& quantized_conv2d_depthwise_nhwc_out( diff --git a/backends/cadence/generic/operators/op_quantized_depthwise_conv1d_nlc.cpp b/backends/cadence/generic/operators/op_quantized_depthwise_conv1d_nlc.cpp index a8f98a76ffc..05fb809cd51 100644 --- a/backends/cadence/generic/operators/op_quantized_depthwise_conv1d_nlc.cpp +++ b/backends/cadence/generic/operators/op_quantized_depthwise_conv1d_nlc.cpp @@ -57,7 +57,7 @@ ::executorch::aten::Tensor& quantized_depthwise_conv1d_nlc_per_tensor_out( output_zero_point, out_multiplier, out_shift, - ::executorch::aten::optional(), + std::optional(), out); } diff --git a/backends/cadence/generic/operators/op_quantized_embedding_byte.cpp b/backends/cadence/generic/operators/op_quantized_embedding_byte.cpp index 55ca67648ca..d2e0d6a8bd9 100644 --- a/backends/cadence/generic/operators/op_quantized_embedding_byte.cpp +++ b/backends/cadence/generic/operators/op_quantized_embedding_byte.cpp @@ -19,11 +19,11 @@ namespace generic { namespace native { using ::executorch::aten::IntArrayRef; -using ::executorch::aten::optional; using ::executorch::aten::Scalar; using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; +using std::optional; #define ET_FORALL_CADENCE_QUANTIZED_TYPES(_) \ _(uint8_t, Byte) \ diff --git a/backends/cadence/generic/operators/op_quantized_embedding_byte.h b/backends/cadence/generic/operators/op_quantized_embedding_byte.h index a46bebe09df..84fc53620a0 100644 --- a/backends/cadence/generic/operators/op_quantized_embedding_byte.h +++ b/backends/cadence/generic/operators/op_quantized_embedding_byte.h @@ -19,8 +19,7 @@ ::executorch::aten::Tensor& quantized_embedding_byte_out( ::executorch::runtime::KernelRuntimeContext& ctx, const ::executorch::aten::Tensor& weight, const ::executorch::aten::Tensor& weight_scales, - const ::executorch::aten::optional<::executorch::aten::Tensor>& - weight_zero_points, + const std::optional<::executorch::aten::Tensor>& weight_zero_points, const ::executorch::aten::Tensor& indices, bool pruned_weights, ::executorch::aten::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 55e29cb7f52..ce74b5b8b7f 100644 --- a/backends/cadence/generic/operators/op_quantized_fully_connected.cpp +++ b/backends/cadence/generic/operators/op_quantized_fully_connected.cpp @@ -16,10 +16,10 @@ namespace impl { namespace generic { namespace native { -using ::executorch::aten::optional; using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; +using std::optional; Tensor& quantized_fully_connected_out( ET_UNUSED KernelRuntimeContext& ctx, diff --git a/backends/cadence/generic/operators/op_quantized_fully_connected.h b/backends/cadence/generic/operators/op_quantized_fully_connected.h index a7510fba95f..408fbabe726 100644 --- a/backends/cadence/generic/operators/op_quantized_fully_connected.h +++ b/backends/cadence/generic/operators/op_quantized_fully_connected.h @@ -25,7 +25,7 @@ ::executorch::aten::Tensor& quantized_fully_connected_out( const ::executorch::aten::Tensor& out_multiplier, const ::executorch::aten::Tensor& out_shift, int64_t out_zero_point, - const ::executorch::aten::optional<::executorch::aten::Tensor>& offset, + const std::optional<::executorch::aten::Tensor>& offset, ::executorch::aten::Tensor& out); ::executorch::aten::Tensor& quantized_fully_connected_per_tensor_out( @@ -38,7 +38,7 @@ ::executorch::aten::Tensor& quantized_fully_connected_per_tensor_out( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - const ::executorch::aten::optional<::executorch::aten::Tensor>& offset, + const std::optional<::executorch::aten::Tensor>& offset, ::executorch::aten::Tensor& out); ::executorch::aten::Tensor& @@ -52,7 +52,7 @@ quantized_fully_connected_asym8sxasym8s_asym8s_per_tensor_out( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - const ::executorch::aten::optional<::executorch::aten::Tensor>& offset, + const std::optional<::executorch::aten::Tensor>& offset, ::executorch::aten::Tensor& out); ::executorch::aten::Tensor& @@ -66,7 +66,7 @@ quantized_fully_connected_asym8uxasym8u_asym8u_per_tensor_out( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - const ::executorch::aten::optional<::executorch::aten::Tensor>& offset, + const std::optional<::executorch::aten::Tensor>& offset, ::executorch::aten::Tensor& out); } // namespace native diff --git a/backends/cadence/generic/operators/op_quantized_layer_norm.cpp b/backends/cadence/generic/operators/op_quantized_layer_norm.cpp index e34ed342d22..85825cff94d 100644 --- a/backends/cadence/generic/operators/op_quantized_layer_norm.cpp +++ b/backends/cadence/generic/operators/op_quantized_layer_norm.cpp @@ -24,7 +24,6 @@ namespace generic { namespace native { using ::executorch::aten::IntArrayRef; -using ::executorch::aten::optional; using ::executorch::aten::Scalar; using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; @@ -32,6 +31,7 @@ using ::executorch::runtime::getLeadingDims; using ::executorch::runtime::KernelRuntimeContext; using ::impl::generic::kernels::dequantize; using ::impl::generic::kernels::quantize; +using std::optional; // Compute quantized layer_norm. The current implementation assumes that the // input is per-tensor quantized. diff --git a/backends/cadence/generic/operators/op_quantized_linear.cpp b/backends/cadence/generic/operators/op_quantized_linear.cpp index 87f990a855b..02ff97de74d 100644 --- a/backends/cadence/generic/operators/op_quantized_linear.cpp +++ b/backends/cadence/generic/operators/op_quantized_linear.cpp @@ -18,11 +18,11 @@ namespace impl { namespace generic { namespace native { -using ::executorch::aten::optional; 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, diff --git a/backends/cadence/generic/operators/op_quantized_linear.h b/backends/cadence/generic/operators/op_quantized_linear.h index b5396cb9701..517357d5bf9 100644 --- a/backends/cadence/generic/operators/op_quantized_linear.h +++ b/backends/cadence/generic/operators/op_quantized_linear.h @@ -25,7 +25,7 @@ ::executorch::aten::Tensor& quantized_linear_out( const ::executorch::aten::Tensor& out_multiplier, const ::executorch::aten::Tensor& out_shift, int64_t out_zero_point, - const ::executorch::aten::optional<::executorch::aten::Tensor>& offset, + const std::optional<::executorch::aten::Tensor>& offset, ::executorch::aten::Tensor& out); ::executorch::aten::Tensor& quantized_linear_per_tensor_out( @@ -38,7 +38,7 @@ ::executorch::aten::Tensor& quantized_linear_per_tensor_out( const int64_t out_multiplier, const int64_t out_shift, const int64_t out_zero_point, - const ::executorch::aten::optional<::executorch::aten::Tensor>& offset, + const std::optional<::executorch::aten::Tensor>& offset, ::executorch::aten::Tensor& out); ::executorch::aten::Tensor& diff --git a/backends/cadence/generic/operators/op_quantized_matmul.cpp b/backends/cadence/generic/operators/op_quantized_matmul.cpp index e3fb0f00fdc..b84c879e65d 100644 --- a/backends/cadence/generic/operators/op_quantized_matmul.cpp +++ b/backends/cadence/generic/operators/op_quantized_matmul.cpp @@ -21,12 +21,12 @@ namespace generic { namespace native { using ::executorch::aten::IntArrayRef; -using ::executorch::aten::optional; using ::executorch::aten::Scalar; 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. diff --git a/backends/cadence/generic/operators/op_quantized_matmul.h b/backends/cadence/generic/operators/op_quantized_matmul.h index 70775380aac..c28862aa11e 100644 --- a/backends/cadence/generic/operators/op_quantized_matmul.h +++ b/backends/cadence/generic/operators/op_quantized_matmul.h @@ -15,9 +15,9 @@ namespace impl { namespace generic { namespace native { -using ::executorch::aten::optional; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; +using std::optional; Tensor& quantized_matmul_out( KernelRuntimeContext& ctx, diff --git a/backends/cadence/generic/operators/op_quantized_mul.cpp b/backends/cadence/generic/operators/op_quantized_mul.cpp index 30352ee9d52..359a305b020 100644 --- a/backends/cadence/generic/operators/op_quantized_mul.cpp +++ b/backends/cadence/generic/operators/op_quantized_mul.cpp @@ -21,13 +21,13 @@ namespace generic { namespace native { using ::executorch::aten::IntArrayRef; -using ::executorch::aten::optional; using ::executorch::aten::Scalar; using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; using ::impl::generic::kernels::dequantize; using ::impl::generic::kernels::quantize; +using std::optional; DECLARE_POINTWISE_TENSOR_QUANTIZED_BINARY_OP(quantized_mul_, *); diff --git a/backends/cadence/generic/operators/op_quantized_relu.cpp b/backends/cadence/generic/operators/op_quantized_relu.cpp index 9430951f65b..ecb87bd1b90 100644 --- a/backends/cadence/generic/operators/op_quantized_relu.cpp +++ b/backends/cadence/generic/operators/op_quantized_relu.cpp @@ -21,12 +21,12 @@ namespace generic { namespace native { using ::executorch::aten::IntArrayRef; -using ::executorch::aten::optional; using ::executorch::aten::Scalar; using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; using ::impl::generic::kernels::quantize; +using std::optional; template void quantized_relu_per_tensor_out_( diff --git a/backends/cadence/generic/operators/op_requantize.cpp b/backends/cadence/generic/operators/op_requantize.cpp index f846a1964a3..b9df6f1f355 100644 --- a/backends/cadence/generic/operators/op_requantize.cpp +++ b/backends/cadence/generic/operators/op_requantize.cpp @@ -19,13 +19,13 @@ namespace generic { namespace native { using ::executorch::aten::IntArrayRef; -using ::executorch::aten::optional; using ::executorch::aten::Scalar; using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; using ::impl::generic::kernels::dequantize; using ::impl::generic::kernels::quantize; +using std::optional; // Requantize the int8_t/uint8_t input tensor to a uint8_t/int8_t out tensor. // The scale and zero_point for requantization are in the args. diff --git a/backends/cadence/generic/operators/op_rope.cpp b/backends/cadence/generic/operators/op_rope.cpp index 17ee6d2a684..fcc7d629cf7 100644 --- a/backends/cadence/generic/operators/op_rope.cpp +++ b/backends/cadence/generic/operators/op_rope.cpp @@ -12,8 +12,8 @@ namespace impl { namespace generic { namespace native { -using ::executorch::aten::optional; using ::executorch::aten::Tensor; +using std::optional; Tensor& rope_out( ET_UNUSED ::executorch::runtime::KernelRuntimeContext& ctx, @@ -75,8 +75,8 @@ namespace impl { namespace generic { namespace native { -using ::executorch::aten::optional; using ::executorch::aten::Tensor; +using std::optional; Tensor& rope_rotate_stacked_halves_out( ET_UNUSED ::executorch::runtime::KernelRuntimeContext& ctx, diff --git a/backends/cadence/generic/operators/op_rope.h b/backends/cadence/generic/operators/op_rope.h index 638677bf118..d738cfda6c1 100644 --- a/backends/cadence/generic/operators/op_rope.h +++ b/backends/cadence/generic/operators/op_rope.h @@ -20,7 +20,7 @@ ::executorch::aten::Tensor& rope_out( const ::executorch::aten::Tensor& input, const ::executorch::aten::Tensor& sin_tensor, const ::executorch::aten::Tensor& cos_tensor, - const ::executorch::aten::optional<::executorch::aten::Tensor>& pos, + const std::optional<::executorch::aten::Tensor>& pos, ::executorch::aten::Tensor& out); ::executorch::aten::Tensor& rope_rotate_stacked_halves_out( @@ -28,7 +28,7 @@ ::executorch::aten::Tensor& rope_rotate_stacked_halves_out( const ::executorch::aten::Tensor& input, const ::executorch::aten::Tensor& sin_tensor, const ::executorch::aten::Tensor& cos_tensor, - const ::executorch::aten::optional<::executorch::aten::Tensor>& pos, + const std::optional<::executorch::aten::Tensor>& pos, ::executorch::aten::Tensor& out); } // namespace native diff --git a/backends/cadence/generic/operators/op_softmax.cpp b/backends/cadence/generic/operators/op_softmax.cpp index 97c64a22511..b680d1e2471 100644 --- a/backends/cadence/generic/operators/op_softmax.cpp +++ b/backends/cadence/generic/operators/op_softmax.cpp @@ -125,7 +125,7 @@ Tensor& _softmax_f32_f32_out( __ET_UNUSED KernelRuntimeContext& ctx, const Tensor& X, int64_t dim, - __ET_UNUSED ::executorch::aten::optional half_to_float, + __ET_UNUSED std::optional half_to_float, Tensor& Y) { _softmax_out(ctx, X, dim, false, Y); diff --git a/backends/cadence/generic/operators/op_softmax.h b/backends/cadence/generic/operators/op_softmax.h index ec51b1d00c0..d83703117b0 100644 --- a/backends/cadence/generic/operators/op_softmax.h +++ b/backends/cadence/generic/operators/op_softmax.h @@ -26,7 +26,7 @@ ::executorch::aten::Tensor& _softmax_f32_f32_out( __ET_UNUSED ::executorch::runtime::KernelRuntimeContext& ctx, const ::executorch::aten::Tensor& X, int64_t dim, - __ET_UNUSED ::executorch::aten::optional half_to_float, + __ET_UNUSED std::optional half_to_float, ::executorch::aten::Tensor& Y); } // namespace native diff --git a/backends/cadence/generic/operators/op_transposed_convolution.cpp b/backends/cadence/generic/operators/op_transposed_convolution.cpp index 121b479e65f..b742ec635b2 100644 --- a/backends/cadence/generic/operators/op_transposed_convolution.cpp +++ b/backends/cadence/generic/operators/op_transposed_convolution.cpp @@ -16,12 +16,12 @@ namespace generic { namespace native { using ::executorch::aten::IntArrayRef; -using ::executorch::aten::optional; using ::executorch::aten::Scalar; using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; using ::impl::generic::kernels::quantize; +using std::optional; // This implements a generic 2d transposed_conv kernel that operates on raw // pointers. The version handles both quantized and fp32 convolutions. diff --git a/backends/cadence/hifi/operators/op_mean.cpp b/backends/cadence/hifi/operators/op_mean.cpp index 514813fbe05..ccd54e80698 100644 --- a/backends/cadence/hifi/operators/op_mean.cpp +++ b/backends/cadence/hifi/operators/op_mean.cpp @@ -17,8 +17,8 @@ using executorch::aten::RuntimeContext; using executorch::aten::ScalarType; using executorch::aten::Tensor; using executorch::runtime::ArrayRef; +using std::optional; using torch::executor::Error; -using torch::executor::optional; namespace impl { namespace HiFi { diff --git a/backends/cadence/hifi/operators/op_quantized_conv1d_nlc.cpp b/backends/cadence/hifi/operators/op_quantized_conv1d_nlc.cpp index 5171c2908bc..9d363469f74 100644 --- a/backends/cadence/hifi/operators/op_quantized_conv1d_nlc.cpp +++ b/backends/cadence/hifi/operators/op_quantized_conv1d_nlc.cpp @@ -238,7 +238,7 @@ void quantized_conv1d_nlc_per_tensor_out( int64_t output_zero_point, int64_t out_multiplier, int64_t out_shift, - __ET_UNUSED const ::executorch::aten::optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { // HiFi nnlib kernels only support dilation=1. // Fall back to generic implementation for dilation > 1. 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 ea3a756f995..86ef244711d 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,7 @@ using Tensor = executorch::aten::Tensor; using KernelRuntimeContext = torch::executor::KernelRuntimeContext; using ScalarType = executorch::aten::ScalarType; using ::executorch::aten::IntArrayRef; -using ::executorch::aten::optional; +using std::optional; namespace impl { namespace HiFi { diff --git a/backends/cadence/hifi/operators/op_quantized_depthwise_conv1d_nlc.cpp b/backends/cadence/hifi/operators/op_quantized_depthwise_conv1d_nlc.cpp index 4299990b52a..a8e2b42d77d 100644 --- a/backends/cadence/hifi/operators/op_quantized_depthwise_conv1d_nlc.cpp +++ b/backends/cadence/hifi/operators/op_quantized_depthwise_conv1d_nlc.cpp @@ -206,7 +206,7 @@ void quantized_depthwise_conv1d_nlc_per_tensor_out( output_zero_point, out_multiplier, out_shift, - ::executorch::aten::optional(), + std::optional(), out); return; } diff --git a/backends/cadence/hifi/operators/op_quantized_matmul_out.h b/backends/cadence/hifi/operators/op_quantized_matmul_out.h index c53a07b58aa..a567c7f650d 100644 --- a/backends/cadence/hifi/operators/op_quantized_matmul_out.h +++ b/backends/cadence/hifi/operators/op_quantized_matmul_out.h @@ -21,7 +21,7 @@ ::executorch::aten::Tensor& quantized_matmul_out( int64_t X_zero_point, const ::executorch::aten::Tensor& Y, int64_t Y_zero_point, - const ::executorch::aten::optional<::executorch::aten::Tensor>& bias, + const std::optional<::executorch::aten::Tensor>& bias, int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, diff --git a/backends/cadence/hifi/operators/op_softmax_f32_f32.cpp b/backends/cadence/hifi/operators/op_softmax_f32_f32.cpp index 074ff29b301..907156af1f7 100644 --- a/backends/cadence/hifi/operators/op_softmax_f32_f32.cpp +++ b/backends/cadence/hifi/operators/op_softmax_f32_f32.cpp @@ -22,7 +22,7 @@ inline Tensor& _softmax_f32_f32_out( KernelRuntimeContext& ctx, const Tensor& in, int64_t dim, - ::executorch::aten::optional half_to_float, + std::optional half_to_float, Tensor& out) { constexpr int kNnlibMaxDim = 16; @@ -146,7 +146,7 @@ Tensor& softmax_f32_f32_out( KernelRuntimeContext& ctx, const Tensor& in, int64_t dim, - ::executorch::aten::optional half_to_float, + std::optional half_to_float, Tensor& out) { return _softmax_f32_f32_out(ctx, in, dim, half_to_float, out); } diff --git a/backends/cadence/hifi/operators/operators.h b/backends/cadence/hifi/operators/operators.h index 3ca505d40cb..fa6847f744b 100644 --- a/backends/cadence/hifi/operators/operators.h +++ b/backends/cadence/hifi/operators/operators.h @@ -72,7 +72,7 @@ void quantized_linear_out( const ::executorch::aten::Tensor& out_multiplier, const ::executorch::aten::Tensor& out_shift, int64_t out_zero_point, - const ::executorch::aten::optional<::executorch::aten::Tensor>& offset, + const std::optional<::executorch::aten::Tensor>& offset, ::executorch::aten::Tensor& out); void quantized_linear_per_tensor_out( @@ -85,7 +85,7 @@ void quantized_linear_per_tensor_out( int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, - const ::executorch::aten::optional<::executorch::aten::Tensor>& offset, + const std::optional<::executorch::aten::Tensor>& offset, ::executorch::aten::Tensor& out); void quantized_conv2d_nhwc_out( @@ -158,7 +158,7 @@ void quantized_conv2d_nhwc_per_tensor_out( int64_t output_zero_point, int64_t out_multiplier, int64_t out_shift, - const ::executorch::aten::optional<::executorch::aten::Tensor>& offset, + const std::optional<::executorch::aten::Tensor>& offset, ::executorch::aten::Tensor& out); ::executorch::aten::Tensor& cat_out( diff --git a/backends/cadence/vision/operators/op_quantized_conv_out.cpp b/backends/cadence/vision/operators/op_quantized_conv_out.cpp index be4b34bff03..aaba9f5696d 100644 --- a/backends/cadence/vision/operators/op_quantized_conv_out.cpp +++ b/backends/cadence/vision/operators/op_quantized_conv_out.cpp @@ -582,7 +582,7 @@ void quantized_conv2d_nhwc_per_tensor_out( int64_t output_zero_point, int64_t out_multiplier, int64_t out_shift, - ET_UNUSED const ::executorch::aten::optional& offset, + ET_UNUSED const std::optional& offset, Tensor& out) { quantized_conv_per_tensor_out( ctx, 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 29aa8906414..c53f7f7667a 100644 --- a/backends/cadence/vision/operators/op_quantized_fully_connected_out.cpp +++ b/backends/cadence/vision/operators/op_quantized_fully_connected_out.cpp @@ -13,10 +13,10 @@ namespace impl { namespace vision { namespace native { -using ::executorch::aten::optional; using ::executorch::aten::ScalarType; using ::executorch::aten::Tensor; using ::executorch::runtime::KernelRuntimeContext; +using std::optional; void quantized_fully_connected_out( __ET_UNUSED KernelRuntimeContext& ctx, diff --git a/backends/cadence/vision/operators/op_quantized_linear_out.cpp b/backends/cadence/vision/operators/op_quantized_linear_out.cpp index b6b7cdd17bc..7b3daed8ef6 100644 --- a/backends/cadence/vision/operators/op_quantized_linear_out.cpp +++ b/backends/cadence/vision/operators/op_quantized_linear_out.cpp @@ -84,7 +84,7 @@ void quantized_linear_out( const Tensor& out_multiplier, const Tensor& out_shift, int64_t out_zero_point, - __ET_UNUSED const executorch::aten::optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { // TODO: refactor to use switch case as quantized_linear_per_tensor_out if (out.scalar_type() == executorch::aten::ScalarType::Byte) { @@ -127,7 +127,7 @@ void quantized_linear_per_tensor_out( const int64_t out_multiplier, const int64_t out_shift, const int64_t out_zero_point, - __ET_UNUSED const executorch::aten::optional& offset, + __ET_UNUSED const std::optional& offset, Tensor& out) { #define typed_quantized_linear_per_tensor(ctype, dtype) \ case executorch::aten::ScalarType::dtype: { \ diff --git a/backends/cadence/vision/operators/op_quantized_matmul_out.cpp b/backends/cadence/vision/operators/op_quantized_matmul_out.cpp index 54a303288c3..e63ae5bdda1 100644 --- a/backends/cadence/vision/operators/op_quantized_matmul_out.cpp +++ b/backends/cadence/vision/operators/op_quantized_matmul_out.cpp @@ -60,7 +60,7 @@ void inline _typed_quantized_matmul( int64_t X_zero_point, const Tensor& Y, int64_t Y_zero_point, - const executorch::aten::optional& bias, + const std::optional& bias, int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, @@ -114,7 +114,7 @@ void quantized_matmul_out( int64_t X_zero_point, const Tensor& Y, int64_t Y_zero_point, - const executorch::aten::optional& bias, + const std::optional& bias, int64_t out_multiplier, int64_t out_shift, int64_t out_zero_point, diff --git a/backends/cadence/vision/operators/op_softmax.cpp b/backends/cadence/vision/operators/op_softmax.cpp index 58ca33c6a0b..6b93709b226 100644 --- a/backends/cadence/vision/operators/op_softmax.cpp +++ b/backends/cadence/vision/operators/op_softmax.cpp @@ -50,7 +50,7 @@ Tensor& _softmax_out( // Adjust for negative dim dim = dim < 0 ? dim + executorch::runtime::nonzero_dim(in) : dim; - const executorch::aten::optional& dim_t = dim; + const std::optional& dim_t = dim; const size_t d = ET_NORMALIZE_IX(dim_t.value(), in.dim()); const size_t size = in.size(d); diff --git a/backends/cadence/vision/operators/operators.h b/backends/cadence/vision/operators/operators.h index 8b5db4161eb..1c756c0b237 100644 --- a/backends/cadence/vision/operators/operators.h +++ b/backends/cadence/vision/operators/operators.h @@ -31,7 +31,7 @@ using ::executorch::runtime::getLeadingDims; inline __attribute__((always_inline)) void linear_( const ::executorch::aten::Tensor& input, const ::executorch::aten::Tensor& weight, - const ::executorch::aten::optional<::executorch::aten::Tensor>& bias, + const std::optional<::executorch::aten::Tensor>& bias, ::executorch::aten::Tensor& output) { const float* __restrict__ input_data = input.const_data_ptr(); const float* __restrict__ weight_data = weight.const_data_ptr(); diff --git a/backends/cortex_m/ops/cmsis_scratch_buffer_context.h b/backends/cortex_m/ops/cmsis_scratch_buffer_context.h index 656309abcee..807cf18cebc 100644 --- a/backends/cortex_m/ops/cmsis_scratch_buffer_context.h +++ b/backends/cortex_m/ops/cmsis_scratch_buffer_context.h @@ -49,7 +49,7 @@ class CMSISScratchBufferContext final { Tensor& scratch_buffer, const Tensor& weights, const Tensor& weight_zero_point, - const torch::executor::optional& bias) + const std::optional& bias) : scratch_ptr_(scratch_buffer.mutable_data_ptr()), total_size_(scratch_buffer.size(0)), base_ptr_(reinterpret_cast(scratch_ptr_)), diff --git a/backends/cortex_m/ops/op_quantized_conv2d.cpp b/backends/cortex_m/ops/op_quantized_conv2d.cpp index 3d4f19e10d0..13e8b132410 100644 --- a/backends/cortex_m/ops/op_quantized_conv2d.cpp +++ b/backends/cortex_m/ops/op_quantized_conv2d.cpp @@ -19,7 +19,7 @@ bool validate_conv2d_arguments( KernelRuntimeContext& context, const Tensor& input, const Tensor& weight, - const torch::executor::optional& bias, + const std::optional& bias, const Tensor& output, const Int64ArrayRef& stride, const Int64ArrayRef& padding, @@ -103,7 +103,7 @@ Tensor& quantized_conv2d_out( KernelRuntimeContext& context, const Tensor& input, const Tensor& weight, - const torch::executor::optional& bias, + const std::optional& bias, const Int64ArrayRef stride, const Int64ArrayRef padding, const Int64ArrayRef dilation, diff --git a/backends/cortex_m/ops/op_quantized_depthwise_conv2d.cpp b/backends/cortex_m/ops/op_quantized_depthwise_conv2d.cpp index a8e1fc21ed7..0793606de44 100644 --- a/backends/cortex_m/ops/op_quantized_depthwise_conv2d.cpp +++ b/backends/cortex_m/ops/op_quantized_depthwise_conv2d.cpp @@ -19,7 +19,7 @@ bool validate_depthwise_conv2d_arguments( KernelRuntimeContext& context, const Tensor& input, const Tensor& weight, - const torch::executor::optional& bias, + const std::optional& bias, const Tensor& output, const Int64ArrayRef& stride, const Int64ArrayRef& padding, @@ -140,7 +140,7 @@ Tensor& quantized_depthwise_conv2d_out( KernelRuntimeContext& context, const Tensor& input, const Tensor& weight, - const torch::executor::optional& bias, + const std::optional& bias, const Int64ArrayRef stride, const Int64ArrayRef padding, const Int64ArrayRef dilation, diff --git a/backends/cortex_m/ops/op_quantized_linear.cpp b/backends/cortex_m/ops/op_quantized_linear.cpp index 7448058de8e..c92ec493cd5 100644 --- a/backends/cortex_m/ops/op_quantized_linear.cpp +++ b/backends/cortex_m/ops/op_quantized_linear.cpp @@ -18,8 +18,8 @@ Tensor& quantized_linear_out( KernelRuntimeContext& context, const Tensor& input, const Tensor& weights, - const torch::executor::optional& bias, - const torch::executor::optional& kernel_sum, + const std::optional& bias, + const std::optional& kernel_sum, const int64_t input_offset, const int64_t filter_offset, const int64_t output_offset, diff --git a/backends/cortex_m/ops/op_quantized_transpose_conv2d.cpp b/backends/cortex_m/ops/op_quantized_transpose_conv2d.cpp index e7ecbc7c7b4..04d57d4c693 100644 --- a/backends/cortex_m/ops/op_quantized_transpose_conv2d.cpp +++ b/backends/cortex_m/ops/op_quantized_transpose_conv2d.cpp @@ -21,7 +21,7 @@ bool validate_transpose_conv2d_arguments( KernelRuntimeContext& context, const Tensor& input, const Tensor& weight, - const torch::executor::optional& bias, + const std::optional& bias, const Tensor& output, const Tensor& requantize_multipliers, const Tensor& requantize_shifts) { @@ -88,7 +88,7 @@ Tensor& quantized_transpose_conv2d_out( KernelRuntimeContext& context, const Tensor& input, const Tensor& weight, - const torch::executor::optional& bias, + const std::optional& bias, const Int64ArrayRef stride, const Int64ArrayRef padding, const Int64ArrayRef output_padding, diff --git a/codegen/api/et_cpp.py b/codegen/api/et_cpp.py index 88f1eb83fe0..1a823b98a5b 100644 --- a/codegen/api/et_cpp.py +++ b/codegen/api/et_cpp.py @@ -278,7 +278,7 @@ def default_expr(d: str, t: Type) -> str: if isinstance(t, OptionalType): if d == "None": - return "torch::executor::nullopt" + return "std::nullopt" return default_expr(d, t.elem) diff --git a/codegen/api/types/types.py b/codegen/api/types/types.py index 712d7e5e341..07c7f7e196a 100644 --- a/codegen/api/types/types.py +++ b/codegen/api/types/types.py @@ -59,7 +59,7 @@ class OptionalCType(CType): def cpp_type(self, *, strip_ref: bool = False) -> str: # Do not pass `strip_ref` recursively. - return f"torch::executor::optional<{self.elem.cpp_type()}>" + return f"std::optional<{self.elem.cpp_type()}>" def remove_const_ref(self) -> CType: return OptionalCType(self.elem.remove_const_ref()) diff --git a/extension/aten_util/make_aten_functor_from_et_functor.h b/extension/aten_util/make_aten_functor_from_et_functor.h index 8e1c2bf0143..c7a823c26df 100644 --- a/extension/aten_util/make_aten_functor_from_et_functor.h +++ b/extension/aten_util/make_aten_functor_from_et_functor.h @@ -67,12 +67,12 @@ struct type_map final { // Optional. template -struct type_map> final { +struct type_map> final { using type = std::optional::type>; }; template -struct type_map&> final { +struct type_map&> final { using type = std::optional::type>&; }; @@ -177,7 +177,7 @@ struct type_convert< typename remove_const_ref::type::value_type>> && std::is_same_v< typename remove_const_ref::type, - torch::executor::optional< + std::optional< typename remove_const_ref::type::value_type>>>> final { public: diff --git a/extension/aten_util/test/make_aten_functor_from_et_functor_test.cpp b/extension/aten_util/test/make_aten_functor_from_et_functor_test.cpp index b76596b9963..3abc84897ce 100644 --- a/extension/aten_util/test/make_aten_functor_from_et_functor_test.cpp +++ b/extension/aten_util/test/make_aten_functor_from_et_functor_test.cpp @@ -32,8 +32,8 @@ Tensor& add_1_out(const Tensor& a, Tensor& out) { } Tensor& add_optional_scalar_out( - torch::executor::optional s1, - torch::executor::optional s2, + std::optional s1, + std::optional s2, Tensor& out) { if (s1.has_value()) { out.mutable_data_ptr()[0] += s1.value(); @@ -45,8 +45,8 @@ Tensor& add_optional_scalar_out( } Tensor& add_optional_tensor_out( - torch::executor::optional s1, - torch::executor::optional s2, + std::optional s1, + std::optional s2, Tensor& out) { if (s1.has_value()) { out.mutable_data_ptr()[0] += @@ -78,8 +78,7 @@ Tensor& sum_arrayref_tensor_out( } Tensor& sum_arrayref_optional_tensor_out( - torch::executor::ArrayRef< - torch::executor::optional> a, + torch::executor::ArrayRef> a, Tensor& out) { for (int i = 0; i < a.size(); i++) { if (a[i].has_value()) { @@ -169,20 +168,19 @@ TEST_F(MakeATenFunctorFromETFunctorTest, TestTypeMap_Tuple_TensorRef3x) { TEST_F(MakeATenFunctorFromETFunctorTest, TestTypeMap_Optionals) { // Scalar. EXPECT_TRUE((std::is_same< - type_map>::type, + type_map>::type, std::optional>::value)); // Tensor. + EXPECT_TRUE((std::is_same< + type_map>::type, + std::optional>::value)); + // ArrayRef. EXPECT_TRUE( (std::is_same< - type_map>::type, - std::optional>::value)); - // ArrayRef. - EXPECT_TRUE((std::is_same< - type_map>>::type, - std::optional>>::value)); + type_map>>::type, + std::optional>>::value)); EXPECT_TRUE((std::is_same< - type_map>>::type, std::optional>>::value)); } @@ -198,13 +196,13 @@ TEST_F(MakeATenFunctorFromETFunctorTest, TestTypeMap_ArrayRef) { type_map>::type, c10::ArrayRef>::value)); // Optionals. + EXPECT_TRUE( + (std::is_same< + type_map>>::type, + c10::ArrayRef>>::value)); EXPECT_TRUE((std::is_same< type_map>>::type, - c10::ArrayRef>>::value)); - EXPECT_TRUE((std::is_same< - type_map>>::type, + std::optional>>::type, c10::ArrayRef>>::value)); } @@ -253,17 +251,16 @@ TEST_F(MakeATenFunctorFromETFunctorTest, TestConvert_OptionalScalar) { // Convert optional at to et. auto optional_at_in = std::optional(); auto optional_et = - type_convert, torch::executor::optional>( + type_convert, std::optional>( optional_at_in) .call(); EXPECT_TRUE( - (std::is_same>:: - value)); + (std::is_same>::value)); // Convert optional et to at. - auto optional_et_in = torch::executor::optional(); + auto optional_et_in = std::optional(); auto optional_at_out = - type_convert, std::optional>( + type_convert, std::optional>( optional_et_in) .call(); EXPECT_TRUE( @@ -273,20 +270,19 @@ TEST_F(MakeATenFunctorFromETFunctorTest, TestConvert_OptionalScalar) { TEST_F(MakeATenFunctorFromETFunctorTest, TestConvert_OptionalTensor) { // Convert optional at to et. auto optional_at_in = std::optional(); - auto optional_et = - type_convert< - std::optional, - torch::executor::optional>(optional_at_in) - .call(); + auto optional_et = type_convert< + std::optional, + std::optional>(optional_at_in) + .call(); EXPECT_TRUE((std::is_same< decltype(optional_et), - torch::executor::optional>::value)); + std::optional>::value)); // Convert optional et to at. torch::executor::testing::TensorFactory tf; - auto et_in = torch::executor::optional(tf.ones({3})); + auto et_in = std::optional(tf.ones({3})); auto optional_at_out = type_convert< - torch::executor::optional, + std::optional, std::optional>(optional_et) .call(); EXPECT_TRUE( @@ -519,9 +515,8 @@ TEST_F(MakeATenFunctorFromETFunctorTest, TestConvert_ConstRefOptionals) { const std::optional const_optional_at_in = std::optional(42); auto const_optional_et = - type_convert< - const std::optional, - torch::executor::optional>(const_optional_at_in) + type_convert, std::optional>( + const_optional_at_in) .call(); EXPECT_TRUE(const_optional_et.has_value()); EXPECT_EQ(const_optional_et.value(), 42); @@ -529,7 +524,7 @@ TEST_F(MakeATenFunctorFromETFunctorTest, TestConvert_ConstRefOptionals) { // Test optional scalar reference conversion std::optional optional_at_ref_in = std::optional(24); auto optional_et_from_ref = - type_convert&, torch::executor::optional>( + type_convert&, std::optional>( optional_at_ref_in) .call(); EXPECT_TRUE(optional_et_from_ref.has_value()); @@ -539,9 +534,8 @@ TEST_F(MakeATenFunctorFromETFunctorTest, TestConvert_ConstRefOptionals) { const std::optional const_optional_at_ref_in = std::optional(84); auto const_optional_et_from_ref = - type_convert< - const std::optional&, - torch::executor::optional>(const_optional_at_ref_in) + type_convert&, std::optional>( + const_optional_at_ref_in) .call(); EXPECT_TRUE(const_optional_et_from_ref.has_value()); EXPECT_EQ(const_optional_et_from_ref.value(), 84); @@ -551,8 +545,7 @@ TEST_F(MakeATenFunctorFromETFunctorTest, TestConvert_ConstRefOptionals) { std::optional(torch::tensor({5})); auto const_optional_tensor_converter = type_convert< const std::optional, - torch::executor::optional>( - const_optional_tensor_at_in); + std::optional>(const_optional_tensor_at_in); auto const_optional_tensor_et = const_optional_tensor_converter.call(); EXPECT_TRUE(const_optional_tensor_et.has_value()); EXPECT_EQ(const_optional_tensor_et.value().const_data_ptr()[0], 5); @@ -562,8 +555,7 @@ TEST_F(MakeATenFunctorFromETFunctorTest, TestConvert_ConstRefOptionals) { std::optional(torch::tensor({7})); auto optional_tensor_converter_from_ref = type_convert< std::optional&, - torch::executor::optional>( - optional_tensor_at_ref_in); + std::optional>(optional_tensor_at_ref_in); auto optional_tensor_et_from_ref = optional_tensor_converter_from_ref.call(); EXPECT_TRUE(optional_tensor_et_from_ref.has_value()); EXPECT_EQ( @@ -574,8 +566,7 @@ TEST_F(MakeATenFunctorFromETFunctorTest, TestConvert_ConstRefOptionals) { std::optional(torch::tensor({9})); auto const_optional_tensor_converter_from_ref = type_convert< const std::optional&, - torch::executor::optional>( - const_optional_tensor_at_ref_in); + std::optional>(const_optional_tensor_at_ref_in); auto const_optional_tensor_et_from_ref = const_optional_tensor_converter_from_ref.call(); EXPECT_TRUE(const_optional_tensor_et_from_ref.has_value()); @@ -586,9 +577,8 @@ TEST_F(MakeATenFunctorFromETFunctorTest, TestConvert_ConstRefOptionals) { // Test empty const optional conversions const std::optional empty_const_optional_at_in = std::nullopt; auto empty_const_optional_et = - type_convert< - const std::optional, - torch::executor::optional>(empty_const_optional_at_in) + type_convert, std::optional>( + empty_const_optional_at_in) .call(); EXPECT_FALSE(empty_const_optional_et.has_value()); @@ -597,7 +587,7 @@ TEST_F(MakeATenFunctorFromETFunctorTest, TestConvert_ConstRefOptionals) { auto empty_const_optional_tensor_et = type_convert< const std::optional, - torch::executor::optional>( + std::optional>( empty_const_optional_tensor_at_in) .call(); EXPECT_FALSE(empty_const_optional_tensor_et.has_value()); diff --git a/extension/flat_tensor/flat_tensor_data_map.cpp b/extension/flat_tensor/flat_tensor_data_map.cpp index 845778f45c2..342e29e63fc 100644 --- a/extension/flat_tensor/flat_tensor_data_map.cpp +++ b/extension/flat_tensor/flat_tensor_data_map.cpp @@ -49,7 +49,7 @@ bool is_aligned(const void* data) { } Result get_named_data( - executorch::aten::string_view key, + std::string_view key, const flatbuffers::Vector< flatbuffers::Offset>* named_data, const flatbuffers::Vector< @@ -127,7 +127,7 @@ Result create_tensor_layout( } // namespace ET_NODISCARD Result FlatTensorDataMap::get_tensor_layout( - executorch::aten::string_view key) const { + std::string_view key) const { Result segment_end_offset = get_segment_end_offset(header_); if (!segment_end_offset.ok()) { return segment_end_offset.error(); @@ -144,7 +144,7 @@ ET_NODISCARD Result FlatTensorDataMap::get_tensor_layout( } ET_NODISCARD Result FlatTensorDataMap::get_data( - executorch::aten::string_view key) const { + std::string_view key) const { Result segment_end_offset = get_segment_end_offset(header_); if (!segment_end_offset.ok()) { return segment_end_offset.error(); @@ -170,7 +170,7 @@ ET_NODISCARD Result FlatTensorDataMap::get_data( } ET_NODISCARD Error FlatTensorDataMap::load_data_into( - ET_UNUSED executorch::aten::string_view key, + ET_UNUSED std::string_view key, ET_UNUSED void* buffer, ET_UNUSED size_t size) const { Result segment_end_offset = get_segment_end_offset(header_); diff --git a/extension/flat_tensor/flat_tensor_data_map.h b/extension/flat_tensor/flat_tensor_data_map.h index 751e312f7ef..7b66eeab470 100644 --- a/extension/flat_tensor/flat_tensor_data_map.h +++ b/extension/flat_tensor/flat_tensor_data_map.h @@ -54,7 +54,7 @@ class FlatTensorDataMap final ET_NODISCARD executorch::runtime::Result< const executorch::ET_RUNTIME_NAMESPACE::TensorLayout> - get_tensor_layout(executorch::aten::string_view key) const override; + get_tensor_layout(std::string_view key) const override; /** * Retrieve read-only data for the specified key. @@ -65,7 +65,7 @@ class FlatTensorDataMap final */ ET_NODISCARD executorch::runtime::Result get_data( - executorch::aten::string_view key) const override; + std::string_view key) const override; /** * Loads the data of the specified tensor into the provided buffer. @@ -78,7 +78,7 @@ class FlatTensorDataMap final * @returns an Error indicating if the load was successful. */ ET_NODISCARD executorch::runtime::Error load_data_into( - executorch::aten::string_view key, + std::string_view key, void* buffer, size_t size) const override; diff --git a/extension/named_data_map/merged_data_map.cpp b/extension/named_data_map/merged_data_map.cpp index 630395e006c..d76f741fbf4 100644 --- a/extension/named_data_map/merged_data_map.cpp +++ b/extension/named_data_map/merged_data_map.cpp @@ -12,13 +12,13 @@ #include #include -using executorch::aten::string_view; using executorch::ET_RUNTIME_NAMESPACE::NamedDataMap; using executorch::ET_RUNTIME_NAMESPACE::TensorLayout; 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 { diff --git a/extension/named_data_map/merged_data_map.h b/extension/named_data_map/merged_data_map.h index 42490ec3d58..cc291b4d093 100644 --- a/extension/named_data_map/merged_data_map.h +++ b/extension/named_data_map/merged_data_map.h @@ -48,7 +48,7 @@ class MergedDataMap final ET_NODISCARD executorch::runtime::Result< const executorch::ET_RUNTIME_NAMESPACE::TensorLayout> - get_tensor_layout(executorch::aten::string_view key) const override; + get_tensor_layout(std::string_view key) const override; /** * Retrieve read-only data for the specified key. @@ -59,7 +59,7 @@ class MergedDataMap final */ ET_NODISCARD executorch::runtime::Result get_data( - executorch::aten::string_view key) const override; + std::string_view key) const override; /** * Loads the data of the specified tensor into the provided buffer. @@ -72,7 +72,7 @@ class MergedDataMap final * @returns an Error indicating if the load was successful. */ ET_NODISCARD executorch::runtime::Error load_data_into( - executorch::aten::string_view key, + std::string_view key, void* buffer, size_t size) const override; diff --git a/kernels/portable/cpu/op_index_put.cpp b/kernels/portable/cpu/op_index_put.cpp index 812d3e8fab3..519842db598 100644 --- a/kernels/portable/cpu/op_index_put.cpp +++ b/kernels/portable/cpu/op_index_put.cpp @@ -19,8 +19,7 @@ namespace executor { namespace native { using Tensor = executorch::aten::Tensor; -using TensorOptList = - executorch::aten::ArrayRef>; +using TensorOptList = executorch::aten::ArrayRef>; Tensor& index_put_out( KernelRuntimeContext& ctx, diff --git a/kernels/portable/cpu/op_native_dropout.cpp b/kernels/portable/cpu/op_native_dropout.cpp index fae7928568d..dc72fb54599 100644 --- a/kernels/portable/cpu/op_native_dropout.cpp +++ b/kernels/portable/cpu/op_native_dropout.cpp @@ -17,7 +17,7 @@ std::tuple native_dropout_out( KernelRuntimeContext& ctx, const Tensor& input, double prob, - torch::executor::optional train, + std::optional train, Tensor& out, Tensor& mask) { std::tuple ret(out, mask); diff --git a/kernels/test/op_native_dropout_test.cpp b/kernels/test/op_native_dropout_test.cpp index 931205f54a5..fec00c87862 100644 --- a/kernels/test/op_native_dropout_test.cpp +++ b/kernels/test/op_native_dropout_test.cpp @@ -25,7 +25,7 @@ class OpNativeDropoutTest : public OperatorTest { void op_native_dropout_out( const Tensor& self, double prob, - executorch::aten::optional train, + std::optional train, Tensor& out, Tensor& mask) { torch::executor::aten::native_dropout_outf( diff --git a/runtime/core/exec_aten/exec_aten.h b/runtime/core/exec_aten/exec_aten.h index f539414aec9..bdac41ba509 100644 --- a/runtime/core/exec_aten/exec_aten.h +++ b/runtime/core/exec_aten/exec_aten.h @@ -8,6 +8,9 @@ #pragma once +#include +#include + #include // @manual #include // @manual #include // @manual @@ -41,11 +44,9 @@ #include // @manual #include // @manual #include // @manual -#include // @manual #include // @manual #include // @manual #include // @manual -#include // @manual #include // @manual #include // @manual @@ -183,8 +184,7 @@ using quint2x4 = torch::executor::quint2x4; using IntArrayRef = torch::executor::IntArrayRef; template -using OptionalArrayRef = - torch::executor::optional>; +using OptionalArrayRef = std::optional>; using OptionalIntArrayRef = OptionalArrayRef; using torch::executor::compute_numel; diff --git a/runtime/core/exec_aten/util/scalar_type_util.h b/runtime/core/exec_aten/util/scalar_type_util.h index f48b50a0786..10b6ed2c6ac 100644 --- a/runtime/core/exec_aten/util/scalar_type_util.h +++ b/runtime/core/exec_aten/util/scalar_type_util.h @@ -47,11 +47,11 @@ using ScalarType = at::ScalarType; } // namespace executorch #else // !USE_ATEN_LIB #include -#include +#include namespace executorch { namespace aten { using ScalarType = torch::executor::ScalarType; -using string_view = torch::executor::string_view; +using string_view = std::string_view; } // namespace aten } // namespace executorch #endif // USE_ATEN_LIB diff --git a/runtime/core/named_data_map.h b/runtime/core/named_data_map.h index c6b6aa4bb7b..dbd5b21a66f 100644 --- a/runtime/core/named_data_map.h +++ b/runtime/core/named_data_map.h @@ -31,7 +31,7 @@ class NamedDataMap { * @return Result containing TensorLayout. */ ET_NODISCARD virtual Result get_tensor_layout( - executorch::aten::string_view key) const = 0; + std::string_view key) const = 0; /** * Get data by key. * @@ -39,7 +39,7 @@ class NamedDataMap { * @return Result containing a FreeableBuffer. */ ET_NODISCARD virtual Result get_data( - executorch::aten::string_view key) const = 0; + std::string_view key) const = 0; /** * Loads data corresponding to the key into the provided buffer. @@ -51,10 +51,8 @@ class NamedDataMap { * `size` bytes of memory. * @returns an Error indicating if the load was successful. */ - ET_NODISCARD virtual Error load_data_into( - executorch::aten::string_view key, - void* buffer, - size_t size) const = 0; + ET_NODISCARD virtual Error + load_data_into(std::string_view key, void* buffer, size_t size) const = 0; /** * Get the number of keys in the NamedDataMap. diff --git a/runtime/core/portable_type/optional.h b/runtime/core/portable_type/optional.h deleted file mode 100644 index 31ad06fd093..00000000000 --- a/runtime/core/portable_type/optional.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include - -namespace executorch { -namespace runtime { -namespace etensor { - -// NOLINTNEXTLINE(misc-unused-using-decls) -using std::nullopt; -// NOLINTNEXTLINE(misc-unused-using-decls) -using std::nullopt_t; -// NOLINTNEXTLINE(misc-unused-using-decls) -using std::optional; - -} // namespace etensor -} // namespace runtime -} // namespace executorch - -namespace torch { -namespace executor { -// TODO(T197294990): Remove these deprecated aliases once all users have moved -// to the new `::executorch` namespaces. -using ::executorch::runtime::etensor::nullopt; -using ::executorch::runtime::etensor::nullopt_t; -using ::executorch::runtime::etensor::optional; -} // namespace executor -} // namespace torch diff --git a/runtime/core/portable_type/string_view.h b/runtime/core/portable_type/string_view.h deleted file mode 100644 index 8e28fa022cc..00000000000 --- a/runtime/core/portable_type/string_view.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include - -namespace executorch { -namespace runtime { -namespace etensor { - -using std::string_view; - -} // namespace etensor -} // namespace runtime -} // namespace executorch - -namespace torch { -namespace executor { -// TODO(T197294990): Remove these deprecated aliases once all users have moved -// to the new `::executorch` namespaces. -using ::executorch::runtime::etensor::string_view; -} // namespace executor -} // namespace torch diff --git a/runtime/core/portable_type/targets.bzl b/runtime/core/portable_type/targets.bzl index 0a368bd6379..bfa2ecd2a30 100644 --- a/runtime/core/portable_type/targets.bzl +++ b/runtime/core/portable_type/targets.bzl @@ -14,11 +14,9 @@ def define_common_targets(): srcs = ["tensor_impl.cpp"], exported_headers = [ "tensor_options.h", - "optional.h", "scalar.h", "tensor.h", "tensor_impl.h", - "string_view.h", "device.h", ], # Only should be depended on by kernel_types:kernel_types, but various suffixes like Android and Static diff --git a/runtime/core/portable_type/test/CMakeLists.txt b/runtime/core/portable_type/test/CMakeLists.txt index b1f57a93ab5..8aa27d4d877 100644 --- a/runtime/core/portable_type/test/CMakeLists.txt +++ b/runtime/core/portable_type/test/CMakeLists.txt @@ -23,7 +23,6 @@ set(_test_srcs bfloat16_test.cpp dont_shadow_complex_test.c half_test.cpp - optional_test.cpp scalar_test.cpp tensor_impl_test.cpp tensor_test.cpp diff --git a/runtime/core/portable_type/test/optional_test.cpp b/runtime/core/portable_type/test/optional_test.cpp deleted file mode 100644 index 60d835d7439..00000000000 --- a/runtime/core/portable_type/test/optional_test.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include - -#include -#include - -#include -#include - -using namespace ::testing; -using executorch::runtime::etensor::nullopt; -using executorch::runtime::etensor::optional; - -// Test that optional::value_type matches the template parameter type. -static_assert( - std::is_same::value_type, int32_t>::value, - "Unexpected optional::value_type"); -static_assert( - std::is_same::value_type, std::string>::value, - "Unexpected optional::value_type"); - -TEST(TestOptional, DefaultHasNoValue) { - optional o; - EXPECT_FALSE(o.has_value()); -} - -TEST(TestOptional, NulloptHasNoValue) { - optional o(nullopt); - EXPECT_FALSE(o.has_value()); -} - -TEST(TestOptional, ValueOfEmptyOptionalShouldThrow) { - optional o; - EXPECT_FALSE(o.has_value()); - - EXPECT_THROW({ (void)o.value(); }, std::bad_optional_access); -} - -TEST(TestOptional, IntValue) { - optional o(15); - EXPECT_TRUE(o.has_value()); - EXPECT_EQ(o.value(), 15); -} - -TEST(TestOptional, NonTrivialValueType) { - optional o("hey"); - EXPECT_TRUE(o.has_value()); - EXPECT_EQ(o.value(), "hey"); -} - -TEST(TestOptional, ConstValue) { - const optional o("hey"); - auto s = o.value(); // If this compiles, we're good. - EXPECT_EQ(o.value(), "hey"); -} - -TEST(TestOptional, CopyCtorWithValue) { - optional o1(15); - optional o2(o1); - - EXPECT_TRUE(o2.has_value()); - EXPECT_EQ(o2.value(), 15); -} - -TEST(TestOptional, CopyCtorWithNoValue) { - optional o1; - optional o2(o1); - - EXPECT_FALSE(o2.has_value()); -} - -TEST(TestOptional, CopyAssignTrivial) { - optional o1(1); - optional o2(2); - o1 = o2; - - EXPECT_EQ(o1.value(), 2); -} - -TEST(TestOptional, CopyAssignNonTrivial) { - optional o1("abcde"); - optional o2("foo"); - o1 = o2; - - EXPECT_EQ(o1.value(), "foo"); -} - -TEST(TestOptional, CopyAssignNone) { - optional o1(2); - optional o2; - o1 = o2; - EXPECT_FALSE(o1.has_value()); -} - -TEST(TestOptional, MoveCtorWithNoValue) { - optional o1; - optional o2(std::move(o1)); - - EXPECT_FALSE(o2.has_value()); -} - -TEST(TestOptional, MoveCtorWithValue) { - optional o1(15); - optional o2(std::move(o1)); - - EXPECT_TRUE(o2.has_value()); - EXPECT_EQ(o2.value(), 15); -} - -TEST(TestOptional, MoveCtorNonTrivialType) { - optional o1("abc"); - optional o2(std::move(o1)); - - EXPECT_TRUE(o2.has_value()); - EXPECT_EQ(o2.value(), "abc"); -} - -optional function_returning_optional_of(int32_t value) { - return value; -} - -TEST(TestOptional, ImplicitReturnOfValue) { - auto o = function_returning_optional_of(21); - EXPECT_TRUE(o.has_value()); - EXPECT_EQ(o.value(), 21); -} - -optional function_returning_nullopt() { - return nullopt; -} - -TEST(TestOptional, ImplicitReturnOfNullopt) { - auto o = function_returning_nullopt(); - EXPECT_FALSE(o.has_value()); -} diff --git a/runtime/core/portable_type/test/targets.bzl b/runtime/core/portable_type/test/targets.bzl index a6671d7d400..ce831f89327 100644 --- a/runtime/core/portable_type/test/targets.bzl +++ b/runtime/core/portable_type/test/targets.bzl @@ -15,14 +15,6 @@ def define_common_targets(): ], ) - runtime.cxx_test( - name = "optional_test", - srcs = ["optional_test.cpp"], - deps = [ - "//executorch/runtime/core/portable_type:portable_type", - ], - ) - runtime.cxx_test( name = "tensor_test", srcs = ["tensor_test.cpp"], diff --git a/runtime/executor/merged_data_map.h b/runtime/executor/merged_data_map.h index d5ae97057f2..aae92d90a9b 100644 --- a/runtime/executor/merged_data_map.h +++ b/runtime/executor/merged_data_map.h @@ -57,7 +57,7 @@ class MergedDataMap final : public NamedDataMap { */ ET_NODISCARD Result get_tensor_layout( - executorch::aten::string_view key) const override { + std::string_view key) const override { auto layout = first_->get_tensor_layout(key); if (layout.ok()) { return layout.get(); @@ -76,8 +76,7 @@ class MergedDataMap final : public NamedDataMap { * @return error if the key is not present or data cannot be loaded. */ ET_NODISCARD - Result get_data( - executorch::aten::string_view key) const override { + Result get_data(std::string_view key) const override { auto data = first_->get_data(key); if (data.error() != Error::NotFound) { return data; @@ -97,7 +96,7 @@ class MergedDataMap final : public NamedDataMap { * @returns an Error indicating if the load was successful. */ ET_NODISCARD Error load_data_into( - ET_UNUSED executorch::aten::string_view key, + ET_UNUSED std::string_view key, ET_UNUSED void* buffer, ET_UNUSED size_t size) const override { return Error::NotImplemented; diff --git a/runtime/executor/pte_data_map.cpp b/runtime/executor/pte_data_map.cpp index 881bfd5165a..e35745e7689 100644 --- a/runtime/executor/pte_data_map.cpp +++ b/runtime/executor/pte_data_map.cpp @@ -26,8 +26,7 @@ namespace internal { } ET_NODISCARD -Result PteDataMap::get_data( - executorch::aten::string_view key) const { +Result PteDataMap::get_data(std::string_view key) const { for (uint32_t i = 0; i < named_data_->size(); i++) { const auto* named_data_item = named_data_->Get(i); ET_CHECK_OR_RETURN_ERROR( diff --git a/runtime/executor/pte_data_map.h b/runtime/executor/pte_data_map.h index b4b46a6b541..36d33ae3945 100644 --- a/runtime/executor/pte_data_map.h +++ b/runtime/executor/pte_data_map.h @@ -79,7 +79,7 @@ class PteDataMap final : public NamedDataMap { */ ET_NODISCARD Result get_tensor_layout( - ET_UNUSED executorch::aten::string_view key) const override { + ET_UNUSED std::string_view key) const override { return Error::NotImplemented; } @@ -91,14 +91,13 @@ class PteDataMap final : public NamedDataMap { * @return error if the key is not present or data cannot be loaded. */ ET_NODISCARD - Result get_data( - executorch::aten::string_view key) const override; + Result get_data(std::string_view key) const override; /** * The PteDataMap currently does not implement load_into. */ ET_NODISCARD Error load_data_into( - ET_UNUSED executorch::aten::string_view key, + ET_UNUSED std::string_view key, ET_UNUSED void* buffer, ET_UNUSED size_t size) const override { return Error::NotImplemented; diff --git a/runtime/executor/test/method_meta_test.cpp b/runtime/executor/test/method_meta_test.cpp index a1991a0562c..1324a40cf52 100644 --- a/runtime/executor/test/method_meta_test.cpp +++ b/runtime/executor/test/method_meta_test.cpp @@ -38,7 +38,7 @@ class TensorInfoTestFriend final { Span dim_order, executorch::aten::ScalarType scalar_type, const bool is_memory_planned, - executorch::aten::string_view name) { + std::string_view name) { return TensorInfo::create( Span(sizes.data(), sizes.size()), Span(dim_order.data(), dim_order.size()), @@ -236,7 +236,7 @@ TEST_F(MethodMetaTest, TensorInfoSizeOverflow) { Span(dim_order.data(), dim_order.size()), executorch::aten::ScalarType::Float, false, // is_memory_planned - executorch::aten::string_view{nullptr, 0}), + std::string_view{nullptr, 0}), ""); } diff --git a/test/utils/OSSTestConfig.json b/test/utils/OSSTestConfig.json index c0877aac924..d7d0cb08567 100644 --- a/test/utils/OSSTestConfig.json +++ b/test/utils/OSSTestConfig.json @@ -75,7 +75,6 @@ "bfloat16_test.cpp", "dont_shadow_complex_test.c", "half_test.cpp", - "optional_test.cpp", "scalar_test.cpp", "tensor_impl_test.cpp", "tensor_test.cpp"