Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit59ca444

Browse files
authored
Merge pull request#23560 from WanliZhong:eltwise_cuda_bug
DNN/CUDA: Solve the bug of same shape broadcast with CUDA
2 parents04d71da +46991bc commit59ca444

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

‎modules/dnn/src/cuda/eltwise_ops.cu‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void eltwise_op(const Stream& stream, TensorSpan<T> output, TensorView<T> x, Ten
150150
*/
151151
for (int r =0; r < output.rank(); r++)
152152
{
153-
while (x.get_axis_size(r) ==1 && y.get_axis_size(r) ==1) {
153+
while (x.rank() > r && y.rank() > r && x.get_axis_size(r) ==1 && y.get_axis_size(r) ==1) {
154154
CV_Assert(output.get_axis_size(r) ==1);
155155

156156
x.squeeze(r);
@@ -183,6 +183,9 @@ void eltwise_op(const Stream& stream, TensorSpan<T> output, TensorView<T> x, Ten
183183
auto new_size = inShape1[i] * inShape1[j];
184184
inShape1[i] = new_size;
185185
inShape2[i] = new_size;
186+
// outShape should be changed after merged
187+
auto output_new_size = outShape[i] * outShape[j];
188+
outShape[i] = output_new_size;
186189

187190
/* delete axis `j`*/
188191
inShape1.erase(std::begin(inShape1) + j);

‎modules/dnn/src/layers/nary_eltwise_layers.cpp‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ class NaryEltwiseLayerImpl CV_FINAL : public NaryEltwiseLayer
5151
WHERE,
5252
} op;
5353

54-
// If the eltwise implementation is modified, you need to force enable the 'Layer_Test_Eltwise_bcast'
55-
// test in the 'test_layers.cpp' file to make sure it all passes
5654
NaryEltwiseLayerImpl(const LayerParams& params)
5755
{
5856
setParamsFrom(params);

‎modules/dnn/test/test_layers.cpp‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,9 @@ struct Layer_Test_Eltwise_bcast : testing::TestWithParam<tuple<string, int, tupl
19491949
int backend = get<0>(backend_target);
19501950
int target = get<1>(backend_target);
19511951

1952+
if (backend == DNN_BACKEND_CUDA && dim >4)
1953+
applyTestTag(CV_TEST_TAG_LONG);
1954+
19521955
vector<vector<int>> dim_shape_list;
19531956
get_all_arr(dim_shape_list, dim);
19541957
replace(dim_shape_list,1,3);
@@ -2028,7 +2031,7 @@ struct Layer_Test_Eltwise_bcast : testing::TestWithParam<tuple<string, int, tupl
20282031
}
20292032
};
20302033

2031-
TEST_P(Layer_Test_Eltwise_bcast,DISABLED_brute_force)
2034+
TEST_P(Layer_Test_Eltwise_bcast,brute_force)
20322035
{
20332036
test_bcast();
20342037
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp