Skip to content

Missing C- and F-contagious flags #1334

Closed
@antonwolfy

Description

@antonwolfy

The code below works differently in dpctl and numpy:

import numpy, dpctl, dpctl.tensor as dpt

a = dpt.ones((2, 3))
dpt.reshape(a, (1, 6, 1)).flags
# Out:
#   C_CONTIGUOUS : False
#   F_CONTIGUOUS : False
#   WRITABLE : True

x = numpy.ones((2, 3))
numpy.reshape(x, (1, 6, 1)).flags
# Out:
#   C_CONTIGUOUS : True
#   F_CONTIGUOUS : True
#   OWNDATA : False
#   WRITEABLE : True
#   ALIGNED : True
#   WRITEBACKIFCOPY : False

and similar use case:

a = dpt.ones((2, 3), order='F')
dpt.reshape(a, (1, 6, 1), order='F').flags
# Out:
#   C_CONTIGUOUS : False
#   F_CONTIGUOUS : False
#   WRITABLE : True

x = numpy.ones((2, 3), order='F')
numpy.reshape(x, (1, 6, 1), order='F').flags
# Out:
#   C_CONTIGUOUS : True
#   F_CONTIGUOUS : True
#   OWNDATA : False
#   WRITEABLE : True
#   ALIGNED : True
#   WRITEBACKIFCOPY : False

one more example with sum:

a = dpt.ones((2, 3, 4))
dpt.sum(a, axis=(1, 2), keepdims=True).flags
# Out:
#   C_CONTIGUOUS : False
#   F_CONTIGUOUS : False
#   WRITABLE : True

x = numpy.ones((2, 3, 4))
numpy.sum(a, axis=(1, 2), keepdims=True).flags
# Out:
#   C_CONTIGUOUS : True
#   F_CONTIGUOUS : True
#   OWNDATA : True
#   WRITEABLE : True
#   ALIGNED : True
#   WRITEBACKIFCOPY : False

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions