← 返回 tesla 的题目列表Batched Trajectory Suffix Sum
类型:qbank
Autopilot AI Foundation coding task over trajectory tensors: given input shaped `[batch, num_waypoint, 2]`, compute a suffix-style aggregate with output shaped `[batch, num_waypoint]`.
Requirements
Input tensor shape: [batch, num_waypoint, 2].
Output tensor shape: [batch, num_waypoint].
Compute a suffix-sum-style value over waypoints for each batch item.
The exact target quantity was not fully leaked; prepare for cumulative distance-to-end, remaining displacement, or remaining scalar score variants.
Notes
The likely implementation pattern is vectorized reverse cumulative aggregation over the waypoint dimension.
Clarify whether the aggregate is over raw coordinates, per-step displacement magnitudes, or an externally supplied per-waypoint scalar.
For remaining path length, compute deltas between adjacent waypoints, convert each delta to a norm, then reverse-cumsum those segment lengths with a zero at the final waypoint.
With NumPy / PyTorch, avoid Python loops over batch. Reverse the waypoint axis, apply cumulative sum, then reverse back.
Preparation
Implement three variants over a [B, T, 2] tensor: remaining displacement vector, remaining scalar path length, and suffix sum of a supplied [B, T] score tensor.
Write shape tests for T=1, repeated waypoints, multiple batches, and float precision on long trajectories.
Practice explaining why np.flip(np.cumsum(np.flip(x, axis=1), axis=1), axis=1) works and where segment arrays need padding.