Closed
[Bug-Report|缺陷反馈]: lrelu 参数转发、异常源码位置清理、历史目录保留及 argsort 默认值文档问题 #3685
AidenAdd on Oct 28Closed at 29 days ago
Oct 28 Associated pull request
Oct 29 Assign tsungl4 as responsible person
Oct 29 Assign chen_chenn as responsible person
Oct 29 Assign songle1 as responsible person
29 days ago changed custom state from 进行中 to 已完成
29 days ago Close issue
29 days ago changed custom state from 已完成 to 已解决
29 days ago Added label: resolved


Describe the current behavior / 问题描述 (Mandatory / 必填)
1. Tensor.lrelu 参数转发及输入参数名不一致
python/pypto/tensor.py中的成员方法多声明了other,并将三个位置参数转发给只接收两个参数的pypto.lrelu:def lrelu(self, other: 'Tensor', negative_slope=0.01): return pypto.lrelu(self, other, negative_slope)默认调用缺少必填的
other;传入位置斜率时又会向底层传递多余参数,成员方法无法正常使用。python/pypto/op/math.py中pypto.lrelu首参数名为other,中文文档为input,docstring 为a。按文档使用input=关键字会失败,斜率默认值的注释也未准确表达0.01。2. 异常后源码位置状态未清理
op_wrapper和source_location在set_source_location()与clear_source_location()之间没有使用try/finally。被包装函数抛异常后,深度计数器未恢复,后续算子沿用旧 span,报错位置指向之前失败的调用点。涉及
python/pypto/_op_wrapper.py、python/pypto/_utils.py。3. 历史目录清理误删最新目录
framework/src/utils/file_utils.cpp中RemoveOldDirectories(path, prefix, kept)按修改时间升序排列,再从下标kept开始删除,导致保留最旧的目录、删除最新的目录。CreateRunDataDir以kept=127调用;目录超过保留上限时,最近运行的 rundata 和 dump 数据可能被删除。4. argsort 文档默认值与实现不一致
docs/zh/api/tensor_api/operation/pypto-argsort.md将descending默认值写为True,但python/pypto/op/comparison.py实现的默认值为False。用户按文档理解默认降序,实际获得升序索引。Environment / 环境信息 (Mandatory / 必填)
Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)
Describe the expected behavior / 预期结果 (Mandatory / 必填)
Tensor.lrelu移除多余的other参数,仅向底层传递当前张量和negative_slope。默认调用、位置参数调用及关键字参数调用均可正常使用;pypto.lrelu输入参数名统一为input,实现、docstring 和文档保持一致,默认斜率明确为0.01。op_wrapper和source_location均通过try/finally保证源码位置状态清理,异常正常向上传播。最外层调用结束后深度恢复为 0,后续算子使用自身调用位置。RemoveOldDirectories保留修改时间最新的kept个匹配目录,删除较旧目录;不匹配前缀的目录及普通文件不受影响。正确处理kept=0、等于目录数及大于目录数等边界情况。descending=False,默认按升序返回索引。Related log / screenshot / 日志 / 截图 (Mandatory / 必填)
1. lrelu 调用错误
按照文档使用
input=关键字调用:2. 异常后源码位置状态残留
异常后深度由 0 变为 1,后续正常算子的 span 从自身调用行 21 变为失败调用行 35。
3. 历史目录清理结果
4. argsort 默认值差异
Special notes for this issue/备注 (Optional / 选填)
对应修复 PR:#7206。