@@ -63,6 +63,10 @@ py_unary_ufunc(dpctl::tensor::usm_ndarray src,
63
63
const contig_dispatchT &contig_dispatch_vector,
64
64
const strided_dispatchT &strided_dispatch_vector)
65
65
{
66
+ if (!dst.is_writable ()) {
67
+ throw py::value_error (" Output array is read-only." );
68
+ }
69
+
66
70
int src_typenum = src.get_typenum ();
67
71
int dst_typenum = dst.get_typenum ();
68
72
@@ -306,6 +310,9 @@ std::pair<sycl::event, sycl::event> py_binary_ufunc(
306
310
const contig_row_matrix_dispatchT
307
311
&contig_row_matrix_broadcast_dispatch_table)
308
312
{
313
+ if (!dst.is_writable ()) {
314
+ throw py::value_error (" Output array is read-only." );
315
+ }
309
316
// check type_nums
310
317
int src1_typenum = src1.get_typenum ();
311
318
int src2_typenum = src2.get_typenum ();
@@ -602,6 +609,10 @@ py_binary_inplace_ufunc(dpctl::tensor::usm_ndarray lhs,
602
609
const contig_dispatchT &contig_dispatch_table,
603
610
const strided_dispatchT &strided_dispatch_table)
604
611
{
612
+ if (!lhs.is_writable ()) {
613
+ throw py::value_error (" Output array is read-only." );
614
+ }
615
+
605
616
// check type_nums
606
617
int rhs_typenum = rhs.get_typenum ();
607
618
int lhs_typenum = lhs.get_typenum ();
0 commit comments