Skip to content

Commit 0c55c99

Browse files
authored
[compute/cker] Fix einsum test error (#15161)
This commit allows dims_data to be nullptr when dimensions_count is 0. ONE-DCO-1.0-Signed-off-by: ragmani <ragmani0216@gmail.com>
1 parent b11cce8 commit 0c55c99

File tree

1 file changed

+4
-1
lines changed
  • runtime/compute/cker/include/cker

1 file changed

+4
-1
lines changed

runtime/compute/cker/include/cker/Shape.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ class Shape
205205
// Replaces the current shape with a new one defined by dimensions_count and dims_data.
206206
inline void ReplaceWith(int dimensions_count, const int32_t *dims_data)
207207
{
208-
assert(dims_data != nullptr);
208+
// Allow dims_data to be nullptr when dimensions_count is 0,
209+
// because there are no dimensions to copy. For any non-zero dimensions_count,
210+
// dims_data must not be nullptr to ensure valid shape data is provided.
211+
assert(dimensions_count == 0 || dims_data != nullptr);
209212
Resize(dimensions_count);
210213
std::memcpy(DimsData(), dims_data, dimensions_count * sizeof(int32_t));
211214
}

0 commit comments

Comments
 (0)