Skip to content

Commit

Permalink
Merge pull request #58 from delve-wang/main
Browse files Browse the repository at this point in the history
最近邻上采样算子中,在内层循环中没有必要判断目标位置的列数与行数是否小于目标图像的宽和高
  • Loading branch information
zjhellofss authored Apr 12, 2024
2 parents fb715cf + acf5078 commit 69798bc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
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

0 comments on commit 69798bc

Please sign in to comment.