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

最近邻上采样算子中,在内层循环中没有必要判断目标位置的列数与行数是否小于目标图像的宽和高 #58

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
- [TypeFloat](https://github.com/TypeFloat)
- [Jasmine-up](https://github.com/Jasmine-up)
- [PerrySkywalker](https://github.com/PerrySkywalker)
- [delve-wang](https://github.com/delve-wang)

### 如何参与项目贡献?
1. 提交代码增加新功能或修改bug;
Expand Down
7 changes: 1 addition & 6 deletions source/layer/details/upsample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,13 @@ StatusCode UpSampleLayer::Forward(const std::vector<std::shared_ptr<Tensor<float
const uint32_t dest_w = w * scale_w;
const float* input_col_ptr = input_channel.colptr(w);
for (uint32_t sw = 0; sw < scale_w; ++sw) {
if (dest_w + sw >= output_w) {
continue;
}
float* output_col_ptr = output_channel.colptr(dest_w + sw);
for (uint32_t h = 0; h < input_h; ++h) {
const uint32_t dest_h = h * scale_h;
float* output_ptr = output_col_ptr + dest_h;
const float input_value = *(input_col_ptr + h);
for (uint32_t sh = 0; sh < scale_h; ++sh) {
if (dest_h + sh < output_h) {
*(output_ptr + sh) = input_value;
}
*(output_ptr + sh) = input_value;
}
}
}
Expand Down
Loading