Skip to content

Commit 25c933f

Browse files
jtmerOswinGuai
andauthored
Fixed the issue of abnormal output when the input length of timerxl is not a multiple of 96 (#15495)
Co-authored-by: OswinGuai <[email protected]>
1 parent 7868917 commit 25c933f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

iotdb-core/ainode/ainode/TimerXL/models/timer_xl.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,18 @@ def forward(self, x, max_new_tokens: int = 96):
253253
self.eval()
254254
self.device = next(self.model.parameters()).device
255255

256+
if len(x.shape) == 2:
257+
batch_size, cur_len = x.shape
258+
if cur_len < self.config.input_token_len:
259+
raise ValueError(
260+
f"Input length must be at least {self.config.input_token_len}")
261+
elif cur_len % self.config.input_token_len != 0:
262+
new_len = (cur_len // self.config.input_token_len) * \
263+
self.config.input_token_len
264+
x = x[:, -new_len:]
265+
else:
266+
raise ValueError('Input shape must be: [batch_size, seq_len]')
267+
256268
use_cache = self.config.use_cache
257269
all_input_ids = x
258270

0 commit comments

Comments
 (0)