Skip to content

Commit

Permalink
remove unnecessary parenthesis around lambda functions (pytorch#972)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#972

Mechanical codemod

Reviewed By: jasonjk-park

Differential Revision: D34744977

fbshipit-source-id: 625a0df43761894d13a01bc1779576fc3f29bf6f
  • Loading branch information
jspark1105 authored and facebook-github-bot committed Mar 9, 2022
1 parent 1baf483 commit 4dfc2a7
Show file tree
Hide file tree
Showing 20 changed files with 273 additions and 291 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ split_embedding_backward_codegen_{{ optimizer }}_cpu(
{% endif %}

AT_DISPATCH_FLOATING_TYPES_AND_HALF(
grad_output.scalar_type(), "split_embedding_backward_cpu", [&]() {
grad_output.scalar_type(), "split_embedding_backward_cpu", [&] {
using grad_t = scalar_t;
AT_DISPATCH_FLOATING_TYPES_AND_HALF(
host_weights.scalar_type(),
"split_embedding_backward_cpu_inner",
[&]() {
[&] {
split_embedding_backward_approx_cpu_kernel<scalar_t, grad_t>(
grad_output,
host_weights,
Expand Down
4 changes: 2 additions & 2 deletions fbgemm_gpu/codegen/embedding_backward_split_cpu_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ void split_embedding_backward_exact_cpu_dense_kernel(
grad_output = grad_output.contiguous();

AT_DISPATCH_FLOATING_TYPES_AND_HALF(
host_weights.scalar_type(), "split_embedding_backward_exact_cpu", [&]() {
host_weights.scalar_type(), "split_embedding_backward_exact_cpu", [&] {
// TODO: respect output_dtype
using grad_t = float;
split_embedding_backward_exact_cpu_kernel<scalar_t, grad_t>(
Expand Down Expand Up @@ -377,7 +377,7 @@ void split_embedding_backward_exact_cpu_dense_kernel(
// When input is dense enough, avoid sorting and just treat as dense.
auto grad = zeros_like(host_weights, grad_output.dtype());
AT_DISPATCH_FLOATING_TYPES_AND_HALF(
grad_output.scalar_type(), "split_embedding_backward_exact_cpu", [&]() {
grad_output.scalar_type(), "split_embedding_backward_exact_cpu", [&] {

split_embedding_backward_exact_cpu_dense_kernel<scalar_t>(
grad,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Tensor {{ "dense" if dense else "split" }}_embedding_codegen_grad_indice_weights
lxu_cache_weights.type(),
{% endif %}
"split_embedding_codegen_grad_indice_weights_kernel",
([&] {
[&] {
{% for kMaxVecsPerThread in range(1, max_embedding_dim // 128 + 1) %}
if (max_D <= {{ 128 * kMaxVecsPerThread }}) {
{{ "dense" if dense else "split" }}_embedding_codegen_grad_indice_weights_kernel<
Expand Down Expand Up @@ -279,7 +279,7 @@ Tensor {{ "dense" if dense else "split" }}_embedding_codegen_grad_indice_weights
return;
}
{% endfor %}
}));
});
C10_CUDA_KERNEL_LAUNCH_CHECK();
return grad_indice_weights;
Expand Down
4 changes: 2 additions & 2 deletions fbgemm_gpu/codegen/embedding_backward_split_template.cu
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ split_embedding{{ "_nobag" if nobag else "" }}_backward_codegen_{{ optimizer }}_
dev_weights.type(),
{% endif %}
"split_embedding_backward_{{ optimizer }}_exact_kernel",
([&] {
[&] {
{% if weighted %}
auto indice_weights_sorted = at::empty_like(indice_weights);
{
Expand Down Expand Up @@ -1133,7 +1133,7 @@ split_embedding{{ "_nobag" if nobag else "" }}_backward_codegen_{{ optimizer }}_
return;
}
{% endfor %}
}));
});
return {{ "grad_dev_weights" if dense else "" }};
}
Expand Down
2 changes: 1 addition & 1 deletion fbgemm_gpu/codegen/embedding_bounds_check.cu
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void bounds_check_indices_cuda(
}
constexpr size_t kNumThreads = 256;

AT_DISPATCH_INDEX_TYPES(indices.scalar_type(), "bounds_check_indices", [&]() {
AT_DISPATCH_INDEX_TYPES(indices.scalar_type(), "bounds_check_indices", [&] {
bounds_check_indices_kernel<index_t>
<<<div_round_up(B * T, kNumThreads / fbgemm_gpu::kWarpSize),
dim3(fbgemm_gpu::kWarpSize, kNumThreads / fbgemm_gpu::kWarpSize),
Expand Down
2 changes: 1 addition & 1 deletion fbgemm_gpu/codegen/embedding_bounds_check_host_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void bounds_check_indices_cpu(
const auto rows_per_table_acc = rows_per_table.accessor<int64_t, 1>();
auto warning_acc = warning.data_ptr<int64_t>();

AT_DISPATCH_INDEX_TYPES(indices.scalar_type(), "bounds_check_indices", [&]() {
AT_DISPATCH_INDEX_TYPES(indices.scalar_type(), "bounds_check_indices", [&] {
auto offsets_acc = offsets.accessor<index_t, 1>();
auto indices_acc = indices.accessor<index_t, 1>();
auto num_indices = indices.numel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ Tensor int_nbit_split_embedding_codegen_forward_{{ wdesc }}_cpu(

const auto* weights_tys_acc = weights_tys.data_ptr<uint8_t>();

DISPATCH_OUTPUT_TYPES(output.type(), "intn_split_embedding_codegen_forward_kernel", ([&] {
DISPATCH_OUTPUT_TYPES(output.type(), "intn_split_embedding_codegen_forward_kernel", [&] {
auto* output_acc = output.data_ptr<output_t>();
{% if weighted %}
const float* indice_weights_acc = indice_weights.data_ptr<float>();
{% endif %}

AT_DISPATCH_INDEX_TYPES(indices.scalar_type(), "int_nbit_split_embedding_codegen_forward_", [&] () {
AT_DISPATCH_INDEX_TYPES(indices.scalar_type(), "int_nbit_split_embedding_codegen_forward_", [&] {
const auto* indices_acc = indices.data_ptr<index_t>();
const auto* offsets_acc = offsets.data_ptr<index_t>();
const auto* D_offsets_acc = D_offsets.data_ptr<int32_t>();
Expand Down Expand Up @@ -320,7 +320,7 @@ Tensor int_nbit_split_embedding_codegen_forward_{{ wdesc }}_cpu(
}
return;
});
}));
});
return output;
}

Expand Down
8 changes: 4 additions & 4 deletions fbgemm_gpu/codegen/embedding_forward_split_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ Tensor split_embedding_codegen_forward_cpu(
TORCH_CHECK(
!indice_weights.defined() || indice_weights.scalar_type() != at::kHalf);
AT_DISPATCH_FLOATING_TYPES(
output.scalar_type(), "split_embedding_cpu_forward", [&]() {
output.scalar_type(), "split_embedding_cpu_forward", [&] {
using output_t = scalar_t;
AT_DISPATCH_FLOATING_TYPES_AND2(
at::ScalarType::Half,
at::ScalarType::Byte,
weights.scalar_type(),
"split_embedding_cpu_forward",
[&]() {
[&] {
using ind_weights_t = std::conditional<
std::is_same<scalar_t, double>::value,
double,
Expand Down Expand Up @@ -294,12 +294,12 @@ Tensor split_embedding_codegen_grad_indice_weights_cpu(
AT_DISPATCH_FLOATING_TYPES_AND_HALF(
grad_output.scalar_type(),
"split_embedding_grad_indice_weights_cpu_outer",
[&]() {
[&] {
using grad_t = scalar_t;
AT_DISPATCH_FLOATING_TYPES_AND_HALF(
weights.scalar_type(),
"split_embedding_grad_indice_weights_cpu",
[&]() {
[&] {
using weights_t = scalar_t;
split_embedding_grad_indice_weights_cpu_kernel<weights_t, grad_t>(
grad_output,
Expand Down
4 changes: 2 additions & 2 deletions fbgemm_gpu/codegen/embedding_forward_split_template.cu
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ Tensor {{ "dense" if dense else "split" }}_embedding{{ "_nobag" if nobag else ""
lxu_cache_weights.type(),
output.type(),
{% endif %}
"batched_embedding{{ "_nobag" if nobag else "" }}_forward_kernel_2", ([&] {
"batched_embedding{{ "_nobag" if nobag else "" }}_forward_kernel_2", [&] {
{% if not nobag %}
{% for kMaxVecsPerThread in range(1, max_embedding_dim // 128 + 1) %}
if (max_D <= {{ 128 * kMaxVecsPerThread }}) {
Expand Down Expand Up @@ -467,7 +467,7 @@ Tensor {{ "dense" if dense else "split" }}_embedding{{ "_nobag" if nobag else ""
return;
{% endif %}
}));
});
C10_CUDA_KERNEL_LAUNCH_CHECK();
return output;
Expand Down
18 changes: 9 additions & 9 deletions fbgemm_gpu/src/histogram_binning_calibration_ops.cu
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ std::tuple<Tensor, Tensor> histogram_binning_calibration_cuda(
const auto bin_num_examples_packed = bin_num_examples.contiguous();
const auto bin_num_positives_packed = bin_num_positives.contiguous();
AT_DISPATCH_FLOATING_TYPES_AND_HALF(
logit.type(), "histogram_binning_calibration_cuda", [&]() {
logit.type(), "histogram_binning_calibration_cuda", [&] {
histogram_binning_calibration_kernel<scalar_t>
<<<fbgemm_gpu::div_round_up(logit.numel(), num_threads),
num_threads,
Expand Down Expand Up @@ -201,10 +201,10 @@ std::tuple<Tensor, Tensor> histogram_binning_calibration_by_feature_cuda(
AT_DISPATCH_INDEX_TYPES(
segment_offsets.scalar_type(),
"to_dense_segment_value_cuda_wrapper",
[&]() {
[&] {
using offset_t = index_t;
AT_DISPATCH_INDEX_TYPES(
segment_value.scalar_type(), "to_dense_segment_value_cuda", [&]() {
segment_value.scalar_type(), "to_dense_segment_value_cuda", [&] {
using value_t = index_t;
to_dense_segment_value_kernel<offset_t, value_t>
<<<fbgemm_gpu::div_round_up(
Expand Down Expand Up @@ -232,12 +232,12 @@ std::tuple<Tensor, Tensor> histogram_binning_calibration_by_feature_cuda(
AT_DISPATCH_FLOATING_TYPES_AND_HALF(
logit.type(),
"histogram_binning_calibration_by_feature_cuda_wrapper",
[&]() {
[&] {
using logit_t = scalar_t;
AT_DISPATCH_INDEX_TYPES(
dense_segment_value_packed.scalar_type(),
"histogram_binning_calibration_by_feature_cuda",
[&]() {
[&] {
using segment_value_t = index_t;
histogram_binning_calibration_by_feature_kernel<
logit_t,
Expand Down Expand Up @@ -362,10 +362,10 @@ generic_histogram_binning_calibration_by_feature_cuda(
AT_DISPATCH_INDEX_TYPES(
segment_offsets.scalar_type(),
"to_dense_segment_value_cuda_wrapper",
[&]() {
[&] {
using offset_t = index_t;
AT_DISPATCH_INDEX_TYPES(
segment_value.scalar_type(), "to_dense_segment_value_cuda", [&]() {
segment_value.scalar_type(), "to_dense_segment_value_cuda", [&] {
using value_t = index_t;
to_dense_segment_value_kernel<offset_t, value_t>
<<<fbgemm_gpu::div_round_up(
Expand All @@ -392,12 +392,12 @@ generic_histogram_binning_calibration_by_feature_cuda(
AT_DISPATCH_FLOATING_TYPES_AND_HALF(
logit.type(),
"generic_histogram_binning_calibration_by_feature_cuda_wrapper",
[&]() {
[&] {
using logit_t = scalar_t;
AT_DISPATCH_INDEX_TYPES(
dense_segment_value_packed.scalar_type(),
"generic_histogram_binning_calibration_by_feature_cuda",
[&]() {
[&] {
using segment_value_t = index_t;
generic_histogram_binning_calibration_by_feature_kernel<
logit_t,
Expand Down
4 changes: 2 additions & 2 deletions fbgemm_gpu/src/input_combine_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Tensor _cat_int_tensors(

for (size_t i = 0; i < tensor_list.size(); i++) {
AT_DISPATCH_INDEX_TYPES(
tensor_list[i].scalar_type(), "tbe_cat_inputs_", [&]() {
tensor_list[i].scalar_type(), "tbe_cat_inputs_", [&] {
auto indices_acc = tensor_list[i].accessor<index_t, 1>();
for (auto j = 0; j < tensor_list[i].numel(); j++) {
combined_tensors_acc[idx++] = static_cast<int32_t>(indices_acc[j]);
Expand Down Expand Up @@ -135,7 +135,7 @@ std::tuple<Tensor, Tensor, Tensor> tbe_input_combine_cpu(

for (size_t i = 0; i < offsets_list.size(); i++) {
AT_DISPATCH_INDEX_TYPES(
offsets_list[i].scalar_type(), "tbe_input_offsets_", [&]() {
offsets_list[i].scalar_type(), "tbe_input_offsets_", [&] {
auto offsets_acc = offsets_list[i].accessor<index_t, 1>();
for (int64_t j = 1,
size = offsets_list[i].numel() -
Expand Down
Loading

0 comments on commit 4dfc2a7

Please sign in to comment.