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

#0: remove device arg from maxpool2d #13615

Merged
merged 1 commit into from
Oct 10, 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
2 changes: 0 additions & 2 deletions models/demos/convnet_mnist/tt/convnet_mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def convnet_mnist(
stride=[1, 1],
padding=[0, 0],
dilation=[1, 1],
device=device,
)

[x, out_height, out_width, weights_device, bias_device] = ttnn.conv2d(
Expand Down Expand Up @@ -118,7 +117,6 @@ def convnet_mnist(
stride=[1, 1],
padding=[0, 0],
dilation=[1, 1],
device=device,
)
x = ttnn.from_device(x)
x = ttnn.reshape(x, (x.shape[0], -1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,6 @@ def first_run(self, input_tensor, device, batch_size, ops_parallel_config) -> tt
stride=[2, 2],
padding=[1, 1],
dilation=[1, 1],
device=device,
)

x_height = 128
Expand Down Expand Up @@ -867,7 +866,6 @@ def optimized_run(self, input_tensor, device, batch_size, ops_parallel_config, c
stride=[2, 2],
padding=[1, 1],
dilation=[1, 1],
device=device,
)

x_height = 128
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,6 @@ def run(self, input_tensor, device, ops_parallel_config, conv_op_cache={}) -> tt
stride=[2, 2],
padding=[1, 1],
dilation=[1, 1],
device=device,
)

x_height = 56
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,6 @@ def first_run(self, input_tensor, device, batch_size, ops_parallel_config) -> tt
stride=[2, 2],
padding=[1, 1],
dilation=[1, 1],
device=device,
)

x_height = 224
Expand Down Expand Up @@ -861,7 +860,6 @@ def optimized_run(self, input_tensor, device, batch_size, ops_parallel_config, c
stride=[2, 2],
padding=[1, 1],
dilation=[1, 1],
device=device,
)

x_height = 224
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,6 @@ def first_run(self, input_tensor, device, batch_size, ops_parallel_config) -> tt
stride=[2, 2],
padding=[1, 1],
dilation=[1, 1],
device=device,
)

x_height = 224
Expand Down Expand Up @@ -891,7 +890,6 @@ def optimized_run(self, input_tensor, device, batch_size, ops_parallel_config, c
stride=[2, 2],
padding=[1, 1],
dilation=[1, 1],
device=device,
)

x_height = 224
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,6 @@ def first_run(self, input_tensor, device, batch_size, ops_parallel_config) -> tt
stride=[2, 2],
padding=[1, 1],
dilation=[1, 1],
device=device,
)

x_height = 256
Expand Down Expand Up @@ -965,7 +964,6 @@ def optimized_run(self, input_tensor, device, batch_size, ops_parallel_config, c
stride=[2, 2],
padding=[1, 1],
dilation=[1, 1],
device=device,
)

x_height = 256
Expand Down
2 changes: 0 additions & 2 deletions models/demos/vgg/tt/ttnn_vgg.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def ttnn_vgg16(
stride=[2, 2],
padding=[0, 0],
dilation=[1, 1],
device=device,
)
ttnn.deallocate(ttact_d)
tt_x = ttnn.from_device(tt_x)
Expand Down Expand Up @@ -206,7 +205,6 @@ def ttnn_vgg11(
stride=[2, 2],
padding=[0, 0],
dilation=[1, 1],
device=device,
)
tt_x = ttnn.from_device(tt_x)
ttnn.deallocate(ttact_d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ def __call__(self, x):
stride=[self.pool.stride, self.pool.stride],
padding=[self.pool.padding, self.pool.padding],
dilation=[self.pool.dilation, self.pool.dilation],
device=self.device,
)
return x

Expand Down
3 changes: 0 additions & 3 deletions models/experimental/yolov4/ttnn/neck.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ def __call__(self, device, input_tensor):
stride=[1, 1],
padding=[2, 2],
dilation=[1, 1],
device=device,
)
pool_2 = ttnn.max_pool2d(
input_tensor=output_tensor,
Expand All @@ -203,7 +202,6 @@ def __call__(self, device, input_tensor):
stride=[1, 1],
padding=[4, 4],
dilation=[1, 1],
device=device,
)
pool_3 = ttnn.max_pool2d(
input_tensor=output_tensor,
Expand All @@ -215,7 +213,6 @@ def __call__(self, device, input_tensor):
stride=[1, 1],
padding=[6, 6],
dilation=[1, 1],
device=device,
)

pool_1 = ttnn.sharded_to_interleaved(pool_1, ttnn.L1_MEMORY_CONFIG)
Expand Down
1 change: 0 additions & 1 deletion tests/ttnn/sweep_tests/sweeps/sweeps/max_pool2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def run(
stride=[stride_h, stride_w],
padding=[pad_h, pad_w],
dilation=[dilation_h, dilation_w],
device=device,
)
out_padded = out_d.cpu()
out_pytorch_padded = ttnn.to_torch(out_padded)
Expand Down
2 changes: 0 additions & 2 deletions tests/ttnn/unit_tests/operations/test_maxpool2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def run_max_pool(
stride=[stride_h, stride_w],
padding=[pad_h, pad_w],
dilation=[dilation_h, dilation_w],
device=device,
)

# interleaved_mem_config = ttnn.L1_MEMORY_CONFIG
Expand Down Expand Up @@ -477,7 +476,6 @@ def test_pool_core_nondivis(
stride=[stride_h, stride_w],
padding=[pad_h, pad_w],
dilation=[dilation_h, dilation_w],
device=device,
)

# interleaved_mem_config = ttnn.L1_MEMORY_CONFIG
Expand Down
9 changes: 2 additions & 7 deletions ttnn/cpp/ttnn/operations/pool/maxpool/max_pool2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
namespace ttnn {
namespace operations::pool {

template<typename T>
Tensor MaxPool2DOp::invoke(uint8_t queue_id, const Tensor& input_tensor, uint32_t batch_size, uint32_t input_h, uint32_t input_w, uint32_t channels, std::array<uint32_t, 2> kernel_size, std::array<uint32_t, 2> stride, std::array<uint32_t, 2> padding, std::array<uint32_t, 2> dilation, T* device) {
Tensor MaxPool2DOp::invoke(uint8_t queue_id, const Tensor& input_tensor, uint32_t batch_size, uint32_t input_h, uint32_t input_w, uint32_t channels, std::array<uint32_t, 2> kernel_size, std::array<uint32_t, 2> stride, std::array<uint32_t, 2> padding, std::array<uint32_t, 2> dilation) {

sliding_window::SlidingWindowConfig sliding_window_config{
.batch_size = batch_size,
Expand Down Expand Up @@ -43,7 +42,7 @@ Tensor MaxPool2DOp::invoke(uint8_t queue_id, const Tensor& input_tensor, uint32_
output_shape[1],
output_shape[2],
0, // out_channels -- not used
device,
input_tensor.device(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little bit suspicious about this change.. did the T3000/TG tests pass?

ShardOrientation::ROW_MAJOR,
false);
num_cores_nhw = conv::conv2d::get_num_cores_nhw_from_parallel_config(parallel_config);
Expand Down Expand Up @@ -104,9 +103,5 @@ Tensor MaxPool2DOp::invoke(uint8_t queue_id, const Tensor& input_tensor, uint32_
memory_config);
}

// device template specializations
template Tensor MaxPool2DOp::invoke<Device>(uint8_t queue_id, const Tensor& input_tensor, uint32_t batch_size, uint32_t input_h, uint32_t input_w, uint32_t channels, std::array<uint32_t, 2> kernel_size, std::array<uint32_t, 2> stride, std::array<uint32_t, 2> padding, std::array<uint32_t, 2> dilation, Device* device);
template Tensor MaxPool2DOp::invoke<MeshDevice>(uint8_t queue_id, const Tensor& input_tensor, uint32_t batch_size, uint32_t input_h, uint32_t input_w, uint32_t channels, std::array<uint32_t, 2> kernel_size, std::array<uint32_t, 2> stride, std::array<uint32_t, 2> padding, std::array<uint32_t, 2> dilation, MeshDevice* device);

} // namespace operations::pool
} // namespace ttnn
3 changes: 1 addition & 2 deletions ttnn/cpp/ttnn/operations/pool/maxpool/max_pool2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ namespace ttnn {
namespace operations::pool {

struct MaxPool2DOp {
template<typename T>
static Tensor invoke(uint8_t queue_id, const Tensor& input_tensor, uint32_t batch_size, uint32_t input_h, uint32_t input_w, uint32_t channels, std::array<uint32_t, 2> kernel_size, std::array<uint32_t, 2> stride, std::array<uint32_t, 2> padding, std::array<uint32_t, 2> dilation, T* device);
static Tensor invoke(uint8_t queue_id, const Tensor& input_tensor, uint32_t batch_size, uint32_t input_h, uint32_t input_w, uint32_t channels, std::array<uint32_t, 2> kernel_size, std::array<uint32_t, 2> stride, std::array<uint32_t, 2> padding, std::array<uint32_t, 2> dilation);

};

Expand Down
40 changes: 1 addition & 39 deletions ttnn/cpp/ttnn/operations/pool/maxpool/max_pool2d_pybind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ void bind_max_pool2d_operation(py::module& module) {
std::array<uint32_t, 2> stride,
std::array<uint32_t, 2> padding,
std::array<uint32_t, 2> dilation,
ttnn::Device* device,
const uint8_t& queue_id)
-> ttnn::Tensor { return self(queue_id,
input_tensor,
Expand All @@ -59,8 +58,7 @@ void bind_max_pool2d_operation(py::module& module) {
kernel_size,
stride,
padding,
dilation,
device); },
dilation); },
py::arg("input_tensor"),
py::arg("batch_size"),
py::arg("input_h"),
Expand All @@ -71,42 +69,6 @@ void bind_max_pool2d_operation(py::module& module) {
py::arg("padding"),
py::arg("dilation"),
py::kw_only(),
py::arg("device"),
py::arg("queue_id") = 0},
ttnn::pybind_overload_t{
[](const decltype(ttnn::max_pool2d)& self, const ttnn::Tensor& input_tensor,
uint32_t batch_size,
uint32_t input_h,
uint32_t input_w,
uint32_t channels,
std::array<uint32_t, 2> kernel_size,
std::array<uint32_t, 2> stride,
std::array<uint32_t, 2> padding,
std::array<uint32_t, 2> dilation,
MeshDevice* device,
const uint8_t& queue_id)
-> ttnn::Tensor { return self(queue_id,
input_tensor,
batch_size,
input_h,
input_w,
channels,
kernel_size,
stride,
padding,
dilation,
device); },
py::arg("input_tensor"),
py::arg("batch_size"),
py::arg("input_h"),
py::arg("input_w"),
py::arg("channels"),
py::arg("kernel_size"),
py::arg("stride"),
py::arg("padding"),
py::arg("dilation"),
py::kw_only(),
py::arg("device"),
py::arg("queue_id") = 0});
}

Expand Down