@@ -125,12 +125,15 @@ device_allocate_and_pack(sycl::queue &q,
125
125
126
126
struct NoOpIndexer
127
127
{
128
- size_t operator ()(size_t gid) const
128
+ constexpr NoOpIndexer () {}
129
+ constexpr size_t operator ()(size_t gid) const
129
130
{
130
131
return gid;
131
132
}
132
133
};
133
134
135
+ using dpctl::tensor::ssize_t ;
136
+
134
137
/* @brief Indexer with shape and strides arrays of same size are packed */
135
138
struct StridedIndexer
136
139
{
@@ -204,7 +207,7 @@ struct UnpackedStridedIndexer
204
207
using dpctl::tensor::strides::CIndexer_vector;
205
208
206
209
CIndexer_vector _ind (nd);
207
- py:: ssize_t relative_offset (0 );
210
+ ssize_t relative_offset (0 );
208
211
_ind.get_displacement <const ssize_t *, const ssize_t *>(
209
212
gid,
210
213
shape, // shape ptr
@@ -253,18 +256,18 @@ struct Strided1DCyclicIndexer
253
256
254
257
template <typename displacementT> struct TwoOffsets
255
258
{
256
- TwoOffsets () : first_offset(0 ), second_offset(0 ) {}
257
- TwoOffsets (const displacementT &first_offset_,
258
- const displacementT &second_offset_)
259
+ constexpr TwoOffsets () : first_offset(0 ), second_offset(0 ) {}
260
+ constexpr TwoOffsets (const displacementT &first_offset_,
261
+ const displacementT &second_offset_)
259
262
: first_offset(first_offset_), second_offset(second_offset_)
260
263
{
261
264
}
262
265
263
- displacementT get_first_offset () const
266
+ constexpr displacementT get_first_offset () const
264
267
{
265
268
return first_offset;
266
269
}
267
- displacementT get_second_offset () const
270
+ constexpr displacementT get_second_offset () const
268
271
{
269
272
return second_offset;
270
273
}
@@ -323,9 +326,9 @@ struct TwoOffsets_StridedIndexer
323
326
324
327
struct TwoZeroOffsets_Indexer
325
328
{
326
- TwoZeroOffsets_Indexer () {}
329
+ constexpr TwoZeroOffsets_Indexer () {}
327
330
328
- TwoOffsets<ssize_t > operator ()(ssize_t ) const
331
+ constexpr TwoOffsets<ssize_t > operator ()(ssize_t ) const
329
332
{
330
333
return TwoOffsets<ssize_t >();
331
334
}
@@ -339,39 +342,41 @@ struct TwoOffsets_CombinedIndexer
339
342
SecondIndexerT second_indexer_;
340
343
341
344
public:
342
- TwoOffsets_CombinedIndexer (const FirstIndexerT &first_indexer,
343
- const SecondIndexerT &second_indexer)
345
+ constexpr TwoOffsets_CombinedIndexer (const FirstIndexerT &first_indexer,
346
+ const SecondIndexerT &second_indexer)
344
347
: first_indexer_(first_indexer), second_indexer_(second_indexer)
345
348
{
346
349
}
347
350
348
- TwoOffsets<py:: ssize_t > operator ()(py:: ssize_t gid) const
351
+ constexpr TwoOffsets<ssize_t > operator ()(ssize_t gid) const
349
352
{
350
- return TwoOffsets<py::ssize_t >(first_indexer_ (gid),
351
- second_indexer_ (gid));
353
+ return TwoOffsets<ssize_t >(first_indexer_ (gid), second_indexer_ (gid));
352
354
}
353
355
};
354
356
355
357
template <typename displacementT> struct ThreeOffsets
356
358
{
357
- ThreeOffsets () : first_offset(0 ), second_offset(0 ), third_offset(0 ) {}
358
- ThreeOffsets (const displacementT &first_offset_,
359
- const displacementT &second_offset_,
360
- const displacementT &third_offset_)
359
+ constexpr ThreeOffsets ()
360
+ : first_offset(0 ), second_offset(0 ), third_offset(0 )
361
+ {
362
+ }
363
+ constexpr ThreeOffsets (const displacementT &first_offset_,
364
+ const displacementT &second_offset_,
365
+ const displacementT &third_offset_)
361
366
: first_offset(first_offset_), second_offset(second_offset_),
362
367
third_offset(third_offset_)
363
368
{
364
369
}
365
370
366
- displacementT get_first_offset () const
371
+ constexpr displacementT get_first_offset () const
367
372
{
368
373
return first_offset;
369
374
}
370
- displacementT get_second_offset () const
375
+ constexpr displacementT get_second_offset () const
371
376
{
372
377
return second_offset;
373
378
}
374
- displacementT get_third_offset () const
379
+ constexpr displacementT get_third_offset () const
375
380
{
376
381
return third_offset;
377
382
}
@@ -438,11 +443,11 @@ struct ThreeOffsets_StridedIndexer
438
443
439
444
struct ThreeZeroOffsets_Indexer
440
445
{
441
- ThreeZeroOffsets_Indexer () {}
446
+ constexpr ThreeZeroOffsets_Indexer () {}
442
447
443
- ThreeOffsets<py:: ssize_t > operator ()(py:: ssize_t ) const
448
+ constexpr ThreeOffsets<ssize_t > operator ()(ssize_t ) const
444
449
{
445
- return ThreeOffsets<py:: ssize_t >();
450
+ return ThreeOffsets<ssize_t >();
446
451
}
447
452
};
448
453
@@ -457,15 +462,15 @@ struct ThreeOffsets_CombinedIndexer
457
462
ThirdIndexerT third_indexer_;
458
463
459
464
public:
460
- ThreeOffsets_CombinedIndexer (const FirstIndexerT &first_indexer,
461
- const SecondIndexerT &second_indexer,
462
- const ThirdIndexerT &third_indexer)
465
+ constexpr ThreeOffsets_CombinedIndexer (const FirstIndexerT &first_indexer,
466
+ const SecondIndexerT &second_indexer,
467
+ const ThirdIndexerT &third_indexer)
463
468
: first_indexer_(first_indexer), second_indexer_(second_indexer),
464
469
third_indexer_(third_indexer)
465
470
{
466
471
}
467
472
468
- ThreeOffsets<ssize_t > operator ()(ssize_t gid) const
473
+ constexpr ThreeOffsets<ssize_t > operator ()(ssize_t gid) const
469
474
{
470
475
return ThreeOffsets<ssize_t >(first_indexer_ (gid), second_indexer_ (gid),
471
476
third_indexer_ (gid));
@@ -474,32 +479,32 @@ struct ThreeOffsets_CombinedIndexer
474
479
475
480
template <typename displacementT> struct FourOffsets
476
481
{
477
- FourOffsets ()
482
+ constexpr FourOffsets ()
478
483
: first_offset(0 ), second_offset(0 ), third_offset(0 ), fourth_offset(0 )
479
484
{
480
485
}
481
- FourOffsets (const displacementT &first_offset_,
482
- const displacementT &second_offset_,
483
- const displacementT &third_offset_,
484
- const displacementT &fourth_offset_)
486
+ constexpr FourOffsets (const displacementT &first_offset_,
487
+ const displacementT &second_offset_,
488
+ const displacementT &third_offset_,
489
+ const displacementT &fourth_offset_)
485
490
: first_offset(first_offset_), second_offset(second_offset_),
486
491
third_offset(third_offset_), fourth_offset(fourth_offset_)
487
492
{
488
493
}
489
494
490
- displacementT get_first_offset () const
495
+ constexpr displacementT get_first_offset () const
491
496
{
492
497
return first_offset;
493
498
}
494
- displacementT get_second_offset () const
499
+ constexpr displacementT get_second_offset () const
495
500
{
496
501
return second_offset;
497
502
}
498
- displacementT get_third_offset () const
503
+ constexpr displacementT get_third_offset () const
499
504
{
500
505
return third_offset;
501
506
}
502
- displacementT get_fourth_offset () const
507
+ constexpr displacementT get_fourth_offset () const
503
508
{
504
509
return fourth_offset;
505
510
}
@@ -513,12 +518,12 @@ template <typename displacementT> struct FourOffsets
513
518
514
519
struct FourOffsets_StridedIndexer
515
520
{
516
- FourOffsets_StridedIndexer (int common_nd,
517
- ssize_t first_offset_,
518
- ssize_t second_offset_,
519
- ssize_t third_offset_,
520
- ssize_t fourth_offset_,
521
- ssize_t const *_packed_shape_strides)
521
+ constexpr FourOffsets_StridedIndexer (int common_nd,
522
+ ssize_t first_offset_,
523
+ ssize_t second_offset_,
524
+ ssize_t third_offset_,
525
+ ssize_t fourth_offset_,
526
+ ssize_t const *_packed_shape_strides)
522
527
: nd(common_nd), starting_first_offset(first_offset_),
523
528
starting_second_offset(second_offset_),
524
529
starting_third_offset(third_offset_),
@@ -527,12 +532,12 @@ struct FourOffsets_StridedIndexer
527
532
{
528
533
}
529
534
530
- FourOffsets<ssize_t > operator ()(ssize_t gid) const
535
+ constexpr FourOffsets<ssize_t > operator ()(ssize_t gid) const
531
536
{
532
537
return compute_offsets (gid);
533
538
}
534
539
535
- FourOffsets<ssize_t > operator ()(size_t gid) const
540
+ constexpr FourOffsets<ssize_t > operator ()(size_t gid) const
536
541
{
537
542
return compute_offsets (static_cast <ssize_t >(gid));
538
543
}
@@ -545,7 +550,7 @@ struct FourOffsets_StridedIndexer
545
550
ssize_t starting_fourth_offset;
546
551
ssize_t const *shape_strides;
547
552
548
- FourOffsets<py:: ssize_t > compute_offsets (ssize_t gid) const
553
+ FourOffsets<ssize_t > compute_offsets (ssize_t gid) const
549
554
{
550
555
using dpctl::tensor::strides::CIndexer_vector;
551
556
@@ -573,9 +578,9 @@ struct FourOffsets_StridedIndexer
573
578
574
579
struct FourZeroOffsets_Indexer
575
580
{
576
- FourZeroOffsets_Indexer () {}
581
+ constexpr FourZeroOffsets_Indexer () {}
577
582
578
- FourOffsets<ssize_t > operator ()(ssize_t ) const
583
+ constexpr FourOffsets<ssize_t > operator ()(ssize_t ) const
579
584
{
580
585
return FourOffsets<ssize_t >();
581
586
}
0 commit comments