pytorch/docs/source
Xiong Wei da10ccd35f Implements cpu_kernel_multiple_outputs and torch.frexp (#51097)
Summary:
Close https://github.com/pytorch/pytorch/issues/51108
Related https://github.com/pytorch/pytorch/issues/38349

This PR implements the `cpu_kernel_multiple_outputs` to support returning multiple values in a CPU kernel.
```c++
auto iter = at::TensorIteratorConfig()
  .add_output(out1)
  .add_output(out2)
  .add_input(in1)
  .add_input(in2)
  .build();

at::native::cpu_kernel_multiple_outputs(iter,
  [=](float a, float b) -> std::tuple<float, float> {
    float add = a + b;
    float mul = a * b;
    return std::tuple<float, float>(add, mul);
  }
);
```

The `out1` will equal to `torch.add(in1, in2)`, while the result of `out2` will be `torch.mul(in1, in2)`.
It helps developers implement new torch functions that return two tensors more conveniently, such as NumPy-like functions [divmod](https://numpy.org/doc/1.18/reference/generated/numpy.divmod.html?highlight=divmod#numpy.divmod) and [frexp](https://numpy.org/doc/stable/reference/generated/numpy.frexp.html#numpy.frexp).

This PR adds `torch.frexp` function to exercise the new functionality provided by `cpu_kernel_multiple_outputs`.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/51097

Reviewed By: albanD

Differential Revision: D26982619

Pulled By: heitorschueroff

fbshipit-source-id: cb61c7f2c79873ab72ab5a61cbdb9203531ad469
2021-03-15 10:44:32 -07:00
..
_static Add documentation page for pipeline parallelism. (#50791) 2021-01-25 13:47:13 -08:00
_templates
_templates-stable
community
notes Fix inport -> import typo in documentation (#53589) 2021-03-08 23:56:42 -08:00
rpc Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08:00
scripts
__config__.rst
amp.rst
autograd.rst
backends.rst Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08:00
benchmark_utils.rst Expand benchmark utils docs (#51664) 2021-02-04 00:22:41 -08:00
bottleneck.rst
checkpoint.rst
complex_numbers.rst Doc update for complex numbers (#51129) 2021-01-27 07:32:26 -08:00
conf.py
cpp_extension.rst
cpp_index.rst
cuda.rst expose memory_fraction and gpu_process docs (#51372) 2021-01-29 18:22:34 -08:00
cudnn_persistent_rnn.rst Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08:00
cudnn_rnn_determinism.rst Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08:00
data.rst Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08:00
ddp_comm_hooks.rst [Gradient Compression] Make FP16 compression as a wrapper that can be combined with other communication hooks (#53808) 2021-03-12 17:31:07 -08:00
distributed.optim.rst [Reland] Update and expose ZeroRedundancyOptimizer docs (#53112) 2021-03-02 14:16:12 -08:00
distributed.rst [doc] reorg dist init and non-init functions (#52976) 2021-03-12 08:48:18 -08:00
distributions.rst Add sample validation for LKJCholesky.log_prob (#52763) 2021-02-25 16:12:29 -08:00
dlpack.rst
docutils.conf
fft.rst
futures.rst
fx.rst [FX][docs] Render inherited methods in fx.Tracer API reference (#53630) 2021-03-09 14:30:41 -08:00
hub.rst
index.rst [special] add torch.special namespace (#52296) 2021-03-04 00:04:36 -08:00
jit.rst [docs] Add starter content for new TorchScript language reference (#53837) 2021-03-11 18:18:27 -08:00
jit_builtin_functions.rst
jit_language_reference.rst add type annotations to torch.nn.modules.conv (#49564) 2021-01-15 11:16:11 -08:00
jit_language_reference_v2.rst [docs] Add starter content for new TorchScript language reference (#53837) 2021-03-11 18:18:27 -08:00
jit_python_reference.rst
jit_unsupported.rst
linalg.rst Implements torch.linalg.lstsq (#49093) 2021-03-12 13:25:55 -08:00
math-quantizer-equation.png
mobile_optimizer.rst
model_zoo.rst
multiprocessing.rst Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08:00
name_inference.rst
named_tensor.rst Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08:00
nn.functional.rst Huber loss (#50553) 2021-03-02 17:30:45 -08:00
nn.init.rst
nn.rst Parametrization Functionality (#33344) 2021-03-04 12:45:27 -08:00
onnx.rst [ONNX] Update ONNX documentation (#51362) (#53313) 2021-03-12 02:49:38 -08:00
optim.rst Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08:00
pipeline.rst Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08:00
profiler.rst Update docs for torch.profiler.tensorboard_trace_handler (#51636) 2021-02-04 13:32:59 -08:00
quantization-support.rst [quantization] Add some support for 3d operations (#50003) 2021-03-10 16:40:35 -08:00
quantization.rst Fix quantization doc issue (#50187) 2021-02-02 20:33:21 -08:00
random.rst
rpc.rst Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08:00
sparse.rst [wip] doc_fix (#51825) 2021-02-06 11:36:36 -08:00
special.rst [special] add torch.special namespace (#52296) 2021-03-04 00:04:36 -08:00
storage.rst [docs] Add docs for storage and tensors for quantized Tensor (#51817) 2021-02-09 13:20:56 -08:00
tensor_attributes.rst Fix the repeated entry in the Tensor Attributes doc (#52995) 2021-03-01 16:42:32 -08:00
tensor_view.rst
tensorboard.rst
tensors.rst Implements cpu_kernel_multiple_outputs and torch.frexp (#51097) 2021-03-15 10:44:32 -07:00
torch.nn.intrinsic.qat.rst [quantization] Add some support for 3d operations (#50003) 2021-03-10 16:40:35 -08:00
torch.nn.intrinsic.quantized.rst
torch.nn.intrinsic.rst [quantization] Add some support for 3d operations (#50003) 2021-03-10 16:40:35 -08:00
torch.nn.qat.rst
torch.nn.quantized.dynamic.rst Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08:00
torch.nn.quantized.rst [quant] add docs for embedding/embedding_bag (#51770) 2021-02-05 11:43:15 -08:00
torch.overrides.rst
torch.quantization.rst Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08:00
torch.rst Implements cpu_kernel_multiple_outputs and torch.frexp (#51097) 2021-03-15 10:44:32 -07:00
type_info.rst