Skip to content

Add complex numbers#849

Open
opfromthestart wants to merge 2 commits intochelsea0x3b:mainfrom
opfromthestart:complex
Open

Add complex numbers#849
opfromthestart wants to merge 2 commits intochelsea0x3b:mainfrom
opfromthestart:complex

Conversation

@opfromthestart
Copy link
Copy Markdown
Contributor

@opfromthestart opfromthestart commented Aug 13, 2023

Closes #821.
I had to use a proxy object to implement cuda traits. It built with cargo build -F complex,cuda,nightly,f16

Comment thread src/dtypes/mod.rs
Comment thread src/dtypes/mod.rs
Comment on lines +115 to +118
#[cfg(feature = "cuda")]
unsafe impl ValidAsZeroBits for Complex {}
#[cfg(feature = "cuda")]
unsafe impl DeviceRepr for Complex {}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We can add these to cudarc in a PR there behind a feature flag, that should allow us to not need the wrapper type, right?

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.

I was unaware that you controlled cudarc. That would work yes.

@chelsea0x3b
Copy link
Copy Markdown
Owner

How does this interact with cuda kernels?

@opfromthestart
Copy link
Copy Markdown
Contributor Author

opfromthestart commented Aug 15, 2023

I don't think it would work at all with cuda kernels atm. Not familiar with how cuda types work, can you overload operators for a custom complex struct?

@chelsea0x3b
Copy link
Copy Markdown
Owner

I don't think it would work at all with cuda kernels atm. Not familiar with how cuda types work, can you overload operators for a custom complex struct?

We could potentially just merge this for Cpu and make sure we get compile errors for cuda.

You can overload operators in c++, but I'm not sure that's sufficient to make the kernels work in the same way as they do in rust land.

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.

Add support for complex tensors

2 participants