-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Cosine Similarity Paddle Function. #1061
Conversation
2290502
to
294042f
Compare
See the License for the specific language governing permissions and | ||
limitations under the License. */ | ||
|
||
#pragma once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CosSimVecMatLayer.h还是跟CosSimVecMatLayer.cpp写在一起好,并没有另外一个文件需要include "CosSimVecMatLayer.h"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
See the License for the specific language governing permissions and | ||
limitations under the License. */ | ||
|
||
#include <gtest/gtest.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test的写法还是比较复杂,对于只是Check CPU/GPU是否一致的test case还是得实现一个更简便的方法来做。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
a7b2929
to
70733b5
Compare
70733b5
to
e28dc0c
Compare
@hedaoyuan , 用新的FunctionTest重写了一下unit test, address 了你的comments.如果没有什么问题的话,可否approve一下(你新的两个op可以再开一个PR写一下)? |
@@ -117,17 +127,25 @@ void CosSimVecMatLayer::forward(PassType passType) { | |||
} | |||
|
|||
MatrixPtr outV = getOutputValue(); | |||
|
|||
CHECK(outV && inV0 && inV1); | |||
REGISTER_TIMER_INFO("FwCosVMTimer", getName().c_str()); | |||
for (size_t i = 0; i < batchSize; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个for (size_t i = 0; i < batchSize; i++)
可以放到CosSimForwardFunc里面,同时Layer可以去掉这些tmp matrix。backward也一样可以去掉for (size_t i = 0; i < batchSize; i++)
。
CosSimForwardFunc区分是被CosSimVecMatLayer还是CosSimLayer调用应该是通过inputs[0],inputs[1]的参数类型上判断(shape不一样)。另外,也不建议在CosSimForwardFunc里面增加for (size_t i = 0; i < batchSize; i++)
,API应该可以直接支持。
e28dc0c
to
ae3ae08
Compare
* feat: add cnn_dailymail dataset * fix: correct error message * refactor: use paddlenlp decompress api * docs: add doc for cnn_dm
Cosine Similarity Task for Paddle Function APIs (#977)