pytorch/test/cpp/api
Kurt Mohler 3fe4718d16 Add padding_idx argument to EmbeddingBag (#49237)
Summary:
This PR adds a `padding_idx` parameter to `nn.EmbeddingBag` and `nn.functional.embedding_bag`. As with `nn.Embedding`'s `padding_idx` argument, if an embedding's index is equal to `padding_idx` it is ignored, so it is not included in the reduction.

This PR does not add support for `padding_idx` for quantized or ONNX `EmbeddingBag` for opset10/11 (opset9 is supported). In these cases, an error is thrown if `padding_idx` is provided.

Fixes https://github.com/pytorch/pytorch/issues/3194

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

Reviewed By: walterddr, VitalyFedyunin

Differential Revision: D26948258

Pulled By: jbschlosser

fbshipit-source-id: 3ca672f7e768941f3261ab405fc7597c97ce3dfc
2021-04-14 09:38:01 -07:00
..
any.cpp
autograd.cpp
CMakeLists.txt Implement public API InferenceMode and its error handling (#55008) 2021-03-31 10:48:00 -07:00
dataloader.cpp Lint trailing newlines (#54737) 2021-03-30 13:09:52 -07:00
dispatch.cpp
enum.cpp
expanding-array.cpp
fft.cpp
functional.cpp Add padding_idx argument to EmbeddingBag (#49237) 2021-04-14 09:38:01 -07:00
grad_mode.cpp [WIP]Relax some limitations of InferenceMode. (#54403) 2021-04-09 14:40:37 -07:00
inference_mode.cpp [WIP]Relax some limitations of InferenceMode. (#54403) 2021-04-09 14:40:37 -07:00
init.cpp
init_baseline.h Lint trailing newlines (#54737) 2021-03-30 13:09:52 -07:00
init_baseline.py
integration.cpp
jit.cpp
memory.cpp
misc.cpp
module.cpp
moduledict.cpp
modulelist.cpp
modules.cpp Add padding_idx argument to EmbeddingBag (#49237) 2021-04-14 09:38:01 -07:00
namespace.cpp
nn_utils.cpp Flip clip_grad_norm default for error_if_nonfinite to false (#55169) 2021-04-02 12:25:32 -07:00
operations.cpp
optim.cpp Adding learning rate schedulers to C++ API (#52268) 2021-03-10 23:09:51 -08:00
optim_baseline.h
optim_baseline.py Remove legacy constructor calls from pytorch codebase. (#54142) 2021-04-11 15:45:17 -07:00
ordered_dict.cpp
parallel.cpp
parallel_benchmark.cpp
parameterdict.cpp
parameterlist.cpp
README.md
rnn.cpp
sequential.cpp
serialize.cpp
special.cpp
static.cpp
support.cpp
support.h Implement public API InferenceMode and its error handling (#55008) 2021-03-31 10:48:00 -07:00
tensor.cpp
tensor_cuda.cpp
tensor_flatten.cpp
tensor_indexing.cpp
tensor_options.cpp
tensor_options_cuda.cpp
torch_include.cpp
transformer.cpp

C++ Frontend Tests

In this folder live the tests for PyTorch's C++ Frontend. They use the GoogleTest test framework.

CUDA Tests

To make a test runnable only on platforms with CUDA, you should suffix your test with _CUDA, e.g.

TEST(MyTestSuite, MyTestCase_CUDA) { }

To make it runnable only on platforms with at least two CUDA machines, suffix it with _MultiCUDA instead of _CUDA, e.g.

TEST(MyTestSuite, MyTestCase_MultiCUDA) { }

There is logic in main.cpp that detects the availability and number of CUDA devices and supplies the appropriate negative filters to GoogleTest.

Integration Tests

Integration tests use the MNIST dataset. You must download it by running the following command from the PyTorch root folder:

$ python tools/download_mnist.py -d test/cpp/api/mnist

The required paths will be referenced as test/cpp/api/mnist/... in the test code, so you must run the integration tests from the PyTorch root folder.