huggingface / huggingface/candle

Additional Tensor Operations Needed

Open
#1,359 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
21k
Forks
1.8k
Avg merge
16h 42m
Merged PRs (30d)
25

Description

I am re-implementing the famous NeRF (https://github.com/bmild/nerf) model in candle. During my experience with candle, I found the following Tensor operations missing.
* `torch.linspace`
* `torch.cumprod`
* `torch.searchsorted`
* `torch.sort`

I am able to find a workaround for `torch.linspace` and `torch.cumprod`, but `torch.searchsorted` and `torch.sort` look formidable. Are there recommended ways to implement that efficiently? Thanks.

Current workarounds for linspace and cumprod

* `linspace`: directly taken from the stable-diffusion example.
* `cumprod`: modified from https://github.com/mokeyish/candle-ext/blob/1b38cb1b9faa9694c204d46788fd70d479109bab/src/cumsum.rs#L6-L28 changing the add operation to multiply operation. Not the optimal solution, I admit.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the stable-diffusion example for the linspace workaround and the referenced src/cumsum.rs implementation used for cumprod. Then inspect Candle's tensor operation entry points to determine how searchsorted and sort would fit; done means providing efficient implementations for the requested missing operations with appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.