Does math.log2 not work on uint8? #1736
Locked
MartinStuwe
started this conversation in
General
Replies: 1 comment 1 reply
-
If you're just counting bits, maybe something in here would be helpful: https://docs.modular.com/mojo/stdlib/math/bit.html |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I tried to learn how to implement the calculation of entropies with math.log2, and it seems like math.log2 doesn't work with DType.uint8.
I got:
log2DType.uint8, 8
^
/__w/modular/modular/Kernels/mojo/stdlib/math/math.mojo:1340:1: note: no viable expansions found
/__w/modular/modular/Kernels/mojo/stdlib/math/math.mojo:1355:42: note: call expansion failed - no concrete specializations
/__w/modular/modular/Kernels/mojo/stdlib/math/math.mojo:1256:1: note: no viable expansions found
/__w/modular/modular/Kernels/mojo/stdlib/math/math.mojo:1312:41: note: constraint failed: neginf only support on floating point types
I changed my code to use float32 and it worked.
from math import log2
I mean the log2 operation outputs floats, thus float32 makes sense, but shouldn't it be possible to use as input an uint8 vector?
Another question, why is log2 only defined for SIMD data types? Is it for performance reasons and thus all non logical math functions are defined with SIMD types?
Solved with:
Beta Was this translation helpful? Give feedback.
All reactions