-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Add ScaleSubRegion Layer. #5488
Conversation
* input_1: Indices value to specify the location an shape of the | ||
* region. | ||
*/ | ||
class MulValueLayer : public Layer { |
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.
MulValueLayer
会不会让人产生误解?ScaleLayer
? SubScaleLayer
?
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.
Changed to ScaleSubRegionLayer.
paddle/function/MulValueOpTest.cpp
Outdated
<< " channels=" << channels << " imgSizeH=" << imgSizeH | ||
<< " imgSizeW=" << imgSizeW; | ||
|
||
for (bool test_grad : {false}) { |
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_grad
-> testGrad
, 和前边变量保持一致?
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.
paddle/function/MulValueOpTest.cpp
Outdated
<< " channels=" << channels << " imgSizeH=" << imgSizeH | ||
<< " imgSizeW=" << imgSizeW; | ||
|
||
for (bool test_grad : {false}) { |
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.
为什么不测试Grad呢?
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.
@@ -340,6 +345,10 @@ class Compare2Function { | |||
initArg(*func1Inputs_[i]); | |||
} | |||
|
|||
if (initArgsCallback_ != nullptr) { | |||
initArgsCallback_(*func1Inputs_[i], 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.
如果input[1]
的初始化依赖input[0]
,怎么办?把initArgsCallback_
放到循环外,整个func1Inputs_
作为参数,会不会更灵活些?
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.
Callback的场景比较有限,如果出现你说的情况,可以到时再考虑扩展
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.
ok.
paddle/function/MulValueOpTest.cpp
Outdated
|
||
for (size_t i = 0; i < numSamples; ++i) { | ||
size_t offset = i * 6; | ||
data[offset] = firstHalf ? 1 : (int)channels / 2; |
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.
不需要(int)
吧?
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.
channelsNum_ = imgV->getWidth() / spatialSize; | ||
shape_ = TensorShape({batchSize, channelsNum_, imgH_, imgW_}); | ||
|
||
resetOutput(batchSize, imgV->getWidth()); |
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.
是不是应该设置下output
的 FrameHeight
和 FrameWidth
? 下个layer有可能用到。
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.
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.
paddle/gserver/layers/MulValueLayer.h
paddle/gserver/layers/MulValueLayer.cpp
没有删除。
paddle/function/MulValueOp.cpp
Outdated
namespace paddle { | ||
|
||
template <> | ||
void MulValue<DEVICE_TYPE_CPU>(real* outputs, |
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.
MulValue
-> ScaleSubRegion
?
paddle/function/MulValueOpTest.cpp
Outdated
for (size_t numSamples : {5, 32}) { | ||
for (size_t channels : {5, 5, 32}) { | ||
for (size_t imgSizeH : {5, 33, 100}) { | ||
for (size_t imgSizeW : {5, 32, 96}) { |
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.
减少channels,imgSizeH,imgSizeW
遍历吧, 减少for
循环的次数,减少单测时间。
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.
LGTM.
Resolves #5416