(a, t, x_shape)
| 59 | return out.reshape(b, *((1,) * (len(x_shape) - 1))) |
| 60 | |
| 61 | def extract_and_interpolate_into_tensor(a, t, x_shape): |
| 62 | b, *_ = t.shape |
| 63 | # t can be float here, linearly interpolate between left and right index |
| 64 | t = t.clamp(0, a.shape[-1] - 1) |
| 65 | left_idx = t.long() |
| 66 | right_idx = (left_idx + 1).clamp(max=a.shape[-1] - 1) |
| 67 | left_val = a.gather(-1, left_idx) |
| 68 | right_val = a.gather(-1, right_idx) |
| 69 | t_ = t - left_idx.float() |
| 70 | out = left_val * (1 - t_) + right_val * t_ |
| 71 | return out.reshape(b, *((1,) * (len(x_shape) - 1))) |
nothing calls this directly
no outgoing calls
no test coverage detected