Add some functions to PaddleAPI.h#1013
Conversation
| @@ -0,0 +1,6 @@ | |||
| ___fc_layer_0__.w0 | |||
| a.cpuSequenceDims = m->cast<paddle::IVector>(vec->getSharedPtr()); | ||
| } | ||
|
|
||
| float Arguments::sumCosts() const { |
There was a problem hiding this comment.
Function names should be Camel Cased: https://google.github.io/styleguide/cppguide.html#Function_Names
是不是至少对于新加的函数,应该符合code style,这样至少提醒大家关注规范;现有的函数,可以以后写个工具重命名?
There was a problem hiding this comment.
麻烦review一下这个 baidu-adu/cpp-primer-digest#1
这个是Paddle目前的命名风格。
| IVector* vec) throw(RangeError); | ||
| void setSlotSequenceDim(size_t idx, IVector* vec) throw(RangeError); | ||
|
|
||
| float sumCosts() const; |
There was a problem hiding this comment.
PR的description里说明一下为什么需要增加这几个函数吧。加了之后能有什么好处:
- sumCosts
- load
- save
|
不好意思,休假耽误了code style的讨论。我刚才comment了https://github.com/PaddlePaddle/cpp-primer-digest/pull/1: baidu-adu/cpp-primer-digest#1 (review) |
|
|
||
| void Parameter::setValueUpdated() { m->getPtr()->setValueUpdated(); } | ||
|
|
||
| bool Parameter::save(const std::string& filename) const { |
There was a problem hiding this comment.
我之前一直迟迟没有approve这个PR的一个主要原因是,save/load(filename) 这样的methods不是一个好的设计。
首先这些methods不容易被unit test。除非我们有一个in-memory mock filesystem。但实际上我们不需要这么复杂的test facility。而且这些methods里的内容经常和网络传输methods里的内容重复——都是要 serialize/deserialize class memebers。
一个比较常见的设计是用 serialize/deserialize 来代替 save/load:
std::string serialize();
error deserialize(const std::string& input);
这样一来容易unit test,二来容易用于网络传输和磁盘I/O:
File f("/tmp/a");
Parameters ps;
f.write(ps.serialize());
There was a problem hiding this comment.
非常有道理!现在的接口是不适合分布式化的,serialize/deserialize才能更方便传输。目前暴露的接口是老接口,仅仅是暴露出来,下一步提供c-api的时候可以考虑重构。
These functions are used to implement training progress in Python. Used by PR #1005