Title: Bug in `asnumpy` copy_utils · Issue #2138 · IntelPython/dpctl · GitHub
Open Graph Title: Bug in `asnumpy` copy_utils · Issue #2138 · IntelPython/dpctl
X Title: Bug in `asnumpy` copy_utils · Issue #2138 · IntelPython/dpctl
Description: It looks like the order-C is being ignored and the C-contiguous checks fails when using dpnp.asnumpy(). Please refer to the below reproducer and output with dpnp+dpctl & cupy, more specifically 3c section of the output. Upon a quick peek...
Open Graph Description: It looks like the order-C is being ignored and the C-contiguous checks fails when using dpnp.asnumpy(). Please refer to the below reproducer and output with dpnp+dpctl & cupy, more specifically 3c ...
X Description: It looks like the order-C is being ignored and the C-contiguous checks fails when using dpnp.asnumpy(). Please refer to the below reproducer and output with dpnp+dpctl & cupy, more specifically...
Opengraph URL: https://github.com/IntelPython/dpctl/issues/2138
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug in `asnumpy` copy_utils","articleBody":"It looks like the order-C is being ignored and the C-contiguous checks fails when using `dpnp.asnumpy()`. Please refer to the below reproducer and output with dpnp+dpctl \u0026 cupy, more specifically `3c` section of the output.\n\nUpon a quick peek, much of the `asnumpy` is being forwarded to `dpt.__copy_utils__` and so opened an issue here. Apologies if this is not the right repo and should move it to DPNP.\n\nReproducer:\n```python\nimport numpy as np\nimport dpnp as dp\n\nprint(\"dpnp version:\", getattr(dp, \"__version__\", \"unknown\"))\n\n# Build the same data as in the larger code\nctr_offsets_slice = [\n dp.array([0, 0, 0], dtype=np.int32),\n dp.array([3, 3, 3], dtype=np.int32),\n dp.array([5, 5, 5], dtype=np.int32),\n dp.array([7, 7, 7], dtype=np.int32),\n dp.array([10, 10, 10], dtype=np.int32),\n dp.array([11, 11, 11], dtype=np.int32),\n dp.array([12, 12, 12], dtype=np.int32),\n]\n\n# 3a: stack -\u003e dpnp_array (should be C-contiguous)\ntemp1 = dp.stack(ctr_offsets_slice)\n\n# 3b: transpose -\u003e dpnp_array view (not C-contiguous)\ntemp2 = dp.stack(ctr_offsets_slice).T\n\n# 3c: device-\u003ehost with \"order='C'\"\n# EXPECTED (per docstring \"works exactly like numpy.asarray\"): C-contiguous NumPy array\n# ACTUAL: order is ignored for dpnp_array, result keeps non-C layout\ntemp3 = dp.asnumpy(temp2, order='C')\n\nprint(\"3a. Testing : temp1: \", bool(temp1.flags['C_CONTIGUOUS']), type(temp1), len(temp1), temp1)\nprint(\"3b. Testing : temp2: \", bool(temp2.flags['C_CONTIGUOUS']), type(temp2), len(temp2), temp2)\nprint(\"3c. Testing : temp3: \", bool(temp3.flags['C_CONTIGUOUS']), type(temp3), len(temp3), temp3)\n\n# Programmatic check to make the failure obvious:\nif not temp3.flags['C_CONTIGUOUS']:\n print(\"\\nBUG: dpnp.asnumpy(dpnp_array, order='C') returned a non-C-contiguous NumPy array.\")\n print(\" strides:\", temp3.strides, \"| shape:\", temp3.shape)\n\n```\n \nOutput from DPNP+DPCTL:\n```bash\ndpnp version: 0.19.0dev3+8.gac795ab9.dirty\n3a. Testing : temp1: True \u003cclass 'dpnp.dpnp_array.dpnp_array'\u003e 7 [[ 0 0 0]\n [ 3 3 3]\n [ 5 5 5]\n [ 7 7 7]\n [10 10 10]\n [11 11 11]\n [12 12 12]]\n3b. Testing : temp2: False \u003cclass 'dpnp.dpnp_array.dpnp_array'\u003e 3 [[ 0 3 5 7 10 11 12]\n [ 0 3 5 7 10 11 12]\n [ 0 3 5 7 10 11 12]]\n3c. Testing : temp3: False \u003cclass 'numpy.ndarray'\u003e 3 [[ 0 3 5 7 10 11 12]\n [ 0 3 5 7 10 11 12]\n [ 0 3 5 7 10 11 12]]\n\nBUG: dpnp.asnumpy(dpnp_array, order='C') returned a non-C-contiguous NumPy array.\n strides: (4, 12) | shape: (3, 7)\n```\n\nOutput from CUPY\n```bash\ncupy version: 13.4.1\n3a. Testing : temp1: True \u003cclass 'cupy.ndarray'\u003e 7 [[ 0 0 0]\n [ 3 3 3]\n [ 5 5 5]\n [ 7 7 7]\n [10 10 10]\n [11 11 11]\n [12 12 12]]\n3b. Testing : temp2: False \u003cclass 'cupy.ndarray'\u003e 3 [[ 0 3 5 7 10 11 12]\n [ 0 3 5 7 10 11 12]\n [ 0 3 5 7 10 11 12]]\n3c. Testing : temp3: True \u003cclass 'numpy.ndarray'\u003e 3 [[ 0 3 5 7 10 11 12]\n [ 0 3 5 7 10 11 12]\n [ 0 3 5 7 10 11 12]]\n```","author":{"url":"https://github.com/abagusetty","@type":"Person","name":"abagusetty"},"datePublished":"2025-08-25T15:43:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/2138/dpctl/issues/2138"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ca94e5cc-26bb-126d-522f-e54e8cadcdef |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB40:6A3DD:128C3D5C:12EEF6B3:696E9900 |
| html-safe-nonce | ad650db2bcd886ed8d11b78199aec1b097fa2deb9529d1d4829ff45581b5ae49 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjQwOjZBM0REOjEyOEMzRDVDOjEyRUVGNkIzOjY5NkU5OTAwIiwidmlzaXRvcl9pZCI6IjE3MTczMzYwMDQ5OTAyNDUxMjAiLCJyZWdpb25fZWRnZSI6InNlYSIsInJlZ2lvbl9yZW5kZXIiOiJzZWEifQ== |
| visitor-hmac | 2f85670c98a109cae0c9fb0c12afe14a6c992cc04fe1f32a1f68b1c1049e8347 |
| hovercard-subject-tag | issue:3352330594 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/IntelPython/dpctl/2138/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7108a824296e04df1f724d4aae500b1abd1afd317230a713f17d11cb741af85e/IntelPython/dpctl/issues/2138 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7108a824296e04df1f724d4aae500b1abd1afd317230a713f17d11cb741af85e/IntelPython/dpctl/issues/2138 |
| og:image:alt | It looks like the order-C is being ignored and the C-contiguous checks fails when using dpnp.asnumpy(). Please refer to the below reproducer and output with dpnp+dpctl & cupy, more specifically 3c ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | abagusetty |
| hostname | github.com |
| expected-hostname | github.com |
| None | fdad15fd2ad43212aa8b8be5f2c2725550f8374ceeeb154a999ad9145b43f3f7 |
| turbo-cache-control | no-preview |
| go-import | github.com/IntelPython/dpctl git https://github.com/IntelPython/dpctl.git |
| octolytics-dimension-user_id | 20491374 |
| octolytics-dimension-user_login | IntelPython |
| octolytics-dimension-repository_id | 279842328 |
| octolytics-dimension-repository_nwo | IntelPython/dpctl |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 279842328 |
| octolytics-dimension-repository_network_root_nwo | IntelPython/dpctl |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 27b23bc056eb973d350fc95afc848757edb9e7a9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width