:github_url: https://github.com/pytorch/pytorch .. _program_listing_file_torch_csrc_api_include_torch_nn_options_transformerlayer.h: Program Listing for File transformerlayer.h =========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``torch/csrc/api/include/torch/nn/options/transformerlayer.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include #include #include #include namespace torch::nn { using activation_t = std::variant< enumtype::kReLU, enumtype::kGELU, std::function>; struct TORCH_API TransformerEncoderLayerOptions { /* implicit */ TransformerEncoderLayerOptions(int64_t d_model, int64_t nhead); TORCH_ARG(int64_t, d_model); TORCH_ARG(int64_t, nhead); TORCH_ARG(int64_t, dim_feedforward) = 2048; TORCH_ARG(double, dropout) = 0.1; TORCH_ARG(activation_t, activation) = torch::kReLU; }; // ============================================================================ struct TORCH_API TransformerDecoderLayerOptions { TransformerDecoderLayerOptions(int64_t d_model, int64_t nhead); TORCH_ARG(int64_t, d_model); TORCH_ARG(int64_t, nhead); TORCH_ARG(int64_t, dim_feedforward) = 2048; TORCH_ARG(double, dropout) = 0.1; TORCH_ARG(activation_t, activation) = torch::kReLU; }; } // namespace torch::nn