mirror of
https://github.com/2noise/ChatTTS.git
synced 2026-08-31 01:12:28 +08:00
fix(gpt): compile failed
This commit is contained in:
+9
-2
@@ -259,6 +259,7 @@ class Chat:
|
||||
device = select_device()
|
||||
self.logger.info("use device %s", str(device))
|
||||
self.device = device
|
||||
self.compile = compile
|
||||
|
||||
if vocos_config_path:
|
||||
vocos = (
|
||||
@@ -548,7 +549,10 @@ class Chat:
|
||||
|
||||
input_ids, attention_mask, text_mask = self._text_to_token(text, gpt.device_gpt)
|
||||
|
||||
emb = gpt(input_ids, text_mask)
|
||||
with torch.inference_mode(not self.compile):
|
||||
with torch.no_grad():
|
||||
emb = gpt(input_ids, text_mask)
|
||||
|
||||
del text_mask
|
||||
|
||||
if params.spk_emb is not None:
|
||||
@@ -612,7 +616,10 @@ class Chat:
|
||||
repetition_penalty=params.repetition_penalty,
|
||||
)
|
||||
|
||||
emb = gpt(input_ids, text_mask)
|
||||
with torch.inference_mode(not self.compile):
|
||||
with torch.no_grad():
|
||||
emb = gpt(input_ids, text_mask)
|
||||
|
||||
del text_mask
|
||||
|
||||
result = next(
|
||||
|
||||
+12
-9
@@ -366,6 +366,7 @@ class GPT(nn.Module):
|
||||
show_tqdm=True,
|
||||
ensure_non_empty=True,
|
||||
stream_batch=24,
|
||||
compile=False,
|
||||
context=Context(),
|
||||
):
|
||||
|
||||
@@ -435,15 +436,17 @@ class GPT(nn.Module):
|
||||
|
||||
model_input.to(self.device_gpt, self.gpt.dtype)
|
||||
|
||||
outputs: BaseModelOutputWithPast = self.gpt(
|
||||
attention_mask=model_input.attention_mask,
|
||||
position_ids=model_input.position_ids,
|
||||
past_key_values=model_input.past_key_values,
|
||||
inputs_embeds=model_input.inputs_embeds,
|
||||
use_cache=model_input.use_cache,
|
||||
output_attentions=return_attn,
|
||||
cache_position=model_input.cache_position,
|
||||
)
|
||||
with torch.inference_mode(not compile):
|
||||
with torch.no_grad():
|
||||
outputs: BaseModelOutputWithPast = self.gpt(
|
||||
attention_mask=model_input.attention_mask,
|
||||
position_ids=model_input.position_ids,
|
||||
past_key_values=model_input.past_key_values,
|
||||
inputs_embeds=model_input.inputs_embeds,
|
||||
use_cache=model_input.use_cache,
|
||||
output_attentions=return_attn,
|
||||
cache_position=model_input.cache_position,
|
||||
)
|
||||
del_all(model_input)
|
||||
attentions.append(outputs.attentions)
|
||||
hidden_states = outputs.last_hidden_state.to(
|
||||
|
||||
Reference in New Issue
Block a user