Skip to content
Open
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
10 changes: 5 additions & 5 deletions models/py_utils/_cpools/src/bottom_pool.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <torch/torch.h>
#include <torch/extension.h>

#include <vector>

Expand Down Expand Up @@ -41,8 +41,8 @@ std::vector<at::Tensor> pool_backward(
int32_t height = input.size(2);
int32_t width = input.size(3);

auto max_val = at::zeros(torch::CUDA(at::kFloat), {batch, channel, width});
auto max_ind = at::zeros(torch::CUDA(at::kLong), {batch, channel, width});
auto max_val = at::zeros({batch, channel, width}, torch::TensorOptions().dtype(torch::kFloat).device(torch::kCUDA));
auto max_ind = at::zeros({batch, channel, width}, torch::TensorOptions().dtype(torch::kLong).device(torch::kCUDA));

auto input_temp = input.select(2, 0);
max_val.copy_(input_temp);
Expand All @@ -54,8 +54,8 @@ std::vector<at::Tensor> pool_backward(
output_temp.copy_(grad_output_temp);

auto un_max_ind = max_ind.unsqueeze(2);
auto gt_mask = at::zeros(torch::CUDA(at::kByte), {batch, channel, width});
auto max_temp = at::zeros(torch::CUDA(at::kFloat), {batch, channel, width});
auto gt_mask = at::zeros({batch, channel, width}, torch::TensorOptions().dtype(torch::kByte).device(torch::kCUDA));
auto max_temp = at::zeros({batch, channel, width}, torch::TensorOptions().dtype(torch::kFloat).device(torch::kCUDA));
for (int32_t ind = 0; ind < height - 1; ++ind) {
input_temp = input.select(2, ind + 1);
at::gt_out(gt_mask, input_temp, max_val);
Expand Down
10 changes: 5 additions & 5 deletions models/py_utils/_cpools/src/left_pool.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <torch/torch.h>
#include <torch/extension.h>

#include <vector>

Expand Down Expand Up @@ -41,8 +41,8 @@ std::vector<at::Tensor> pool_backward(
int32_t height = input.size(2);
int32_t width = input.size(3);

auto max_val = at::zeros(torch::CUDA(at::kFloat), {batch, channel, height});
auto max_ind = at::zeros(torch::CUDA(at::kLong), {batch, channel, height});
auto max_val = at::zeros({batch, channel, height}, torch::TensorOptions().dtype(torch::kFloat).device(torch::kCUDA));
auto max_ind = at::zeros({batch, channel, height}, torch::TensorOptions().dtype(torch::kLong).device(torch::kCUDA));

auto input_temp = input.select(3, width - 1);
max_val.copy_(input_temp);
Expand All @@ -54,8 +54,8 @@ std::vector<at::Tensor> pool_backward(
output_temp.copy_(grad_output_temp);

auto un_max_ind = max_ind.unsqueeze(3);
auto gt_mask = at::zeros(torch::CUDA(at::kByte), {batch, channel, height});
auto max_temp = at::zeros(torch::CUDA(at::kFloat), {batch, channel, height});
auto gt_mask = at::zeros({batch, channel, height}, torch::TensorOptions().dtype(torch::kByte).device(torch::kCUDA));
auto max_temp = at::zeros({batch, channel, height}, torch::TensorOptions().dtype(torch::kFloat).device(torch::kCUDA));
for (int32_t ind = 1; ind < width; ++ind) {
input_temp = input.select(3, width - ind - 1);
at::gt_out(gt_mask, input_temp, max_val);
Expand Down
10 changes: 5 additions & 5 deletions models/py_utils/_cpools/src/right_pool.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <torch/torch.h>
#include <torch/extension.h>

#include <vector>

Expand Down Expand Up @@ -41,8 +41,8 @@ std::vector<at::Tensor> pool_backward(
int32_t height = input.size(2);
int32_t width = input.size(3);

auto max_val = at::zeros(torch::CUDA(at::kFloat), {batch, channel, height});
auto max_ind = at::zeros(torch::CUDA(at::kLong), {batch, channel, height});
auto max_val = at::zeros({batch, channel, height}, torch::TensorOptions().dtype(torch::kFloat).device(torch::kCUDA));
auto max_ind = at::zeros({batch, channel, height}, torch::TensorOptions().dtype(torch::kLong).device(torch::kCUDA));

auto input_temp = input.select(3, 0);
max_val.copy_(input_temp);
Expand All @@ -54,8 +54,8 @@ std::vector<at::Tensor> pool_backward(
output_temp.copy_(grad_output_temp);

auto un_max_ind = max_ind.unsqueeze(3);
auto gt_mask = at::zeros(torch::CUDA(at::kByte), {batch, channel, height});
auto max_temp = at::zeros(torch::CUDA(at::kFloat), {batch, channel, height});
auto gt_mask = at::zeros({batch, channel, height}, torch::TensorOptions().dtype(torch::kByte).device(torch::kCUDA));
auto max_temp = at::zeros({batch, channel, height}, torch::TensorOptions().dtype(torch::kFloat).device(torch::kCUDA));
for (int32_t ind = 0; ind < width - 1; ++ind) {
input_temp = input.select(3, ind + 1);
at::gt_out(gt_mask, input_temp, max_val);
Expand Down
10 changes: 5 additions & 5 deletions models/py_utils/_cpools/src/top_pool.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <torch/torch.h>
#include <torch/extension.h>

#include <vector>

Expand Down Expand Up @@ -41,8 +41,8 @@ std::vector<at::Tensor> top_pool_backward(
int32_t height = input.size(2);
int32_t width = input.size(3);

auto max_val = at::zeros(torch::CUDA(at::kFloat), {batch, channel, width});
auto max_ind = at::zeros(torch::CUDA(at::kLong), {batch, channel, width});
auto max_val = at::zeros({batch, channel, width}, torch::TensorOptions().dtype(torch::kFloat).device(torch::kCUDA));
auto max_ind = at::zeros({batch, channel, width}, torch::TensorOptions().dtype(torch::kLong).device(torch::kCUDA));

auto input_temp = input.select(2, height - 1);
max_val.copy_(input_temp);
Expand All @@ -54,8 +54,8 @@ std::vector<at::Tensor> top_pool_backward(
output_temp.copy_(grad_output_temp);

auto un_max_ind = max_ind.unsqueeze(2);
auto gt_mask = at::zeros(torch::CUDA(at::kByte), {batch, channel, width});
auto max_temp = at::zeros(torch::CUDA(at::kFloat), {batch, channel, width});
auto gt_mask = at::zeros({batch, channel, width}, torch::TensorOptions().dtype(torch::kByte).device(torch::kCUDA));
auto max_temp = at::zeros({batch, channel, width}, torch::TensorOptions().dtype(torch::kFloat).device(torch::kCUDA));
for (int32_t ind = 1; ind < height; ++ind) {
input_temp = input.select(2, height - ind - 1);
at::gt_out(gt_mask, input_temp, max_val);
Expand Down