Skip to content

Commit

Permalink
c10::nullopt -> std::nullopt
Browse files Browse the repository at this point in the history
Summary:
X-link: pytorch/torchrec#2515

X-link: pytorch/executorch#6461

X-link: pytorch/audio#3848

X-link: pytorch/ao#1151

X-link: facebookincubator/AITemplate#1032

Reviewed By: houseroad

Differential Revision: D64835967

fbshipit-source-id: 9f9f65335aaf5497680561027ef9314e4b36f8d9
  • Loading branch information
r-barnes authored and facebook-github-bot committed Oct 23, 2024
1 parent 2834998 commit 3375de1
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ Tensor split_embedding_codegen_lookup_dense_function(
const std::optional<Tensor>& indice_weights,
const std::optional<Tensor>& feature_requires_grad,
int64_t /* output_dtype = static_cast<int64_t>(SparseType::FP32) */,
const std::optional<Tensor>& /* B_offsets = c10::nullopt */,
const std::optional<Tensor>& /* B_offsets = std::nullopt */,
const std::optional<
Tensor>& /* vbe_output_offsets_feature_rank = c10::nullopt */,
Tensor>& /* vbe_output_offsets_feature_rank = std::nullopt */,
const std::optional<
Tensor>& /* vbe_B_offsets_rank_per_feature = c10::nullopt */,
Tensor>& /* vbe_B_offsets_rank_per_feature = std::nullopt */,
c10::SymInt /* max_B = -1 */,
c10::SymInt /* max_B_feature_rank = -1 */,
c10::SymInt /* vbe_output_size = -1 */) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1006,26 +1006,26 @@ Tensor {{ bwd_mdesc }}_embedding_codegen_lookup_{{ optimizer }}_function(
{{ args.split_function_args | join(", ") }},
{%- endif %}
const int64_t output_dtype = static_cast<int64_t>(SparseType::FP32),
const std::optional<Tensor>& B_offsets = c10::nullopt,
const std::optional<Tensor>& vbe_output_offsets_feature_rank = c10::nullopt,
const std::optional<Tensor>& vbe_B_offsets_rank_per_feature = c10::nullopt,
const std::optional<Tensor>& B_offsets = std::nullopt,
const std::optional<Tensor>& vbe_output_offsets_feature_rank = std::nullopt,
const std::optional<Tensor>& vbe_B_offsets_rank_per_feature = std::nullopt,
const c10::SymInt max_B = -1,
const c10::SymInt max_B_feature_rank = -1,
{%- if not dense %}
const c10::SymInt vbe_output_size = -1,
const bool is_experimental_tbe = false, // formerly named is_experimental
const bool use_uniq_cache_locations_bwd = false,
const bool use_homogeneous_placements = false,
const std::optional<Tensor>& uvm_cache_stats = c10::nullopt,
const std::optional<Tensor>& uvm_cache_stats = std::nullopt,
{%- if "prev_iter_dev" not in args.split_function_arg_names %}
const std::optional<Tensor>& prev_iter_dev = c10::nullopt,
const std::optional<Tensor>& prev_iter_dev = std::nullopt,
{%- endif %}
{%- if "iter" not in args.split_function_arg_names %}
const int64_t iter = 0,
{%- endif %}
const bool apply_global_weight_decay = false,
{%- if ssd %}
const std::optional<at::TensorList>& ssd_tensors = c10::nullopt,
const std::optional<at::TensorList>& ssd_tensors = std::nullopt,
{%- endif %}
const double gwd_lower_bound = 0
{%- else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -987,25 +987,25 @@ Tensor {{ bwd_mdesc }}_embedding_codegen_lookup_{{ optimizer }}_function_pt2(
{%- endif %}
{{ args_pt2.unified_pt2.split_function_args | join(", ") }},
const int64_t output_dtype = static_cast<int64_t>(SparseType::FP32),
const std::optional<Tensor>& B_offsets = c10::nullopt,
const std::optional<Tensor>& vbe_output_offsets_feature_rank = c10::nullopt,
const std::optional<Tensor>& vbe_B_offsets_rank_per_feature = c10::nullopt,
const std::optional<Tensor>& B_offsets = std::nullopt,
const std::optional<Tensor>& vbe_output_offsets_feature_rank = std::nullopt,
const std::optional<Tensor>& vbe_B_offsets_rank_per_feature = std::nullopt,
const c10::SymInt max_B = -1,
const c10::SymInt max_B_feature_rank = -1,
const c10::SymInt vbe_output_size = -1,
const bool is_experimental_tbe = false, // formerly named is_experimental
const bool use_uniq_cache_locations_bwd = false,
const bool use_homogeneous_placements = false,
const std::optional<Tensor>& uvm_cache_stats = c10::nullopt,
const std::optional<Tensor>& uvm_cache_stats = std::nullopt,
{%- if "prev_iter_dev" not in args_pt2.split_function_arg_names %}
const std::optional<Tensor>& prev_iter_dev = c10::nullopt,
const std::optional<Tensor>& prev_iter_dev = std::nullopt,
{%- endif %}
{%- if "iter" not in args_pt2.split_function_arg_names %}
const int64_t iter = 0,
{%- endif %}
const bool apply_global_weight_decay = false,
{%- if ssd %}
const std::optional<at::TensorList>& ssd_tensors = c10::nullopt,
const std::optional<at::TensorList>& ssd_tensors = std::nullopt,
{%- endif %}
const double gwd_lower_bound = 0
) {
Expand Down
2 changes: 1 addition & 1 deletion fbgemm_gpu/experimental/gen_ai/src/gemm/ck_extensions.hip
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ at::Tensor dispatch_bf16_gemm(at::Tensor A, at::Tensor B, std::optional<at::Tens
}
}

at::Tensor bf16_gemm(at::Tensor A, at::Tensor B, std::optional<at::Tensor> bias = c10::nullopt) {
at::Tensor bf16_gemm(at::Tensor A, at::Tensor B, std::optional<at::Tensor> bias = std::nullopt) {
TORCH_CHECK(
A.dtype() == at::kBFloat16 && B.dtype() == at::kBFloat16,
"Inputs must be bfloat16.");
Expand Down
4 changes: 2 additions & 2 deletions fbgemm_gpu/experimental/gen_ai/src/gemm/gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace fbgemm_gpu {
at::Tensor bf16_gemm(
at::Tensor A,
at::Tensor B,
std::optional<at::Tensor> bias = c10::nullopt);
std::optional<at::Tensor> bias = std::nullopt);

TORCH_LIBRARY_FRAGMENT(fbgemm, m) {
#ifdef USE_ROCM
Expand All @@ -31,7 +31,7 @@ TORCH_LIBRARY_IMPL(fbgemm, CUDA, m) {
at::Tensor bf16_gemm_meta(
at::Tensor A,
at::Tensor B,
std::optional<at::Tensor> /* bias */ = c10::nullopt) {
std::optional<at::Tensor> /* bias */ = std::nullopt) {
const at::SymInt M = A.sym_size(0);
const at::SymInt N = B.sym_size(0);
auto C = at::empty_symint({M, N}, A.options().dtype(at::kBFloat16));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ at::Tensor f8f8bf16_rowwise(
at::Tensor w_scale,
std::optional<at::Tensor> bias,
bool use_fast_accum,
std::optional<at::Tensor> output = c10::nullopt) {
std::optional<at::Tensor> output = std::nullopt) {
// Check that input datatypes are valid.
TORCH_CHECK(
(XQ.dtype() == at::kFloat8_e4m3fnuz) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ namespace fbgemm_gpu {
at::Tensor f8f8bf16_cublas(
at::Tensor A, // FP8
at::Tensor B, // FP8
std::optional<at::Tensor> Ainvs = c10::nullopt,
std::optional<at::Tensor> Binvs = c10::nullopt,
std::optional<at::Tensor> Ainvs = std::nullopt,
std::optional<at::Tensor> Binvs = std::nullopt,
bool use_fast_accum = true,
std::optional<at::Tensor> output = c10::nullopt) {
std::optional<at::Tensor> output = std::nullopt) {
auto m = A.size(0);
auto n = B.size(0);
auto k = A.size(1);
Expand Down Expand Up @@ -167,10 +167,10 @@ at::Tensor f8f8bf16_cublas(
at::Tensor f8f8bf16_cublas(
at::Tensor A, // FP8
at::Tensor B, // FP8
std::optional<at::Tensor> Ainvs = c10::nullopt,
std::optional<at::Tensor> Binvs = c10::nullopt,
std::optional<at::Tensor> Ainvs = std::nullopt,
std::optional<at::Tensor> Binvs = std::nullopt,
bool use_fast_accum = true,
std::optional<at::Tensor> output = c10::nullopt) {
std::optional<at::Tensor> output = std::nullopt) {
throw std::runtime_error(
"CUDA version is older than 12.0"); // requires CUDA>=12
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ at::Tensor f8f8bf16_rowwise(
at::Tensor WQ, // FP8
at::Tensor x_scale, // FP32
at::Tensor w_scale, // FP32
std::optional<at::Tensor> bias = c10::nullopt,
std::optional<at::Tensor> bias = std::nullopt,
bool use_fast_accum = true,
std::optional<at::Tensor> output = c10::nullopt) {
std::optional<at::Tensor> output = std::nullopt) {
// Check datatypes.
TORCH_CHECK(
x_scale.dtype() == at::kFloat && w_scale.dtype() == at::kFloat,
Expand Down Expand Up @@ -482,9 +482,9 @@ at::Tensor f8f8bf16_rowwise(
at::Tensor WQ, // FP8
at::Tensor x_scale,
at::Tensor w_scale,
std::optional<at::Tensor> bias = c10::nullopt,
std::optional<at::Tensor> bias = std::nullopt,
bool use_fast_accum = true,
std::optional<at::Tensor> output = c10::nullopt) {
std::optional<at::Tensor> output = std::nullopt) {
throw std::runtime_error(
"CUDA version is older than 12.0"); // requires CUDA>=12
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,9 @@ at::Tensor f8f8bf16_rowwise_batched(
at::Tensor WQ, // FP8
at::Tensor x_scale, // FP32
at::Tensor w_scale, // FP32
std::optional<at::Tensor> bias = c10::nullopt,
std::optional<at::Tensor> bias = std::nullopt,
bool use_fast_accum = true,
std::optional<at::Tensor> output = c10::nullopt) {
std::optional<at::Tensor> output = std::nullopt) {
// Check datatypes.
TORCH_CHECK(
x_scale.dtype() == at::kFloat && w_scale.dtype() == at::kFloat,
Expand Down Expand Up @@ -720,9 +720,9 @@ at::Tensor f8f8bf16_rowwise_batched(
at::Tensor WQ, // FP8
at::Tensor x_scale,
at::Tensor w_scale,
std::optional<at::Tensor> bias = c10::nullopt,
std::optional<at::Tensor> bias = std::nullopt,
bool use_fast_accum = true,
std::optional<at::Tensor> output = c10::nullopt) {
std::optional<at::Tensor> output = std::nullopt) {
throw std::runtime_error(
"CUDA version is older than 12.0"); // requires CUDA>=12
}
Expand Down
14 changes: 7 additions & 7 deletions fbgemm_gpu/experimental/gen_ai/src/quantize/quantize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ at::Tensor f8f8bf16_rowwise(
at::Tensor WQ,
at::Tensor x_scale,
at::Tensor w_scale,
std::optional<at::Tensor> bias = c10::nullopt,
std::optional<at::Tensor> bias = std::nullopt,
bool use_fast_accum = true,
std::optional<at::Tensor> output = c10::nullopt);
std::optional<at::Tensor> output = std::nullopt);
at::Tensor f8f8bf16_rowwise_batched(
at::Tensor XQ,
at::Tensor WQ,
at::Tensor x_scale,
at::Tensor w_scale,
std::optional<at::Tensor> bias = c10::nullopt,
std::optional<at::Tensor> bias = std::nullopt,
bool use_fast_accum = true,
std::optional<at::Tensor> output = c10::nullopt);
std::optional<at::Tensor> output = std::nullopt);
at::Tensor f8f8bf16_blockwise(
at::Tensor XQ,
at::Tensor WQ,
Expand All @@ -81,10 +81,10 @@ at::Tensor f8f8bf16_blockwise(
at::Tensor f8f8bf16_cublas(
at::Tensor A,
at::Tensor B,
std::optional<at::Tensor> Ainvs = c10::nullopt,
std::optional<at::Tensor> Binvs = c10::nullopt,
std::optional<at::Tensor> Ainvs = std::nullopt,
std::optional<at::Tensor> Binvs = std::nullopt,
bool use_fast_accum = true,
std::optional<at::Tensor> output = c10::nullopt);
std::optional<at::Tensor> output = std::nullopt);
at::Tensor f8i4bf16_rowwise(
at::Tensor XQ,
at::Tensor WQ,
Expand Down
12 changes: 6 additions & 6 deletions fbgemm_gpu/include/fbgemm_gpu/embedding_inplace_update.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ void embedding_inplace_update_cuda(
Tensor update_row_idx,
Tensor update_offsets,
const int64_t row_alignment,
std::optional<Tensor> lxu_cache_weights = c10::nullopt,
std::optional<Tensor> lxu_cache_locations = c10::nullopt);
std::optional<Tensor> lxu_cache_weights = std::nullopt,
std::optional<Tensor> lxu_cache_locations = std::nullopt);

void embedding_inplace_update_single_placement_cuda(
Tensor& dev_weights,
Expand All @@ -69,8 +69,8 @@ void embedding_inplace_update_single_placement_cuda(
const Tensor& update_row_idx,
const Tensor& update_offsets,
const int64_t row_alignment,
std::optional<Tensor> lxu_cache_weights = c10::nullopt,
std::optional<Tensor> lxu_cache_locations = c10::nullopt);
std::optional<Tensor> lxu_cache_weights = std::nullopt,
std::optional<Tensor> lxu_cache_locations = std::nullopt);

void embedding_inplace_update_cpu(
Tensor dev_weights,
Expand All @@ -85,9 +85,9 @@ void embedding_inplace_update_cpu(
Tensor update_offsets,
const int64_t row_alignment,
std::optional<Tensor> lxu_cache_weights =
c10::nullopt, // Not used, to match cache interface for CUDA op
std::nullopt, // Not used, to match cache interface for CUDA op
std::optional<Tensor> lxu_cache_locations =
c10::nullopt // Not used, to match cache interface for CUDA op
std::nullopt // Not used, to match cache interface for CUDA op
);

/**
Expand Down
2 changes: 1 addition & 1 deletion fbgemm_gpu/include/fbgemm_gpu/sparse_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ std::vector<at::Tensor> jagged_index_select_2d(
const at::Tensor& values,
const at::Tensor& lengths,
const at::Tensor& indices,
const std::optional<int64_t> num_dense_output_rows = c10::nullopt);
const std::optional<int64_t> num_dense_output_rows = std::nullopt);

at::Tensor jagged_index_select_2d_forward_cpu(
const at::Tensor& values,
Expand Down
4 changes: 2 additions & 2 deletions fbgemm_gpu/src/quantize_ops/quantize_ops_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Tensor& _float_to_fused8bitrowwise_cpu_out_t(

auto output_dims = input_sizes.vec();
output_dims[last_dim] = output_columns;
at::native::resize_(output, output_dims, c10::nullopt);
at::native::resize_(output, output_dims, std::nullopt);

const auto input_data = static_cast<input_t*>(
input.data_ptr()); // input.data_ptr<input_t>(); -> Yields
Expand Down Expand Up @@ -73,7 +73,7 @@ Tensor& _fused8bitrowwise_to_float_cpu_out_t(

auto output_dims = input_sizes.vec();
output_dims[last_dim] = output_columns;
at::native::resize_(output, output_dims, c10::nullopt);
at::native::resize_(output, output_dims, std::nullopt);

auto output_data = static_cast<output_t*>(
output.data_ptr()); // output.data_ptr<output_t>(); -> Yields
Expand Down
2 changes: 1 addition & 1 deletion fbgemm_gpu/src/sparse_ops/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ inline Tensor native_empty_like(const Tensor& self) {
self.options().layout_opt(),
self.options().device_opt(),
self.options().pinned_memory_opt(),
c10::nullopt);
std::nullopt);
}

} // namespace
Expand Down
2 changes: 1 addition & 1 deletion fbgemm_gpu/src/sparse_ops/sparse_async_cumsum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void asynchronous_exclusive_cumsum_cpu_out(Tensor& t_out, const Tensor& t_in) {
TENSOR_ON_CPU(t_out);

const auto t_in_contig = t_in.expect_contiguous();
at::native::resize_(t_out, t_in_contig->sizes(), c10::nullopt);
at::native::resize_(t_out, t_in_contig->sizes(), std::nullopt);

FBGEMM_DISPATCH_ALL_TYPES(
t_in_contig->scalar_type(),
Expand Down
2 changes: 1 addition & 1 deletion fbgemm_gpu/src/sparse_ops/sparse_ops_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,7 @@ Tensor& lengths_range_out(
});
}

at::native::resize_(output, {output_size}, c10::nullopt);
at::native::resize_(output, {output_size}, std::nullopt);

AT_DISPATCH_INDEX_TYPES(
t_in_contig->scalar_type(), "lengths_range_compute", [&]() {
Expand Down
4 changes: 2 additions & 2 deletions fbgemm_gpu/src/sparse_ops/sparse_permute_1d.cu
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ permute_1D_sparse_data_cuda(
return {
lengths.view({-1}).clone(),
indices.clone(),
weights.has_value() ? c10::make_optional(weights->clone())
: c10::nullopt};
weights.has_value() ? std::make_optional(weights->clone())
: std::nullopt};
}

Tensor permuted_lengths;
Expand Down
4 changes: 2 additions & 2 deletions fbgemm_gpu/src/sparse_ops/sparse_permute_2d.cu
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ permute_2D_sparse_data_cuda(
return {
lengths.clone(),
indices.clone(),
weights.has_value() ? c10::make_optional(weights->clone())
: c10::nullopt,
weights.has_value() ? std::make_optional(weights->clone())
: std::nullopt,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ get_unique_indices_cuda_impl(
auto unique_indices = at::empty_like(linear_indices);
auto unique_indices_length =
at::empty({1}, linear_indices.options().dtype(at::kInt));
std::optional<Tensor> unique_indices_count = c10::nullopt;
std::optional<Tensor> linear_index_positions_sorted = c10::nullopt;
std::optional<Tensor> unique_indices_count = std::nullopt;
std::optional<Tensor> linear_index_positions_sorted = std::nullopt;
Tensor linear_index_positions;
if (compute_inverse_indices) {
Expand Down
2 changes: 1 addition & 1 deletion fbgemm_gpu/src/split_embeddings_cache/lru_cache_find.cu
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ lru_cache_find_uncached_cuda(
auto cache_set_sorted_unique_indices = empty_like(unique_indices);
Tensor cache_sets_positions;
std::optional<Tensor> cache_set_inverse_indices = c10::nullopt;
std::optional<Tensor> cache_set_inverse_indices = std::nullopt;
if (compute_inverse_indices) {
TORCH_CHECK(
cache_sets.numel() <=
Expand Down

0 comments on commit 3375de1

Please sign in to comment.