Class EmbeddingBagImpl

Inheritance Relationships

Base Type

Class Documentation

class torch::nn::EmbeddingBagImpl : public torch::nn::Cloneable<EmbeddingBagImpl>

Computes sums or means of ‘bags’ of embeddings, without instantiating the intermediate embeddings.

See to learn about the exact behavior of this module.

See the documentation for torch::nn::EmbeddingBagOptions class to learn what constructor arguments are supported for this module.


EmbeddingBag model(EmbeddingBagOptions(10,

Public Functions

EmbeddingBagImpl(int64_t num_embeddings, int64_t embedding_dim)
EmbeddingBagImpl(const EmbeddingBagOptions &options_)
void reset() override

reset() must perform initialization of all members with reference semantics, most importantly parameters, buffers and submodules.

void reset_parameters()
void pretty_print(std::ostream &stream) const override

Pretty prints the EmbeddingBag module into the given stream.

Tensor forward(const Tensor &input, const Tensor &offsets = {}, const Tensor &per_sample_weights = {})

Public Members

EmbeddingBagOptions options

The Options used to configure this EmbeddingBag module.

Tensor weight

The embedding table.

Protected Functions

bool _forward_has_default_args() override

The following three functions allow a module with default arguments in its forward method to be used in a Sequential module.

You should NEVER override these functions manually. Instead, you should use the FORWARD_HAS_DEFAULT_ARGS macro.

unsigned int _forward_num_required_args() override
std::vector<torch::nn::AnyValue> _forward_populate_default_args(std::vector<torch::nn::AnyValue> &&arguments) override


friend struct torch::nn::AnyModuleHolder


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources