@@ -146,8 +146,7 @@ def _to_memory(unsigned char[::1] b, str usm_kind):
146146 res = MemoryUSMHost(len (b))
147147 else :
148148 raise ValueError (
149- " Unrecognized usm_kind={} stored in the "
150- " pickle" .format(usm_kind)
149+ f" Unrecognized usm_kind={usm_kind} stored in the pickle"
151150 )
152151 res.copy_from_host(b)
153152
@@ -206,9 +205,8 @@ cdef class _Memory:
206205 p = DPCTLmalloc_device(nbytes, QRef)
207206 else :
208207 raise RuntimeError (
209- " Pointer type '{}' is not recognized" .format(
210- ptr_type.decode(" UTF-8" )
211- )
208+ f" Pointer type '{ptr_type.decode('UTF-8')}' is not "
209+ " recognized"
212210 )
213211
214212 if (p):
@@ -250,13 +248,13 @@ cdef class _Memory:
250248 self .refobj = other
251249 else :
252250 raise ValueError (
253- " Argument {} does not correctly expose"
254- " `__sycl_usm_array_interface__`." .format(other)
251+ f " Argument {other } does not correctly expose"
252+ " `__sycl_usm_array_interface__`."
255253 )
256254 else :
257255 raise ValueError (
258- " Argument {} does not expose "
259- " `__sycl_usm_array_interface__`." .format(other)
256+ f " Argument {other } does not expose "
257+ " `__sycl_usm_array_interface__`."
260258 )
261259
262260 def __dealloc__ (self ):
@@ -350,12 +348,8 @@ cdef class _Memory:
350348
351349 def __repr__ (self ):
352350 return (
353- " <SYCL(TM) USM-{} allocation of {} bytes at {}>"
354- .format(
355- self .get_usm_type(),
356- self .nbytes,
357- hex (< object > (< size_t> self ._memory_ptr))
358- )
351+ f" <SYCL(TM) USM-{self.get_usm_type()} allocation of {self.nbytes} "
352+ f" bytes at {hex(<object>(<size_t>self._memory_ptr))}>"
359353 )
360354
361355 def __len__ (self ):
@@ -488,8 +482,8 @@ cdef class _Memory:
488482 host_buf = obj
489483 elif (< Py_ssize_t> len (host_buf) < self .nbytes):
490484 raise ValueError (
491- " Destination object is too small to accommodate {} bytes "
492- .format( self .nbytes)
485+ f " Destination object is too small to accommodate {self.nbytes} "
486+ " bytes "
493487 )
494488 # call kernel to copy from
495489 ERef = DPCTLQueue_Memcpy(
@@ -514,8 +508,8 @@ cdef class _Memory:
514508
515509 if (buf_len > self .nbytes):
516510 raise ValueError (
517- " Source object is too large to be accommodated in {} bytes "
518- " buffer " .format( self .nbytes)
511+ " Source object is too large to be accommodated in "
512+ f " { self.nbytes} bytes buffer "
519513 )
520514 # call kernel to copy from
521515 ERef = DPCTLQueue_Memcpy(
@@ -551,7 +545,7 @@ cdef class _Memory:
551545 if (src_buf.nbytes > self .nbytes):
552546 raise ValueError (
553547 " Source object is too large to "
554- " be accommondated in {} bytes buffer" .format( self .nbytes)
548+ f " be accommondated in {self.nbytes } bytes buffer"
555549 )
556550
557551 src_queue = src_buf.queue
@@ -788,13 +782,12 @@ cdef class MemoryUSMShared(_Memory):
788782 self .copy_from_device(other)
789783 else :
790784 raise ValueError (
791- " USM pointer in the argument {} is not a "
785+ f " USM pointer in the argument {other } is not a "
792786 " USM shared pointer. "
793787 " Zero-copy operation is not possible with "
794788 " copy=False. "
795789 " Either use copy=True, or use a constructor "
796- " appropriate for "
797- " type '{}'" .format(other, self .get_usm_type())
790+ f" appropriate for type '{self.get_usm_type()}'"
798791 )
799792
800793 def __getbuffer__ (self , Py_buffer *buffer , int flags ):
@@ -840,13 +833,11 @@ cdef class MemoryUSMHost(_Memory):
840833 self .copy_from_device(other)
841834 else :
842835 raise ValueError (
843- " USM pointer in the argument {} is "
836+ f " USM pointer in the argument {other } is "
844837 " not a USM host pointer. "
845838 " Zero-copy operation is not possible with copy=False. "
846839 " Either use copy=True, or use a constructor "
847- " appropriate for type '{}'" .format(
848- other, self .get_usm_type()
849- )
840+ f" appropriate for type '{self.get_usm_type()}'"
850841 )
851842
852843 def __getbuffer__ (self , Py_buffer *buffer , int flags ):
@@ -892,13 +883,11 @@ cdef class MemoryUSMDevice(_Memory):
892883 self .copy_from_device(other)
893884 else :
894885 raise ValueError (
895- " USM pointer in the argument {} is not "
886+ f " USM pointer in the argument {other } is not "
896887 " a USM device pointer. "
897888 " Zero-copy operation is not possible with copy=False. "
898889 " Either use copy=True, or use a constructor "
899- " appropriate for type '{}'" .format(
900- other, self .get_usm_type()
901- )
890+ f" appropriate for type '{self.get_usm_type()}'"
902891 )
903892
904893
0 commit comments