Skip to content

Commit

Permalink
Flags fnc to 'F-not-C' and added fc ('F-and-C')
Browse files Browse the repository at this point in the history
  • Loading branch information
ndgrigorian committed Oct 10, 2022
1 parent 5deed9b commit 74043c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 10 additions & 1 deletion dpctl/tensor/_flags.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ cdef class Flags:
def writable(self):
return _check_bit(self.flags_, USM_ARRAY_WRITEABLE)

@property
def fc(self):
return (
_check_bit(self.flags_, USM_ARRAY_C_CONTIGUOUS)
and _check_bit(self.flags_, USM_ARRAY_F_CONTIGUOUS)
)

@property
def forc(self):
return (
Expand All @@ -68,7 +75,7 @@ cdef class Flags:
def fnc(self):
return (
_check_bit(self.flags_, USM_ARRAY_C_CONTIGUOUS)
and _check_bit(self.flags_, USM_ARRAY_F_CONTIGUOUS)
and not _check_bit(self.flags_, USM_ARRAY_F_CONTIGUOUS)
)

@property
Expand All @@ -82,6 +89,8 @@ cdef class Flags:
return self.f_contiguous
elif name == "WRITABLE":
return self.writable
elif name == "FC":
return self.fc
elif name == "CONTIGUOUS":
return self.forc

Expand Down
5 changes: 3 additions & 2 deletions dpctl/tests/test_usm_ndarray_ctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def test_allocate_usm_ndarray(shape, usm_type):


def test_usm_ndarray_flags():
assert dpt.usm_ndarray((5,)).flags.fnc
assert dpt.usm_ndarray((5,)).flags.fc
assert dpt.usm_ndarray((5, 2)).flags.c_contiguous
assert dpt.usm_ndarray((5, 2), order="F").flags.f_contiguous
assert dpt.usm_ndarray((5, 1, 2), order="F").flags.f_contiguous
assert dpt.usm_ndarray((5, 1, 2), strides=(2, 0, 1)).flags.c_contiguous
assert dpt.usm_ndarray((5, 1, 2), strides=(1, 0, 5)).flags.f_contiguous
assert dpt.usm_ndarray((5, 1, 1), strides=(1, 0, 1)).flags.fnc
assert dpt.usm_ndarray((5, 1, 1), strides=(1, 0, 1)).flags.fc


@pytest.mark.parametrize(
Expand Down Expand Up @@ -1525,6 +1525,7 @@ def test_flags():
f.c_contiguous
f.f_contiguous
f.contiguous
f.fc
f.fnc
f.forc
f.writable
Expand Down

0 comments on commit 74043c3

Please sign in to comment.