Skip to content

Commit

Permalink
[codemod] c10::optional -> std::optional in pyspeech/experimental/csr…
Browse files Browse the repository at this point in the history
…c/decoders/TransducerDecoder.h +20

Summary: `c10::optional` was switched to be `std::optional` after PyTorch moved to C++17. Let's eliminate `c10::optional`, if we can.

Reviewed By: albanD

Differential Revision: D57294284
  • Loading branch information
r-barnes authored and facebook-github-bot committed May 14, 2024
1 parent ea437b3 commit 9e9ac54
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/source/libtorio.stream_reader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ StreamingMediaDecoder

.. doxygenclass:: torio::io::StreamingMediaDecoder

.. doxygenfunction:: torio::io::StreamingMediaDecoder::StreamingMediaDecoder(const std::string &src, const c10::optional<std::string> &format = {}, const c10::optional<OptionDict> &option = {})
.. doxygenfunction:: torio::io::StreamingMediaDecoder::StreamingMediaDecoder(const std::string &src, const std::optional<std::string> &format = {}, const c10::optional<OptionDict> &option = {})

StreamingMediaDecoderCustomIO
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/source/libtorio.stream_writer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ StreamingMediaEncoder

.. doxygenclass:: torio::io::StreamingMediaEncoder

.. doxygenfunction:: torio::io::StreamingMediaEncoder::StreamingMediaEncoder(const std::string &dst, const c10::optional<std::string> &format = {})
.. doxygenfunction:: torio::io::StreamingMediaEncoder::StreamingMediaEncoder(const std::string &dst, const std::optional<std::string> &format = {})

StreamingMediaEncoderCustomIO
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/libtorchaudio/rnnt/autograd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class RNNTLossFunction : public torch::autograd::Function<RNNTLossFunction> {
}
};

std::tuple<torch::Tensor, c10::optional<torch::Tensor>> rnnt_loss_autograd(
std::tuple<torch::Tensor, std::optional<torch::Tensor>> rnnt_loss_autograd(
torch::Tensor& logits,
const torch::Tensor& targets,
const torch::Tensor& logit_lengths,
Expand Down
2 changes: 1 addition & 1 deletion src/libtorchaudio/rnnt/compute.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <libtorchaudio/rnnt/compute.h>
#include <torch/script.h>

std::tuple<torch::Tensor, c10::optional<torch::Tensor>> rnnt_loss(
std::tuple<torch::Tensor, std::optional<torch::Tensor>> rnnt_loss(
torch::Tensor& logits,
const torch::Tensor& targets,
const torch::Tensor& logit_lengths,
Expand Down
2 changes: 1 addition & 1 deletion src/libtorchaudio/rnnt/compute.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <torch/script.h>

std::tuple<torch::Tensor, c10::optional<torch::Tensor>> rnnt_loss(
std::tuple<torch::Tensor, std::optional<torch::Tensor>> rnnt_loss(
torch::Tensor& logits,
const torch::Tensor& targets,
const torch::Tensor& logit_lengths,
Expand Down
4 changes: 2 additions & 2 deletions src/libtorchaudio/rnnt/cpu/compute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace rnnt {
namespace cpu {

// Entry point into RNNT Loss
std::tuple<torch::Tensor, c10::optional<torch::Tensor>> compute(
std::tuple<torch::Tensor, std::optional<torch::Tensor>> compute(
torch::Tensor& logits,
const torch::Tensor& targets,
const torch::Tensor& logit_lengths,
Expand Down Expand Up @@ -89,7 +89,7 @@ std::tuple<torch::Tensor, c10::optional<torch::Tensor>> compute(
torch::Tensor costs = torch::empty(
options.batchSize_ * options.nHypos_,
torch::TensorOptions().device(logits.device()).dtype(logits.dtype()));
c10::optional<torch::Tensor> gradients = torch::zeros_like(logits);
std::optional<torch::Tensor> gradients = torch::zeros_like(logits);

torch::Tensor int_workspace = torch::empty(
IntWorkspace::ComputeSizeFromOptions(options),
Expand Down
4 changes: 2 additions & 2 deletions src/libtorchaudio/rnnt/gpu/compute.cu
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace rnnt {
namespace gpu {

// Entry point into RNNT Loss
std::tuple<torch::Tensor, c10::optional<torch::Tensor>> compute(
std::tuple<torch::Tensor, std::optional<torch::Tensor>> compute(
torch::Tensor& logits,
const torch::Tensor& targets,
const torch::Tensor& logit_lengths,
Expand Down Expand Up @@ -92,7 +92,7 @@ std::tuple<torch::Tensor, c10::optional<torch::Tensor>> compute(
torch::Tensor costs = torch::empty(
options.batchSize_ * options.nHypos_,
torch::TensorOptions().device(logits.device()).dtype(logits.dtype()));
c10::optional<torch::Tensor> gradients = torch::zeros_like(logits);
std::optional<torch::Tensor> gradients = torch::zeros_like(logits);

torch::Tensor int_workspace = torch::empty(
IntWorkspace::ComputeSizeFromOptions(options),
Expand Down

0 comments on commit 9e9ac54

Please sign in to comment.