Skip to content
37 changes: 37 additions & 0 deletions swe-paddle/tasks/PaddlePaddle__Paddle-64320/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# PaddlePaddle__Paddle-64320

This directory converts Paddle PR #64320 into a SWE-Paddle community task candidate.

## Source

| Field | Value |
| --- | --- |
| Repo | `PaddlePaddle/Paddle` |
| PR | [64320](https://github.com/PaddlePaddle/Paddle/pull/64320) |
| PR title | 【Hackathon 6th No.17】为 Paddle 新增 sparse.mask_as API -part |
| Base commit | `605f5e20305db0e4932a20d3e0e6cf7d7d9631d8` |
| Merged at | `2024-06-07T09:10:27Z` |
| Hackathon | `6th` task `17` |
| Task type | `feature_enhancement` |
| Resource | CPU + GPU |

## Summary

Add `sparse.mask_as` API for Paddle, which extracts values from a dense tensor at positions indicated by a sparse mask and outputs a sparse tensor.

## Files

- `proposal.md`: candidate proposal for maintainer triage.
- `instruction.md`: self-contained problem statement for the coding agent.
- `solution/code.patch`: gold patch from the merged PR.
- `tests/test.patch`: test patch exposing the target behavior.
- `tests/test.sh`: minimal target test command.
- `environment/README.md`: environment notes for reproduction.

## Verification

```bash
bash tests/test.sh
```

Expected behavior: applying `tests/test.patch` to `base_commit` should fail on the target behavior; applying both `tests/test.patch` and `solution/code.patch` should pass the target tests.
27 changes: 27 additions & 0 deletions swe-paddle/tasks/PaddlePaddle__Paddle-64320/environment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Environment Notes

This candidate is part of the SWE-Paddle task set.

## Expected Environment

- Repository: `PaddlePaddle/Paddle`
- Base commit: `605f5e20305db0e4932a20d3e0e6cf7d7d9631d8`
- Resource: CPU + GPU
- GPU required: yes (CUDA kernels are included)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

具体的环境信息(cuda版本)之类的提供一下~

- Build path: Paddle source checkout at the base commit. This task involves C++ CPU kernels, CUDA GPU kernels, Python API, and YAML op definitions, so source build is required.

## Run Order

1. Check out `PaddlePaddle/Paddle` at the base commit.
2. Apply `tests/test.patch`.
3. Run `bash tests/test.sh`; the target behavior should fail before the fix.
4. Apply `solution/code.patch`.
5. Run `bash tests/test.sh` again; the target behavior should pass after the gold patch.

## Minimal Test Command

```bash
bash tests/test.sh
```

The verifier is responsible for deriving stable F2P and P2P node IDs from repeated runs.
24 changes: 24 additions & 0 deletions swe-paddle/tasks/PaddlePaddle__Paddle-64320/instruction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 新增 sparse.mask_as API

## 详细描述

为 Paddle 稀疏计算新增 `sparse.mask_as` API。该 API 根据给定的稀疏 mask(SparseCooTensor 或 SparseCsrTensor),从稠密 Tensor 中提取对应非零位置的值,输出一个与 mask 具有相同 indices 的稀疏 Tensor。

要求支持:
- COO 格式:支持 1-D ~ 4-D 输入
- CSR 格式:支持 2-D 和 3-D 输入(其他维度应报错)
- 数据类型:float32, float64, int32, int64, complex64, complex128, int8, int16, float16
- 前向计算 + 反向梯度

## 验收说明

- `paddle.sparse.mask_as(x, mask)` 应能正确根据 mask 的 indices 从稠密 Tensor x 中提取值
- 支持 COO 和 CSR 两种稀疏格式
- CSR 格式仅支持 2-D 和 3-D,其他维度应报错
- 反向梯度应正确传播

## Acceptance Criteria

- The behavior described above should be fixed.
- Existing valid behavior should remain unchanged.
- Do not satisfy the task by deleting tests, weakening assertions, or bypassing validation broadly.
Loading