Skip to content

Commit

Permalink
Move conv specific ops from tensor_utils to conv2d.
Browse files Browse the repository at this point in the history
Signed-off-by: Nilaykumar Patel <nkpatel@tenstorrent.com>
  • Loading branch information
nkpatel-tt committed Jan 2, 2025
1 parent d9304dd commit 6a02bae
Show file tree
Hide file tree
Showing 6 changed files with 508 additions and 558 deletions.
29 changes: 0 additions & 29 deletions ttnn/cpp/ttnn/operations/conv/conv2d/conv2d_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,35 +72,6 @@ uint32_t find_closest_largest_divisor_with_num_padding(uint32_t num1, uint32_t n
return divisor;
}

// Converts convolution weights to tilized 2d matrix layout.
// Returns a new tensor with layout=Tile
Tensor convert_conv_weight_tensor_to_tiled_layout(
const Tensor& conv_weight_tensor,
uint32_t in1_block_h,
uint32_t in1_block_w,
std::optional<DataType> output_dtype) {
return tt::tt_metal::convert_conv_weight_tensor_to_tiled_layout(
std::move(conv_weight_tensor), in1_block_h, in1_block_w, output_dtype);
}

// Converts convolution weights to tilized 2d matrix layout with special block height padding
// Returns a new tensor with layout=Tile
Tensor convert_conv_weight_tensor_to_special_padding_tiled_layout(
const Tensor& conv_weight_tensor,
uint32_t in1_block_h,
uint32_t in1_block_w,
std::optional<DataType> output_dtype) {
return tt::tt_metal::convert_conv_weight_tensor_to_special_padding_tiled_layout(
std::move(conv_weight_tensor), in1_block_h, in1_block_w, output_dtype);
}

// Converts convolution weights to grouped layout with padded zeros
Tensor convert_conv_weight_tensor_to_grouped_layout(
const Tensor& conv_weight_tensor, uint32_t num_groups, DataType output_dtype) {
return tt::tt_metal::convert_conv_weight_tensor_to_grouped_layout(
std::move(conv_weight_tensor), num_groups, output_dtype);
}

ParallelConfig determine_parallel_config_non_tile_mul_width(
const TensorMemoryLayout shard_layout,
uint32_t batch_size,
Expand Down
20 changes: 0 additions & 20 deletions ttnn/cpp/ttnn/operations/conv/conv2d/conv2d_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,26 +171,6 @@ shard_or_reshard_tensor_if_required(
bool auto_shard,
bool is_non_tile_mul_width = false);

// Converts convolution weights to tilized 2d matrix layout.
// Returns a new tensor with layout=Tile
Tensor convert_conv_weight_tensor_to_tiled_layout(
const Tensor& conv_weight_tensor,
uint32_t in1_block_h,
uint32_t in1_block_w,
std::optional<DataType> output_dtype = std::nullopt);

// Converts convolution weights to tilized 2d matrix layout with special block height padding
// Returns a new tensor with layout=Tile
Tensor convert_conv_weight_tensor_to_special_padding_tiled_layout(
const Tensor& conv_weight_tensor,
uint32_t in1_block_h,
uint32_t in1_block_w,
std::optional<DataType> output_dtype = std::nullopt);

// Converts convolution weights to grouped layout with padded zeros
Tensor convert_conv_weight_tensor_to_grouped_layout(
const Tensor& conv_weight_tensor, uint32_t num_groups, DataType output_dtype);

std::ostream& operator<<(std::ostream& os, const Conv2dConfig& config);

} // namespace operations::conv
Expand Down
Loading

0 comments on commit 6a02bae

Please sign in to comment.