candle icon indicating copy to clipboard operation
candle copied to clipboard

Add AVG Pooling cpu implementation

Open WenheLI opened this issue 1 year ago • 4 comments

Try to resolve https://github.com/huggingface/candle/issues/2294

WenheLI avatar Jun 28 '24 21:06 WenheLI

@WenheLI I think this is correct.

EricLBuehler avatar Jun 29 '24 00:06 EricLBuehler

@EricLBuehler - Thanks! I guess another question is that in the CPU backend implementation, we should be able to speed this up by using vectorization. Not sure in candle's codebase, do we already have some infrastructure that can help us?

WenheLI avatar Jun 29 '24 01:06 WenheLI

Hi @WenheLI, I think you could use something like Rayon, just replace the for loops (probably just choose one to replace as rayon uses the number of CPU cores as the number of threads by default) and replace .iter() with .par_iter().

EricLBuehler avatar Jun 29 '24 07:06 EricLBuehler

Thanks! Added vectorization. Wondering if someone can I take a look and review this?

WenheLI avatar Jun 29 '24 18:06 WenheLI