-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checking vector size for a power of 2 #2491
base: main
Are you sure you want to change the base?
Conversation
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
1 similar comment
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
python/utils/OpaqueArguments.h
Outdated
@@ -99,6 +99,14 @@ inline py::args simplifiedValidateInputArguments(py::args &args) { | |||
if (shape.size() != 1) | |||
throw std::runtime_error("Cannot pass ndarray with shape != (N,)."); | |||
|
|||
// Vector size validation | |||
size_t size = shape[0].cast<size_t>(); | |||
if (size == 0 || (size & (size - 1)) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is only valid if the argument is used as an initializer (state) for a register of qubits. That is, we are allowed to pass a vector of any length of floats to a kernel in general.
Signed-off-by: Sachin Pisal <[email protected]>
Signed-off-by: Sachin Pisal <[email protected]>
Signed-off-by: Sachin Pisal <[email protected]>
4257988
to
a1dda5a
Compare
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
Fixes #2490
Before
After
Test result