Skip to content

  • 体验新版
    • 正在加载...
  • 登录
  • PaddlePaddle
  • Paddle
  • 合并请求
  • !26886

P
Paddle
  • 项目概览

PaddlePaddle / Paddle
大约 2 年 前同步成功

通知 2325
Star 20933
Fork 5424
  • 代码
    • 文件
    • 提交
    • 分支
    • Tags
    • 贡献者
    • 分支图
    • Diff
  • Issue 1423
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 543
  • Wiki 0
    • Wiki
  • 分析
    • 仓库
    • DevOps
  • 项目成员
  • Pages
P
Paddle
  • 项目概览
    • 项目概览
    • 详情
    • 发布
  • 仓库
    • 仓库
    • 文件
    • 提交
    • 分支
    • 标签
    • 贡献者
    • 分支图
    • 比较
  • Issue 1,423
    • Issue 1,423
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 543
    • 合并请求 543
  • Pages
  • 分析
    • 分析
    • 仓库分析
    • DevOps
  • Wiki 0
    • Wiki
  • 成员
    • 成员
  • 收起侧边栏
  • 动态
  • 分支图
  • 创建新Issue
  • 提交
  • Issue看板

refine paddle.stack !26886

  • Report abuse
!26886 已合并 9月 01, 2020 由 saxon_zh@saxon_zh 创建
#<User:0x00007ff7d6a2c6e8>
  • 概览 0
  • 提交 6
  • 变更 3

Created by: zhiqiu

PR types

Bug fixes

PR changes

APIs

Describe

paddle.stack does not support a single Tensor as input anymore.

Before this PR, paddle.stack accepts a single Tensor x as input, and implicitly convert it to a list of Tensor [x].

This is not a good design since it violates the single responsibility. The responsibility of stack is to stack several Tensors, so this PR prohibits that usage.

An Exception, input as Variable of LOD_Tensor_Array type in static graph is still ok, since it means array of tensors.

For example, the following code will result in an error.

import paddle

paddle.disable_static()
x1 = paddle.rand([2,2])
result = paddle.stack(x1, axis=0)
  • dygraph
Traceback (most recent call last):
  File "test_stack.py", line 8, in <module>
    result = paddle.stack(x1, axis=0)
  File "/usr/local/lib/python3.5/dist-packages/paddle/tensor/manipulation.py", line 468, in stack
    return layers.stack(x, axis, name)
  File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/layers/nn.py", line 10055, in stack
    return core.ops.stack(x, 'axis', axis)
paddle.fluid.core_avx.EnforceNotMet: 

--------------------------------------
C++ Traceback (most recent call last):
--------------------------------------
0   paddle::platform::EnforceNotMet::EnforceNotMet(paddle::platform::ErrorSummary const&, char const*, int)
1   paddle::platform::GetCurrentTraceBackString[abi:cxx11]()

----------------------
Error Message Summary:
----------------------
InvalidArgumentError: stack(): argument 'X' (position 0) must be list of Tensors, but got Tensor (at /Paddle/Paddle/paddle/fluid/pybind/op_function.h:88)
  • static graph
Traceback (most recent call last):
  File "test_stack.py", line 8, in <module>
    result = paddle.stack(x1, axis=0)
  File "/usr/local/lib/python3.5/dist-packages/paddle/tensor/manipulation.py", line 468, in stack
    return layers.stack(x, axis, name)
  File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/layers/nn.py", line 10058, in stack
    raise TypeError("The type of '%s' in %s must be %s, but received %s" % ( 'x', 'stack', 'list[Tensor] or tuple[Tensor]', type(x)))
TypeError: The type of 'x' in stack must be list[Tensor] or tuple[Tensor], but received <class 'paddle.fluid.framework.Variable'>
指派人
分配到
审核者
Request review from
无
里程碑
无
分配里程碑
工时统计
标识: paddlepaddle/Paddle!26886
Source branch: github/fork/zhiqiu/dev/refine_stack
渝ICP备2023009037号

京公网安备11010502055752号

网络110报警服务 Powered by GitLab CE v13.7
开源知识
Git 入门 Pro Git 电子书 在线学 Git
Markdown 基础入门 IT 技术知识开源图谱
帮助
使用手册 反馈建议 博客
《GitCode 隐私声明》 《GitCode 服务条款》 关于GitCode
Powered by GitLab CE v13.7