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

[OpenCL]fix tf_shufflenet model segmentation bug #5777

Merged
merged 2 commits into from
Mar 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions lite/kernels/opencl/layout_image_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,18 @@ class LayoutComputeBufferChwToImageDefault

// out info
std::vector<size_t> new_dims = {1, 1, 1, 1};
for (int tidx = 0; tidx < x_dims.size(); ++tidx) {
new_dims[4 - x_dims.size() + tidx] = x_dims[tidx];
if (x_dims.size() == 5) {
new_dims[4 - x_dims.size() + 1] = x_dims[0] * x_dims[1];
for (int tidx = 2; tidx < x_dims.size(); ++tidx) {
new_dims[4 - x_dims.size() + tidx] = x_dims[tidx];
}
} else if (x_dims.size() < 5) {
for (int tidx = 0; tidx < x_dims.size(); ++tidx) {
new_dims[4 - x_dims.size() + tidx] = x_dims[tidx];
}
} else {
LOG(FATAL) << "unsupported layout tensor dims size, the dims size is:"
<< x_dims.size();
}
const int out_C = new_dims[1];
const int out_H = new_dims[2];
Expand Down Expand Up @@ -207,8 +217,18 @@ class LayoutComputeImageDefaultToBufferChw
auto x_image_shape = InitImageDimInfoWith(x_dims);

std::vector<size_t> new_dims = {1, 1, 1, 1};
for (int j = 0; j < x_dims.size(); ++j) {
new_dims[4 - x_dims.size() + j] = x_dims[j];
if (x_dims.size() == 5) {
new_dims[4 - x_dims.size() + 1] = x_dims[0] * x_dims[1];
for (int j = 2; j < x_dims.size(); ++j) {
new_dims[4 - x_dims.size() + j] = x_dims[j];
}
} else if (x_dims.size() < 5) {
for (int j = 0; j < x_dims.size(); ++j) {
new_dims[4 - x_dims.size() + j] = x_dims[j];
}
} else {
LOG(FATAL) << "unsupported layout tensor dims size, the dims size is: "
<< x_dims.size();
}

#ifdef LITE_WITH_LOG
Expand Down Expand Up @@ -322,8 +342,18 @@ class LayoutComputeBufferChwToImage2DNw

// out info
std::vector<size_t> new_dims = {1, 1, 1, 1};
for (int tidx = 0; tidx < x_dims.size(); ++tidx) {
new_dims[4 - x_dims.size() + tidx] = x_dims[tidx];
if (x_dims.size() == 5) {
new_dims[4 - x_dims.size() + 1] = x_dims[0] * x_dims[1];
for (int tidx = 2; tidx < x_dims.size(); ++tidx) {
new_dims[4 - x_dims.size() + tidx] = x_dims[tidx];
}
} else if (x_dims.size() < 5) {
for (int tidx = 0; tidx < x_dims.size(); ++tidx) {
new_dims[4 - x_dims.size() + tidx] = x_dims[tidx];
}
} else {
LOG(FATAL) << "unsupported layout tensor dims size, the dims size is:"
<< x_dims.size();
}

const int out_N = new_dims[0];
Expand Down