Size the memory of empty DLPack tensors on oneAPI devices as one element #3203
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 221 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.323
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3203"
general
weight: 0.35
vlad-perevezentsev
This PR fixes the memory size that
dpnp.tensor.from_dlpackanddpnp.from_dlpackgive an empty DLPack tensor with more than one dimension on a oneAPI device.from_dlpack_capsulesizes the memory of a tensor by the span from its lowest to its highest element offset. A dimension of length 0 added nothing to that span, but the other dimensions still did, so an empty tensor of shape(0, n)was sized asnelements. With a NULL data pointer, which DLPack asks for in a tensor of size zero and which #3197 made importable, that size is what gets allocated for the result: 4 MiB for shape(0, 220)ofint32and 8 GiB for(0, 231). With a data pointer, the imported memory claimed more than the producer allocated: 4 MiB for an emptydpnp.tensorarray of shape(0, 2**20), whose buffer is 4 bytes. A tensor with a dimension of length 0 now spans no elements and gets one element, asusm_ndarraydoes for an empty shape.Two tests are added. Importing an empty tensor with a NULL data pointer must allocate one element, and importing an empty
dpnp.tensorarray must not claim more memory than the array's buffer. Without the fix, all five cases fail.#3183 changes the same loop to accept NULL strides, so whichever of the two PRs lands second needs a small rebase.