MCPcopy Create free account
hub / github.com/CompVis/diff2flow / forward

Method forward

diff2flow/conditioning/encoders.py:241–249  ·  view source on GitHub ↗
(self, text)

Source from the content-addressed store, hash-verified

239 param.requires_grad = False
240
241 def forward(self, text):
242 dev = next(self.parameters()).device
243 batch_encoding = self.tokenizer(text, truncation=True, max_length=self.max_length, return_length=True,
244 return_overflowing_tokens=False, padding="max_length", return_tensors="pt")
245 tokens = batch_encoding["input_ids"].to(dev)
246 outputs = self.transformer(input_ids=tokens)
247
248 z = outputs.last_hidden_state
249 return z
250
251 def encode(self, text):
252 return self(text)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected