Skip to content

Commit e693340

Browse files
committed
More fixes
Signed-off-by: Yuanyuan Chen <[email protected]>
1 parent 1734ec5 commit e693340

13 files changed

+111
-122
lines changed

codegen/api/et_cpp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def return_names(f: NativeFunction, *, fallback_name: str = "result") -> Sequenc
243243
JIT_TO_CPP_DEFAULT = {
244244
"False": "false",
245245
"True": "true",
246-
"None": "torch::execustd::nullopt", # UGH this one is type directed
246+
"None": "std::nullopt", # UGH this one is type directed
247247
"[]": "{}",
248248
"contiguous_format": "torch::executorch::MemoryFormat::Contiguous",
249249
"long": "torch::executorch::kLong",
@@ -278,7 +278,7 @@ def default_expr(d: str, t: Type) -> str:
278278

279279
if isinstance(t, OptionalType):
280280
if d == "None":
281-
return "torch::executor::nullopt"
281+
return "std::nullopt"
282282

283283
return default_expr(d, t.elem)
284284

kernels/aten/cpu/op__clone_dim_order.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ using Optional = std::optional<T>;
2828
namespace {
2929
Optional<MemoryFormat> get_memory_format(OptionalArrayRef<int64_t> dim_order) {
3030
if (!dim_order.has_value()) {
31-
return executorch::aten::nullopt;
31+
return std::nullopt;
3232
}
3333
if (is_contiguous_dim_order(
3434
dim_order.value().data(), dim_order.value().size())) {

kernels/aten/cpu/op__to_dim_order_copy.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ using MemoryFormat = executorch::aten::MemoryFormat;
2222
template <typename T>
2323
using OptionalArrayRef = executorch::aten::OptionalArrayRef<T>;
2424

25-
template <typename T>
26-
using Optional = std::optional<T>;
27-
2825
namespace {
29-
Optional<MemoryFormat> get_memory_format(OptionalArrayRef<int64_t> dim_order) {
26+
std::optional<MemoryFormat> get_memory_format(
27+
OptionalArrayRef<int64_t> dim_order) {
3028
if (!dim_order.has_value()) {
31-
return executorch::aten::nullopt;
29+
return std::nullopt;
3230
}
3331
if (is_contiguous_dim_order(
3432
dim_order.value().data(), dim_order.value().size())) {
@@ -105,7 +103,7 @@ Tensor& _to_dim_order_copy_out(
105103
InvalidArgument,
106104
out);
107105

108-
Optional<MemoryFormat> memory_format = get_memory_format(dim_order);
106+
std::optional<MemoryFormat> memory_format = get_memory_format(dim_order);
109107
at::_to_copy_outf(self, non_blocking, memory_format, out);
110108

111109
return out;

kernels/test/op__clone_dim_order_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ TEST_F(OpDimOrderCloneTest, PreserveChannelsLast) {
354354
Tensor ret = op__clone_dim_order_out(
355355
/*self*/ x,
356356
/*non_blocking*/ false,
357-
/*dim_order*/ executorch::aten::nullopt,
357+
/*dim_order*/ std::nullopt,
358358
out);
359359

360360
EXPECT_TENSOR_EQ(out, expected);

kernels/test/op__to_dim_order_copy_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ TEST_F(OpToDimOrderCopyTest, PreserveChanneslLast) {
653653
Tensor ret = op__to_dim_order_copy_out(
654654
/*self*/ x,
655655
/*non_blocking*/ false,
656-
/*dim_order*/ executorch::aten::nullopt,
656+
/*dim_order*/ std::nullopt,
657657
out);
658658

659659
EXPECT_TENSOR_EQ(out, expected);

kernels/test/op_clamp_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323
using namespace ::testing;
2424
using executorch::aten::ArrayRef;
25-
using executorch::aten::nullopt;
2625
using executorch::aten::Scalar;
2726
using executorch::aten::ScalarType;
2827
using executorch::aten::Tensor;
29-
using std::optional;
28+
using ::std::nullopt;
29+
using ::std::optional;
3030
using torch::executor::testing::TensorFactory;
3131

3232
using OptScalar = std::optional<Scalar>;

kernels/test/op_clone_test.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class OpCloneTest : public OperatorTest {
4444
// nullopt or MemoryFormat::Contiguous.
4545
Tensor out_nullopt_ret = op_clone_out(
4646
/*self=*/input,
47-
/*memory_format=*/executorch::aten::nullopt,
47+
/*memory_format=*/std::nullopt,
4848
/*out=*/out_nullopt);
4949
Tensor out_contiguous_ret = op_clone_out(
5050
/*self=*/input,
@@ -65,7 +65,7 @@ class OpCloneTest : public OperatorTest {
6565
TensorFactory<DTYPE> tf;
6666
Tensor input = tf.make(/*sizes=*/{3, 0, 1, 2}, /*data=*/{});
6767
Tensor out = tf.zeros({3, 0, 1, 2});
68-
op_clone_out(input, /*memory_format=*/executorch::aten::nullopt, out);
68+
op_clone_out(input, /*memory_format=*/std::nullopt, out);
6969
// check a and out share same value, but are different object
7070
EXPECT_TENSOR_EQ(input, out);
7171
}
@@ -95,8 +95,7 @@ TEST_F(OpCloneTest, MismatchedSizesDie) {
9595
Tensor input = tf.make(/*sizes=*/{3, 1, 1, 2}, /*data=*/{1, 2, 3, 4, 5, 6});
9696
Tensor out = tf.zeros({3, 2, 1, 1});
9797
ET_EXPECT_KERNEL_FAILURE(
98-
context_,
99-
op_clone_out(input, /*memory_format=*/executorch::aten::nullopt, out));
98+
context_, op_clone_out(input, /*memory_format=*/std::nullopt, out));
10099
}
101100

102101
TEST_F(OpCloneTest, MismatchedTypesDie) {
@@ -106,8 +105,7 @@ TEST_F(OpCloneTest, MismatchedTypesDie) {
106105
tf_in.make(/*sizes=*/{3, 1, 1, 2}, /*data=*/{1, 2, 3, 4, 5, 6});
107106
Tensor out = tf_out.zeros({3, 1, 1, 2});
108107
ET_EXPECT_KERNEL_FAILURE(
109-
context_,
110-
op_clone_out(input, /*memory_format=*/executorch::aten::nullopt, out));
108+
context_, op_clone_out(input, /*memory_format=*/std::nullopt, out));
111109
}
112110

113111
// Only contiguous memory is supported, the memory type other than nullopt or

kernels/test/op_native_layer_norm_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
using namespace ::testing;
2424
using executorch::aten::ArrayRef;
2525
using executorch::aten::IntArrayRef;
26-
using executorch::aten::nullopt;
2726
using executorch::aten::Scalar;
2827
using executorch::aten::ScalarType;
2928
using executorch::aten::Tensor;
29+
using std::nullopt;
3030
using std::optional;
3131
using torch::executor::testing::TensorFactory;
3232

kernels/test/op_slice_copy_test.cpp

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -217,21 +217,20 @@ TEST_F(OpSliceCopyTensorOutTest, AllStartValsSupported) {
217217
// The result shall equal to input[:, 3:3:1, :], which is an empty tensor
218218
Tensor expected_start_3_or_above = tf.make({2, 0, 4}, {});
219219
// clang-format on
220-
std::vector<Tensor> expected_rets = {
221-
// start = -3
222-
expected_start_0_or_below,
223-
// start = -2
224-
expected_start_1,
225-
// start = -1
226-
expected_start_2,
227-
// start = 0
228-
expected_start_0_or_below,
229-
// start = 1
230-
expected_start_1,
231-
// start = 2
232-
expected_start_2,
233-
// start = 3
234-
expected_start_3_or_above};
220+
std::vector<Tensor> expected_rets = {// start = -3
221+
expected_start_0_or_below,
222+
// start = -2
223+
expected_start_1,
224+
// start = -1
225+
expected_start_2,
226+
// start = 0
227+
expected_start_0_or_below,
228+
// start = 1
229+
expected_start_1,
230+
// start = 2
231+
expected_start_2,
232+
// start = 3
233+
expected_start_3_or_above};
235234

236235
// In this test, we maintain dim and step as 1 and 1, also set the end
237236
// large enough to hold any start
@@ -316,21 +315,20 @@ TEST_F(OpSliceCopyTensorOutTest, AllEndValsSupported) {
316315
-9., -10., -11., -12., // [1, 2, :]
317316
});
318317
// clang-format on
319-
std::vector<Tensor> expected_rets = {
320-
// end = -3
321-
expected_end_0_or_below,
322-
// end = -2
323-
expected_end_1,
324-
// end = -1
325-
expected_end_2,
326-
// end = 0
327-
expected_end_0_or_below,
328-
// end = 1
329-
expected_end_1,
330-
// end = 2
331-
expected_end_2,
332-
// end = 3
333-
expected_end_3_or_above};
318+
std::vector<Tensor> expected_rets = {// end = -3
319+
expected_end_0_or_below,
320+
// end = -2
321+
expected_end_1,
322+
// end = -1
323+
expected_end_2,
324+
// end = 0
325+
expected_end_0_or_below,
326+
// end = 1
327+
expected_end_1,
328+
// end = 2
329+
expected_end_2,
330+
// end = 3
331+
expected_end_3_or_above};
334332

335333
int64_t dim = 1;
336334
int64_t start = 0;
@@ -570,7 +568,7 @@ TEST_F(OpSliceCopyTensorOutTest, DefaultStartValSupported) {
570568
Tensor ret_default_start = op_slice_copy_tensor_out(
571569
input,
572570
/*dim=*/0,
573-
/*start=*/executorch::aten::nullopt,
571+
/*start=*/std::nullopt,
574572
/*end=*/2,
575573
/*step=*/1,
576574
out);
@@ -590,7 +588,7 @@ TEST_F(OpSliceCopyTensorOutTest, DefaultEndValSupported) {
590588
input,
591589
/*dim=*/0,
592590
/*start=*/0,
593-
/*end=*/executorch::aten::nullopt,
591+
/*end=*/std::nullopt,
594592
/*step=*/1,
595593
out);
596594
EXPECT_TENSOR_EQ(ret_default_end, out);

kernels/test/op_slice_scatter_test.cpp

Lines changed: 60 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -332,36 +332,34 @@ TEST_F(OpSliceScatterTensorOutTest, AllStartValsSupported) {
332332
});
333333
// clang-format on
334334

335-
std::vector<Tensor> src_tensors = {
336-
// start = -3
337-
src_start_0_or_below,
338-
// start = -2
339-
src_start_1,
340-
// start = -1
341-
src_start_2,
342-
// start = 0
343-
src_start_0_or_below,
344-
// start = 1
345-
src_start_1,
346-
// start = 2
347-
src_start_2,
348-
// start = 3
349-
src_start_3_or_above};
350-
std::vector<Tensor> expected_rets = {
351-
// start = -3
352-
expected_start_0_or_below,
353-
// start = -2
354-
expected_start_1,
355-
// start = -1
356-
expected_start_2,
357-
// start = 0
358-
expected_start_0_or_below,
359-
// start = 1
360-
expected_start_1,
361-
// start = 2
362-
expected_start_2,
363-
// start = 3
364-
expected_start_3_or_above};
335+
std::vector<Tensor> src_tensors = {// start = -3
336+
src_start_0_or_below,
337+
// start = -2
338+
src_start_1,
339+
// start = -1
340+
src_start_2,
341+
// start = 0
342+
src_start_0_or_below,
343+
// start = 1
344+
src_start_1,
345+
// start = 2
346+
src_start_2,
347+
// start = 3
348+
src_start_3_or_above};
349+
std::vector<Tensor> expected_rets = {// start = -3
350+
expected_start_0_or_below,
351+
// start = -2
352+
expected_start_1,
353+
// start = -1
354+
expected_start_2,
355+
// start = 0
356+
expected_start_0_or_below,
357+
// start = 1
358+
expected_start_1,
359+
// start = 2
360+
expected_start_2,
361+
// start = 3
362+
expected_start_3_or_above};
365363

366364
// In this test, we maintain dim and step as 1 and 1, also set the end
367365
// large enough to hold any start
@@ -500,37 +498,35 @@ TEST_F(OpSliceScatterTensorOutTest, AllEndValsSupported) {
500498
});
501499
// clang-format on
502500

503-
std::vector<Tensor> src_tensors = {
504-
// end = -3
505-
src_end_0_or_below,
506-
// end = -2
507-
src_end_1,
508-
// end = -1
509-
src_end_2,
510-
// end = 0
511-
src_end_0_or_below,
512-
// end = 1
513-
src_end_1,
514-
// end = 2
515-
src_end_2,
516-
// end = 3
517-
src_end_3_or_above};
518-
519-
std::vector<Tensor> expected_rets = {
520-
// end = -3
521-
expected_end_0_or_below,
522-
// end = -2
523-
expected_end_1,
524-
// end = -1
525-
expected_end_2,
526-
// end = 0
527-
expected_end_0_or_below,
528-
// end = 1
529-
expected_end_1,
530-
// end = 2
531-
expected_end_2,
532-
// end = 3
533-
expected_end_3_or_above};
501+
std::vector<Tensor> src_tensors = {// end = -3
502+
src_end_0_or_below,
503+
// end = -2
504+
src_end_1,
505+
// end = -1
506+
src_end_2,
507+
// end = 0
508+
src_end_0_or_below,
509+
// end = 1
510+
src_end_1,
511+
// end = 2
512+
src_end_2,
513+
// end = 3
514+
src_end_3_or_above};
515+
516+
std::vector<Tensor> expected_rets = {// end = -3
517+
expected_end_0_or_below,
518+
// end = -2
519+
expected_end_1,
520+
// end = -1
521+
expected_end_2,
522+
// end = 0
523+
expected_end_0_or_below,
524+
// end = 1
525+
expected_end_1,
526+
// end = 2
527+
expected_end_2,
528+
// end = 3
529+
expected_end_3_or_above};
534530

535531
int64_t dim = 1;
536532
int64_t start = 0;
@@ -817,7 +813,7 @@ TEST_F(OpSliceScatterTensorOutTest, DefaultStartValSupported) {
817813
input,
818814
src,
819815
/*dim=*/0,
820-
/*start=*/executorch::aten::nullopt,
816+
/*start=*/std::nullopt,
821817
/*end=*/2,
822818
/*step=*/1,
823819
out);
@@ -839,7 +835,7 @@ TEST_F(OpSliceScatterTensorOutTest, DefaultEndValSupported) {
839835
src,
840836
/*dim=*/0,
841837
/*start=*/0,
842-
/*end=*/executorch::aten::nullopt,
838+
/*end=*/std::nullopt,
843839
/*step=*/1,
844840
out);
845841
EXPECT_TENSOR_EQ(ret_default_end, out);
@@ -861,7 +857,7 @@ TEST_F(OpSliceScatterTensorOutTest, DynamicShapeTest) {
861857
src,
862858
/*dim=*/0,
863859
/*start=*/0,
864-
/*end=*/executorch::aten::nullopt,
860+
/*end=*/std::nullopt,
865861
/*step=*/1,
866862
out);
867863
EXPECT_TENSOR_EQ(ret_default_end, out);

0 commit comments

Comments
 (0)