@@ -23,7 +23,7 @@ from libcpp cimport bool as cpp_bool
2323from dpctl.tensor._usmarray cimport (
2424 USM_ARRAY_C_CONTIGUOUS,
2525 USM_ARRAY_F_CONTIGUOUS,
26- USM_ARRAY_WRITEABLE ,
26+ USM_ARRAY_WRITABLE ,
2727 usm_ndarray,
2828)
2929
@@ -33,7 +33,10 @@ cdef cpp_bool _check_bit(int flag, int mask):
3333
3434
3535cdef class Flags:
36- """ Helper class to represent flags of :class:`dpctl.tensor.usm_ndarray`."""
36+ """
37+ Helper class to represent memory layout flags of
38+ :class:`dpctl.tensor.usm_ndarray`.
39+ """
3740 cdef int flags_
3841 cdef usm_ndarray arr_
3942
@@ -43,51 +46,83 @@ cdef class Flags:
4346
4447 @property
4548 def flags (self ):
49+ """
50+ Integer representation of the memory layout flags of
51+ :class:`dpctl.tensor.usm_ndarray` instance.
52+ """
4653 return self .flags_
4754
4855 @property
4956 def c_contiguous (self ):
57+ """
58+ True if the memory layout of the
59+ :class:`dpctl.tensor.usm_ndarray` instance is C-contiguous.
60+ """
5061 return _check_bit(self .flags_, USM_ARRAY_C_CONTIGUOUS)
5162
5263 @property
5364 def f_contiguous (self ):
65+ """
66+ True if the memory layout of the
67+ :class:`dpctl.tensor.usm_ndarray` instance is F-contiguous.
68+ """
5469 return _check_bit(self .flags_, USM_ARRAY_F_CONTIGUOUS)
5570
5671 @property
5772 def writable (self ):
58- return _check_bit(self .flags_, USM_ARRAY_WRITEABLE)
73+ """
74+ True if :class:`dpctl.tensor.usm_ndarray` instance is writable.
75+ """
76+ return _check_bit(self .flags_, USM_ARRAY_WRITABLE)
5977
6078 @property
6179 def fc (self ):
80+ """
81+ True if the memory layout of the :class:`dpctl.tensor.usm_ndarray`
82+ instance is C-contiguous and F-contiguous.
83+ """
6284 return (
6385 _check_bit(self .flags_, USM_ARRAY_C_CONTIGUOUS)
6486 and _check_bit(self .flags_, USM_ARRAY_F_CONTIGUOUS)
6587 )
6688
6789 @property
6890 def forc (self ):
91+ """
92+ True if the memory layout of the :class:`dpctl.tensor.usm_ndarray`
93+ instance is C-contiguous or F-contiguous.
94+ """
6995 return (
7096 _check_bit(self .flags_, USM_ARRAY_C_CONTIGUOUS)
7197 or _check_bit(self .flags_, USM_ARRAY_F_CONTIGUOUS)
7298 )
7399
74100 @property
75101 def fnc (self ):
102+ """
103+ True if the memory layout of the :class:`dpctl.tensor.usm_ndarray`
104+ instance is F-contiguous and not C-contiguous.
105+ """
76106 return (
77107 _check_bit(self .flags_, USM_ARRAY_C_CONTIGUOUS)
78108 and not _check_bit(self .flags_, USM_ARRAY_F_CONTIGUOUS)
79109 )
80110
81111 @property
82112 def contiguous (self ):
113+ """
114+ True if the memory layout of the :class:`dpctl.tensor.usm_ndarray`
115+ instance is C-contiguous and F-contiguous.
116+ Equivalent to `forc.`
117+ """
83118 return self .forc
84119
85120 def __getitem__ (self , name ):
86121 if name in [" C_CONTIGUOUS" , " C" ]:
87122 return self .c_contiguous
88123 elif name in [" F_CONTIGUOUS" , " F" ]:
89124 return self .f_contiguous
90- elif name == " WRITABLE" :
125+ elif name in [ " WRITABLE" , " W " ] :
91126 return self .writable
92127 elif name == " FC" :
93128 return self .fc
0 commit comments