Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module fn forward should pass a modifiable context #911

Open
Jabberwocky238 opened this issue Nov 18, 2024 · 0 comments
Open

Module fn forward should pass a modifiable context #911

Jabberwocky238 opened this issue Nov 18, 2024 · 0 comments

Comments

@Jabberwocky238
Copy link

in python transformers module, there are lots of context(additional params) passing in forwarding

like LlamaModel

def forward(
        self,
        input_ids: torch.LongTensor = None,
        attention_mask: Optional[torch.Tensor] = None,
        position_ids: Optional[torch.LongTensor] = None,
        past_key_values: Optional[List[torch.FloatTensor]] = None,
        inputs_embeds: Optional[torch.FloatTensor] = None,
        use_cache: Optional[bool] = None,
        output_attentions: Optional[bool] = None,
        output_hidden_states: Optional[bool] = None,
        return_dict: Optional[bool] = None,
        cache_position: Optional[torch.LongTensor] = None,
    ) -> Union[Tuple, BaseModelOutputWithPast]:

def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pub trait Module<Ctx>: std::fmt::Debug + Send {
    fn forward(&self, xs: &Tensor, ctx: Option<Ctx>) -> Tensor;
}

Is it a good solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant