Skip to content

  • 体验新版
    • 正在加载...
  • 登录
  • PaddlePaddle
  • Paddle
  • Issue
  • #11529

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看板
已关闭
开放中
Opened 6月 17, 2018 by saxon_zh@saxon_zhGuest

Implementing lazy execution in tape

Created by: kexinzhao

In Tape, we want to provide the lazy evaluation feature, so that we can use the following code to compute the value of a variable:

auto loss = softmax(linear2(linear1(input)), label); // compile time InferShape & InferVarType
LOG(INFO) << loss.value(); // Run forward up to loss

When value() is called upon a variable, the variable must know the location of the operator handle in the global tape so that tape run from the current op position up to the location of the target op handle.

There are two ways of adding the needed info in variable class for lazy exe:

  1. Add a int op_position_ field

    • Pros: tape is implemented as a vector of op handles and has a built-in current_position field. A op_position_ field in variable is easy to implement and understand by comparing it with current_location and overall size of the tape.
    • Cons: OpHandle does not store its position in the tape. If we later want to do kernel fusion or something similar to change the vector<ophandle> in tape, the position of the ops needed to updated for variables generated by many ops.
  2. Add a weak_ptr<OpHandle> op_ field. (we don't consider shared_ptr here because there maybe cyclic referencing issue between OpHandle and Variable)

    • Pros: If there is change in vector<ophandle> in tape, we mostly don't need to change Variable.
    • Cons:
      • weak_ptr may occupy more memory than size_t.
      • Hard to implement and error prone: we need to use while to compare the current OPHandle and the target OpHandle and run it until we hit the target position, but what if the variable's correponding OP is before the current location or there is no such OpHandle in the current tape.

Based on the above comparison, I plan to go with the first solution.

指派人
分配到
无
里程碑
无
分配里程碑
工时统计
无
截止日期
无
标识: paddlepaddle/Paddle#11529
渝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