@@ -26,8 +26,8 @@ struct evalue_to_const_ref_overload_return {
26
26
};
27
27
28
28
template <>
29
- struct evalue_to_const_ref_overload_return <exec_aten ::Tensor> {
30
- using type = const exec_aten ::Tensor&;
29
+ struct evalue_to_const_ref_overload_return <executorch::aten ::Tensor> {
30
+ using type = const executorch::aten ::Tensor&;
31
31
};
32
32
33
33
template <typename T>
@@ -36,8 +36,8 @@ struct evalue_to_ref_overload_return {
36
36
};
37
37
38
38
template <>
39
- struct evalue_to_ref_overload_return <exec_aten ::Tensor> {
40
- using type = exec_aten ::Tensor&;
39
+ struct evalue_to_ref_overload_return <executorch::aten ::Tensor> {
40
+ using type = executorch::aten ::Tensor&;
41
41
};
42
42
43
43
} // namespace internal
@@ -67,18 +67,19 @@ class BoxedEvalueList {
67
67
/*
68
68
* Constructs and returns the list of T specified by the EValue pointers
69
69
*/
70
- exec_aten ::ArrayRef<T> get () const ;
70
+ executorch::aten ::ArrayRef<T> get () const ;
71
71
72
72
private:
73
73
// Source of truth for the list
74
- exec_aten ::ArrayRef<EValue*> wrapped_vals_;
74
+ executorch::aten ::ArrayRef<EValue*> wrapped_vals_;
75
75
// Same size as wrapped_vals
76
76
mutable T* unwrapped_vals_;
77
77
};
78
78
79
79
template <>
80
- exec_aten::ArrayRef<exec_aten::optional<exec_aten::Tensor>>
81
- BoxedEvalueList<exec_aten::optional<exec_aten::Tensor>>::get() const ;
80
+ executorch::aten::ArrayRef<executorch::aten::optional<executorch::aten::Tensor>>
81
+ BoxedEvalueList<executorch::aten::optional<executorch::aten::Tensor>>::get()
82
+ const ;
82
83
83
84
// Aggregate typing system similar to IValue only slimmed down with less
84
85
// functionality, no dependencies on atomic, and fewer supported types to better
@@ -96,18 +97,18 @@ struct EValue {
96
97
bool as_bool;
97
98
// TODO(jakeszwe): convert back to pointers to optimize size of this
98
99
// struct
99
- exec_aten ::ArrayRef<char > as_string;
100
- exec_aten ::ArrayRef<double > as_double_list;
101
- exec_aten ::ArrayRef<bool > as_bool_list;
100
+ executorch::aten ::ArrayRef<char > as_string;
101
+ executorch::aten ::ArrayRef<double > as_double_list;
102
+ executorch::aten ::ArrayRef<bool > as_bool_list;
102
103
BoxedEvalueList<int64_t > as_int_list;
103
- BoxedEvalueList<exec_aten ::Tensor> as_tensor_list;
104
- BoxedEvalueList<exec_aten:: optional<exec_aten ::Tensor>>
104
+ BoxedEvalueList<executorch::aten ::Tensor> as_tensor_list;
105
+ BoxedEvalueList<executorch::aten:: optional<executorch::aten ::Tensor>>
105
106
as_list_optional_tensor;
106
107
} copyable_union;
107
108
108
109
// Since a Tensor just holds a TensorImpl*, there's no value to use Tensor*
109
110
// here.
110
- exec_aten ::Tensor as_tensor;
111
+ executorch::aten ::Tensor as_tensor;
111
112
112
113
Payload () {}
113
114
~Payload () {}
@@ -197,7 +198,7 @@ struct EValue {
197
198
198
199
/* ***** Scalar Type ******/
199
200
// / Construct an EValue using the implicit value of a Scalar.
200
- /* implicit*/ EValue(exec_aten ::Scalar s) {
201
+ /* implicit*/ EValue(executorch::aten ::Scalar s) {
201
202
if (s.isIntegral (false )) {
202
203
tag = Tag::Int;
203
204
payload.copyable_union .as_int = s.to <int64_t >();
@@ -216,7 +217,7 @@ struct EValue {
216
217
return tag == Tag::Int || tag == Tag::Double || tag == Tag::Bool;
217
218
}
218
219
219
- exec_aten ::Scalar toScalar () const {
220
+ executorch::aten ::Scalar toScalar () const {
220
221
// Convert from implicit value to Scalar using implicit constructors.
221
222
222
223
if (isDouble ()) {
@@ -231,11 +232,11 @@ struct EValue {
231
232
}
232
233
233
234
/* ***** Tensor Type ******/
234
- /* implicit*/ EValue(exec_aten ::Tensor t) : tag(Tag::Tensor) {
235
+ /* implicit*/ EValue(executorch::aten ::Tensor t) : tag(Tag::Tensor) {
235
236
// When built in aten mode, at::Tensor has a non trivial constructor
236
237
// destructor, so regular assignment to a union field is UB. Instead we must
237
238
// go through placement new (which causes a refcount bump).
238
- new (&payload.as_tensor ) exec_aten ::Tensor (t);
239
+ new (&payload.as_tensor ) executorch::aten ::Tensor (t);
239
240
}
240
241
241
242
// Template constructor that allows construction from types that can be
@@ -261,35 +262,36 @@ struct EValue {
261
262
return tag == Tag::Tensor;
262
263
}
263
264
264
- exec_aten ::Tensor toTensor () && {
265
+ executorch::aten ::Tensor toTensor () && {
265
266
ET_CHECK_MSG (isTensor (), " EValue is not a Tensor." );
266
267
auto res = std::move (payload.as_tensor );
267
268
clearToNone ();
268
269
return res;
269
270
}
270
271
271
- exec_aten ::Tensor& toTensor () & {
272
+ executorch::aten ::Tensor& toTensor () & {
272
273
ET_CHECK_MSG (isTensor (), " EValue is not a Tensor." );
273
274
return payload.as_tensor ;
274
275
}
275
276
276
- const exec_aten ::Tensor& toTensor () const & {
277
+ const executorch::aten ::Tensor& toTensor () const & {
277
278
ET_CHECK_MSG (isTensor (), " EValue is not a Tensor." );
278
279
return payload.as_tensor ;
279
280
}
280
281
281
282
/* ***** String Type ******/
282
283
/* implicit*/ EValue(const char * s, size_t size) : tag(Tag::String) {
283
- payload.copyable_union .as_string = exec_aten::ArrayRef<char >(s, size);
284
+ payload.copyable_union .as_string =
285
+ executorch::aten::ArrayRef<char >(s, size);
284
286
}
285
287
286
288
bool isString () const {
287
289
return tag == Tag::String;
288
290
}
289
291
290
- exec_aten ::string_view toString () const {
292
+ executorch::aten ::string_view toString () const {
291
293
ET_CHECK_MSG (isString (), " EValue is not a String." );
292
- return exec_aten ::string_view (
294
+ return executorch::aten ::string_view (
293
295
payload.copyable_union .as_string .data (),
294
296
payload.copyable_union .as_string .size ());
295
297
}
@@ -303,41 +305,42 @@ struct EValue {
303
305
return tag == Tag::ListInt;
304
306
}
305
307
306
- exec_aten ::ArrayRef<int64_t > toIntList () const {
308
+ executorch::aten ::ArrayRef<int64_t > toIntList () const {
307
309
ET_CHECK_MSG (isIntList (), " EValue is not an Int List." );
308
310
return payload.copyable_union .as_int_list .get ();
309
311
}
310
312
311
313
/* ***** Bool List Type ******/
312
- /* implicit*/ EValue(exec_aten ::ArrayRef<bool > b) : tag(Tag::ListBool) {
314
+ /* implicit*/ EValue(executorch::aten ::ArrayRef<bool > b) : tag(Tag::ListBool) {
313
315
payload.copyable_union .as_bool_list = b;
314
316
}
315
317
316
318
bool isBoolList () const {
317
319
return tag == Tag::ListBool;
318
320
}
319
321
320
- exec_aten ::ArrayRef<bool > toBoolList () const {
322
+ executorch::aten ::ArrayRef<bool > toBoolList () const {
321
323
ET_CHECK_MSG (isBoolList (), " EValue is not a Bool List." );
322
324
return payload.copyable_union .as_bool_list ;
323
325
}
324
326
325
327
/* ***** Double List Type ******/
326
- /* implicit*/ EValue(exec_aten::ArrayRef<double > d) : tag(Tag::ListDouble) {
328
+ /* implicit*/ EValue(executorch::aten::ArrayRef<double > d)
329
+ : tag(Tag::ListDouble) {
327
330
payload.copyable_union .as_double_list = d;
328
331
}
329
332
330
333
bool isDoubleList () const {
331
334
return tag == Tag::ListDouble;
332
335
}
333
336
334
- exec_aten ::ArrayRef<double > toDoubleList () const {
337
+ executorch::aten ::ArrayRef<double > toDoubleList () const {
335
338
ET_CHECK_MSG (isDoubleList (), " EValue is not a Double List." );
336
339
return payload.copyable_union .as_double_list ;
337
340
}
338
341
339
342
/* ***** Tensor List Type ******/
340
- /* implicit*/ EValue(BoxedEvalueList<exec_aten ::Tensor> t)
343
+ /* implicit*/ EValue(BoxedEvalueList<executorch::aten ::Tensor> t)
341
344
: tag(Tag::ListTensor) {
342
345
payload.copyable_union .as_tensor_list = t;
343
346
}
@@ -346,13 +349,14 @@ struct EValue {
346
349
return tag == Tag::ListTensor;
347
350
}
348
351
349
- exec_aten:: ArrayRef<exec_aten ::Tensor> toTensorList () const {
352
+ executorch::aten:: ArrayRef<executorch::aten ::Tensor> toTensorList () const {
350
353
ET_CHECK_MSG (isTensorList (), " EValue is not a Tensor List." );
351
354
return payload.copyable_union .as_tensor_list .get ();
352
355
}
353
356
354
357
/* ***** List Optional Tensor Type ******/
355
- /* implicit*/ EValue(BoxedEvalueList<exec_aten::optional<exec_aten::Tensor>> t)
358
+ /* implicit*/ EValue(
359
+ BoxedEvalueList<executorch::aten::optional<executorch::aten::Tensor>> t)
356
360
: tag(Tag::ListOptionalTensor) {
357
361
payload.copyable_union .as_list_optional_tensor = t;
358
362
}
@@ -361,34 +365,39 @@ struct EValue {
361
365
return tag == Tag::ListOptionalTensor;
362
366
}
363
367
364
- exec_aten::ArrayRef<exec_aten::optional<exec_aten::Tensor>>
368
+ executorch::aten::ArrayRef<
369
+ executorch::aten::optional<executorch::aten::Tensor>>
365
370
toListOptionalTensor () const {
366
371
return payload.copyable_union .as_list_optional_tensor .get ();
367
372
}
368
373
369
374
/* ***** ScalarType Type ******/
370
- exec_aten ::ScalarType toScalarType () const {
375
+ executorch::aten ::ScalarType toScalarType () const {
371
376
ET_CHECK_MSG (isInt (), " EValue is not a ScalarType." );
372
- return static_cast <exec_aten::ScalarType>(payload.copyable_union .as_int );
377
+ return static_cast <executorch::aten::ScalarType>(
378
+ payload.copyable_union .as_int );
373
379
}
374
380
375
381
/* ***** MemoryFormat Type ******/
376
- exec_aten ::MemoryFormat toMemoryFormat () const {
382
+ executorch::aten ::MemoryFormat toMemoryFormat () const {
377
383
ET_CHECK_MSG (isInt (), " EValue is not a MemoryFormat." );
378
- return static_cast <exec_aten::MemoryFormat>(payload.copyable_union .as_int );
384
+ return static_cast <executorch::aten::MemoryFormat>(
385
+ payload.copyable_union .as_int );
379
386
}
380
387
381
388
/* ***** Layout Type ******/
382
- exec_aten ::Layout toLayout () const {
389
+ executorch::aten ::Layout toLayout () const {
383
390
ET_CHECK_MSG (isInt (), " EValue is not a Layout." );
384
- return static_cast <exec_aten ::Layout>(payload.copyable_union .as_int );
391
+ return static_cast <executorch::aten ::Layout>(payload.copyable_union .as_int );
385
392
}
386
393
387
394
/* ***** Device Type ******/
388
- exec_aten ::Device toDevice () const {
395
+ executorch::aten ::Device toDevice () const {
389
396
ET_CHECK_MSG (isInt (), " EValue is not a Device." );
390
- return exec_aten::Device (
391
- static_cast <exec_aten::DeviceType>(payload.copyable_union .as_int ), -1 );
397
+ return executorch::aten::Device (
398
+ static_cast <executorch::aten::DeviceType>(
399
+ payload.copyable_union .as_int ),
400
+ -1 );
392
401
}
393
402
394
403
template <typename T>
@@ -403,9 +412,9 @@ struct EValue {
403
412
* an uninitialized state.
404
413
*/
405
414
template <typename T>
406
- inline exec_aten ::optional<T> toOptional () const {
415
+ inline executorch::aten ::optional<T> toOptional () const {
407
416
if (this ->isNone ()) {
408
- return exec_aten ::nullopt;
417
+ return executorch::aten ::nullopt;
409
418
}
410
419
return this ->to <T>();
411
420
}
@@ -421,7 +430,7 @@ struct EValue {
421
430
void moveFrom (EValue&& rhs) noexcept {
422
431
if (rhs.isTensor ()) {
423
432
new (&payload.as_tensor )
424
- exec_aten ::Tensor (std::move (rhs.payload .as_tensor ));
433
+ executorch::aten ::Tensor (std::move (rhs.payload .as_tensor ));
425
434
rhs.payload .as_tensor .~Tensor ();
426
435
} else {
427
436
payload.copyable_union = rhs.payload .copyable_union ;
@@ -451,7 +460,7 @@ struct EValue {
451
460
452
461
EValue (const Payload& p, Tag t) : tag(t) {
453
462
if (isTensor ()) {
454
- new (&payload.as_tensor ) exec_aten ::Tensor (p.as_tensor );
463
+ new (&payload.as_tensor ) executorch::aten ::Tensor (p.as_tensor );
455
464
} else {
456
465
payload.copyable_union = p.copyable_union ;
457
466
}
@@ -480,60 +489,64 @@ struct EValue {
480
489
return static_cast <return_type>(this ->method_name ()); \
481
490
}
482
491
483
- EVALUE_DEFINE_TO (exec_aten ::Scalar, toScalar)
492
+ EVALUE_DEFINE_TO (executorch::aten ::Scalar, toScalar)
484
493
EVALUE_DEFINE_TO (int64_t , toInt)
485
494
EVALUE_DEFINE_TO (bool , toBool)
486
495
EVALUE_DEFINE_TO (double , toDouble)
487
- EVALUE_DEFINE_TO (exec_aten ::string_view, toString)
488
- EVALUE_DEFINE_TO (exec_aten ::ScalarType, toScalarType)
489
- EVALUE_DEFINE_TO (exec_aten ::MemoryFormat, toMemoryFormat)
490
- EVALUE_DEFINE_TO (exec_aten ::Layout, toLayout)
491
- EVALUE_DEFINE_TO (exec_aten ::Device, toDevice)
496
+ EVALUE_DEFINE_TO (executorch::aten ::string_view, toString)
497
+ EVALUE_DEFINE_TO (executorch::aten ::ScalarType, toScalarType)
498
+ EVALUE_DEFINE_TO (executorch::aten ::MemoryFormat, toMemoryFormat)
499
+ EVALUE_DEFINE_TO (executorch::aten ::Layout, toLayout)
500
+ EVALUE_DEFINE_TO (executorch::aten ::Device, toDevice)
492
501
// Tensor and Optional Tensor
493
502
EVALUE_DEFINE_TO (
494
- exec_aten:: optional<exec_aten ::Tensor>,
495
- toOptional<exec_aten ::Tensor>)
496
- EVALUE_DEFINE_TO (exec_aten ::Tensor, toTensor)
503
+ executorch::aten:: optional<executorch::aten ::Tensor>,
504
+ toOptional<executorch::aten ::Tensor>)
505
+ EVALUE_DEFINE_TO (executorch::aten ::Tensor, toTensor)
497
506
498
507
// IntList and Optional IntList
499
- EVALUE_DEFINE_TO (exec_aten ::ArrayRef<int64_t >, toIntList)
508
+ EVALUE_DEFINE_TO (executorch::aten ::ArrayRef<int64_t >, toIntList)
500
509
EVALUE_DEFINE_TO (
501
- exec_aten:: optional<exec_aten ::ArrayRef<int64_t >>,
502
- toOptional<exec_aten ::ArrayRef<int64_t >>)
510
+ executorch::aten:: optional<executorch::aten ::ArrayRef<int64_t >>,
511
+ toOptional<executorch::aten ::ArrayRef<int64_t >>)
503
512
504
513
// DoubleList and Optional DoubleList
505
- EVALUE_DEFINE_TO (exec_aten ::ArrayRef<double >, toDoubleList)
514
+ EVALUE_DEFINE_TO (executorch::aten ::ArrayRef<double >, toDoubleList)
506
515
EVALUE_DEFINE_TO (
507
- exec_aten:: optional<exec_aten ::ArrayRef<double >>,
508
- toOptional<exec_aten ::ArrayRef<double >>)
516
+ executorch::aten:: optional<executorch::aten ::ArrayRef<double >>,
517
+ toOptional<executorch::aten ::ArrayRef<double >>)
509
518
510
519
// BoolList and Optional BoolList
511
- EVALUE_DEFINE_TO (exec_aten ::ArrayRef<bool >, toBoolList)
520
+ EVALUE_DEFINE_TO (executorch::aten ::ArrayRef<bool >, toBoolList)
512
521
EVALUE_DEFINE_TO (
513
- exec_aten:: optional<exec_aten ::ArrayRef<bool >>,
514
- toOptional<exec_aten ::ArrayRef<bool >>)
522
+ executorch::aten:: optional<executorch::aten ::ArrayRef<bool >>,
523
+ toOptional<executorch::aten ::ArrayRef<bool >>)
515
524
516
525
// TensorList and Optional TensorList
517
- EVALUE_DEFINE_TO (exec_aten::ArrayRef<exec_aten::Tensor>, toTensorList)
518
526
EVALUE_DEFINE_TO (
519
- exec_aten::optional<exec_aten::ArrayRef<exec_aten::Tensor>>,
520
- toOptional<exec_aten::ArrayRef<exec_aten::Tensor>>)
527
+ executorch::aten::ArrayRef<executorch::aten::Tensor>,
528
+ toTensorList)
529
+ EVALUE_DEFINE_TO (
530
+ executorch::aten::optional<
531
+ executorch::aten::ArrayRef<executorch::aten::Tensor>>,
532
+ toOptional<executorch::aten::ArrayRef<executorch::aten::Tensor>>)
521
533
522
534
// List of Optional Tensor
523
535
EVALUE_DEFINE_TO (
524
- exec_aten::ArrayRef<exec_aten::optional<exec_aten::Tensor>>,
536
+ executorch::aten::ArrayRef<
537
+ executorch::aten::optional<executorch::aten::Tensor>>,
525
538
toListOptionalTensor)
526
539
#undef EVALUE_DEFINE_TO
527
540
528
541
template <typename T>
529
- exec_aten ::ArrayRef<T> BoxedEvalueList<T>::get() const {
530
- for (typename exec_aten ::ArrayRef<T>::size_type i = 0 ;
542
+ executorch::aten ::ArrayRef<T> BoxedEvalueList<T>::get() const {
543
+ for (typename executorch::aten ::ArrayRef<T>::size_type i = 0 ;
531
544
i < wrapped_vals_.size ();
532
545
i++) {
533
546
ET_CHECK (wrapped_vals_[i] != nullptr );
534
547
unwrapped_vals_[i] = wrapped_vals_[i]->template to <T>();
535
548
}
536
- return exec_aten ::ArrayRef<T>{unwrapped_vals_, wrapped_vals_.size ()};
549
+ return executorch::aten ::ArrayRef<T>{unwrapped_vals_, wrapped_vals_.size ()};
537
550
}
538
551
539
552
} // namespace runtime
0 commit comments