Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use param header to save mkldnn format info #3516

Merged
merged 2 commits into from
Aug 16, 2017

Conversation

tensor-tang
Copy link
Contributor

update doc

@@ -101,6 +101,7 @@ if use_mkldnn
5. 在**Argument**里添加两个`MkldnnMatrixPtr`,取名为`mkldnnValue`和`mkldnnGrad`,用于存放`MkldnnLayer`会用到的memory buffer。 并且添加函数cvt(会修改为一个更加合适的函数名),用于处理"CPU device"和"MKL-DNN device"之间memory的相互转化。
6. 在父类`Layer`中的`getOutput`函数中添加一段逻辑,用于判断`deviceId`,并针对device在MKL-DNN和CPU之间不统一的情况,做一个前期转换。 也就是调用`Argument`的cvt函数把output统一到需要的device上。
7. 在原来的`FLAGS`中添加一个`use_mkldnn`的flag,用于选择是否使用MKL-DNN的相关功能。
8. 关于MKLDNN参数的保存。由于MKLDNN参数的格式与PaddlePaddle原有的格式存在不一样的情况,所以需要在保存参数时同时保存该格式信息。目前准备扩展`Header`里面的`int32_t version; // = 0, file format version`信息。这个`version`值,不管是在v1还是在v2里面,一直保存的是0。所以可以充分利用这个信息,定义一个枚举处理所有MKLDNN的参数格式,`MKLDNNLayer`就可以知道得到的参数是哪种格式的了。只不过目前v2里面是写的固定值0,而不是保存的`Header`本身,这一点相信v2未来应该会优化的。
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. 准备扩展struct Header里面的int32_t version信息。
  • 需要加上链接,说明是在哪个代码里面的?或者贴讨论的issue号。不然还是看不懂说的是哪里。
  • 里面的注释去掉,这个注释不合理,后面要改掉。
  1. “只不过目前v2里面是写的固定值0,而不是保存的Header本身,这一点相信v2未来应该会优化的。”这句可以去掉,为了mkldnn的格式,这块也要马上做修改,不能写死。

Copy link
Contributor Author

@tensor-tang tensor-tang Aug 16, 2017

Choose a reason for hiding this comment

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

Thanks, done.

另外我想问下,我可以把code里面的version名字改为format吗?现在感觉这个名字更加贴切。

Copy link
Contributor

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

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

LGTM.

另外我想问下,我可以把code里面的version名字改为format吗?现在感觉这个名字更加贴切。

个人觉得还是不要改。改成format后,就仅仅局限在格式上面了。version可能还会有别的用处。

@luotao1 luotao1 merged commit c94a324 into PaddlePaddle:develop Aug 16, 2017
@tensor-tang
Copy link
Contributor Author

好的~

“只不过目前v2里面是写的固定值0,而不是保存的Header本身,这一点相信v2未来应该会优化的。”这句可以去掉,为了mkldnn的格式,这块也要马上做修改,不能写死。

另外,我备注下,需要加一个task, 我们要让v2不能仅仅只保存version为0的值。

@tensor-tang tensor-tang deleted the doc branch August 16, 2017 06:26
@luotao1
Copy link
Contributor

luotao1 commented Aug 16, 2017

另外,我备注下,需要加一个task, 我们要让v2不能仅仅只保存version为0的值

#3519

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants