dmlc / dlpack

common in-memory tensor structure
https://dmlc.github.io/dlpack/latest
Apache License 2.0
905 stars 133 forks source link

Add a comment for complex numbers #66

Closed leofang closed 3 years ago

leofang commented 3 years ago

Based on the ongoing discussion in https://github.com/pytorch/pytorch/pull/55365, we think it's best to clarify the expectation for complex numbers. There could be two legit ways to construct them:

complex64 -> type_code = 5, bits=64, lanes=1

or

complex64 -> type_code = 5, bits=32, lanes=2

While the latter is natural if one considers complex64=float2 (a 2-vector of floats), the former is natural to stress we are dealing with single datatype, not a compound/vector one.

cc: @rgommers @emcastillo

tqchen commented 3 years ago

likely complex64 -> type_code = 5, bits=64, lanes=1 is the right approach, so that we can use lanes for vectorized types later

leofang commented 3 years ago

Thanks, @tqchen! Both CuPy (https://github.com/cupy/cupy/pull/5045) and PyTorch (https://github.com/pytorch/pytorch/pull/55365) will follow this convention.

tqchen commented 3 years ago

@leofang can you send a PR to dlpack.h to clarify?

leofang commented 3 years ago

@tqchen this is already a PR 😂

tqchen commented 3 years ago

oops, sorry. Thanks @leofang

leofang commented 3 years ago

haha thanks @tqchen