Skip to content
Discussion options

You must be logged in to vote

Essentially any time you implement an algorithm with an explicit loop, you should expect compilation and execution times to be slower than necessary.

I think the main bottleneck here is your use of a loop within hilbertTransform. Instead, you should use broadcasting:

def hilbertTransform(f, grid, x, hilb_grid, h):
    eval_pt = (x - hilb_grid * h) / h
    return jnp.sum(jnp.interp(hilb_grid * h, grid, f) * jnp.sinc(eval_pt / 2) * jnp.sin(eval_pt / 2))

Also, you should delete the block_until_ready() calls in your functions, as they are preventing asynchronous dispatch from speeding up your loops.

I think your other loops could probably also be replaced with broadcasting operations as well,…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@JoshPilipovsky
Comment options

@JoshPilipovsky
Comment options

Answer selected by JoshPilipovsky
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants