Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion runtime/compute/cker/include/cker/Shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ class Shape
// Replaces the current shape with a new one defined by dimensions_count and dims_data.
inline void ReplaceWith(int dimensions_count, const int32_t *dims_data)
{
assert(dims_data != nullptr);
// Allow dims_data to be nullptr when dimensions_count is 0,
// because there are no dimensions to copy. For any non-zero dimensions_count,
// dims_data must not be nullptr to ensure valid shape data is provided.
assert(dimensions_count == 0 || dims_data != nullptr);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Einsum kernel, MatMulBCast is used with arguments where the dimensions_count is 0 and dims_data is nullptr. This happens when there are no batch dimensions (e.g., for 2D matrices), so passing an empty dimensions vector (size 0 and nullptr data) is valid.

Resize(dimensions_count);
std::memcpy(DimsData(), dims_data, dimensions_count * sizeof(int32_t));
}
Expand Down