Skip to content

Conversation

@Nader-Rahhal
Copy link
Collaborator

Just doing a basic cast from int -> float64 -> int.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request enables integer matrix multiplication for NDArray types by implementing a conversion-based approach. Previously, integer matrix multiplication was not supported and would throw an error.

Changes:

  • Added integer matrix multiplication support by converting integers to Float64, performing the multiplication, then converting back
  • Updated test cases to verify integer matrix multiplication works correctly
  • Removed test that verified integer matrix multiplication threw an error

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/ndarray/binary.jl Replaced error-throwing function with implementation that converts integers to Float64 for multiplication, then converts back to original integer type
test/tests/gemm.jl Updated integer test case to verify integer matrix multiplication works instead of testing that it throws an error

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 136 to 142
IntermediateType = Float64

A_float = cuNumeric.as_type(rhs1, IntermediateType)
B_float = cuNumeric.as_type(rhs2, IntermediateType)

C_float = A_float * B_float
C_int = cuNumeric.as_type(C_float, T)
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

Converting through Float64 may cause precision loss or overflow for large integer values. For Int32 values, Float64 has 53 bits of mantissa precision, which can represent all Int32 values exactly. However, for Int64, values larger than 2^53 will lose precision. Consider documenting this limitation or adding a check for Int64 matrices with large values.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants