@@ -499,16 +499,16 @@ int simplify_iteration_two_strides(const int nd,
499
499
return nd_;
500
500
}
501
501
502
- using vecT = std::vector<py:: ssize_t >;
503
- std::tuple<vecT, vecT, py:: size_t > contract_iter (vecT shape, vecT strides)
502
+ template < typename T, class Error , typename vecT = std::vector<T>>
503
+ std::tuple<vecT, vecT, T > contract_iter (vecT shape, vecT strides)
504
504
{
505
505
const size_t dim = shape.size ();
506
506
if (dim != strides.size ()) {
507
- throw py::value_error (" Shape and strides must be of equal size." );
507
+ throw Error (" Shape and strides must be of equal size." );
508
508
}
509
509
vecT out_shape = shape;
510
510
vecT out_strides = strides;
511
- py:: ssize_t disp (0 );
511
+ T disp (0 );
512
512
513
513
int nd = simplify_iteration_stride (dim, out_shape.data (),
514
514
out_strides.data (), disp);
@@ -517,18 +517,19 @@ std::tuple<vecT, vecT, py::size_t> contract_iter(vecT shape, vecT strides)
517
517
return std::make_tuple (out_shape, out_strides, disp);
518
518
}
519
519
520
- std::tuple<vecT, vecT, py::size_t , vecT, py::ssize_t >
520
+ template <typename T, class Error , typename vecT = std::vector<T>>
521
+ std::tuple<vecT, vecT, T, vecT, T>
521
522
contract_iter2 (vecT shape, vecT strides1, vecT strides2)
522
523
{
523
524
const size_t dim = shape.size ();
524
525
if (dim != strides1.size () || dim != strides2.size ()) {
525
- throw py::value_error (" Shape and strides must be of equal size." );
526
+ throw Error (" Shape and strides must be of equal size." );
526
527
}
527
528
vecT out_shape = shape;
528
529
vecT out_strides1 = strides1;
529
530
vecT out_strides2 = strides2;
530
- py:: ssize_t disp1 (0 );
531
- py:: ssize_t disp2 (0 );
531
+ T disp1 (0 );
532
+ T disp2 (0 );
532
533
533
534
int nd = simplify_iteration_two_strides (dim, out_shape.data (),
534
535
out_strides1.data (),
0 commit comments