srush / Tensor-Puzzles

Solve puzzles. Improve your pytorch.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Puzzle 12 log_2 implementation?

TrentBrick opened this issue · comments

I want log_2() function. Any tips on how I can implement this with numba? It looks like even the natural log doesn't run?

Eg. int(math.log(size)) returns:

LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)
No definition for lowering <built-in function log>(int64,) -> float64

File "<ipython-input-235-5ed9de693fee>", line 9:
    def call(out, a, size: int) -> None:
        <source elided>

        num_steps = int(math.log(size))
        ^

During: lowering "$58call_method.25 = call $54load_method.23(size, func=$54load_method.23, args=[Var(size, <ipython-input-235-5ed9de693fee>:4)], kws=(), vararg=None)" at <ipython-input-235-5ed9de693fee> (9)

Sorry I meant to post this in GPU Puzzles!