mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2026-04-23 08:21:53 +08:00
init version, exist some bugs, waiting fix (#4906)
CE Compile Job / ce_job_pre_check (push) Has been cancelled
CE Compile Job / print_ce_job_pre_check_outputs (push) Has been cancelled
CE Compile Job / FD-Clone-Linux (push) Has been cancelled
CE Compile Job / Show Code Archive Output (push) Has been cancelled
CE Compile Job / BUILD_SM8090 (push) Has been cancelled
CE Compile Job / BUILD_SM8689 (push) Has been cancelled
CE Compile Job / CE_UPLOAD (push) Has been cancelled
Deploy GitHub Pages / deploy (push) Has been cancelled
CE Compile Job / ce_job_pre_check (push) Has been cancelled
CE Compile Job / print_ce_job_pre_check_outputs (push) Has been cancelled
CE Compile Job / FD-Clone-Linux (push) Has been cancelled
CE Compile Job / Show Code Archive Output (push) Has been cancelled
CE Compile Job / BUILD_SM8090 (push) Has been cancelled
CE Compile Job / BUILD_SM8689 (push) Has been cancelled
CE Compile Job / CE_UPLOAD (push) Has been cancelled
Deploy GitHub Pages / deploy (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
|
||||
from fastdeploy.output.stream_transfer_data import DecoderState, StreamTransferData
|
||||
|
||||
|
||||
class TestStreamTransferData(unittest.TestCase):
|
||||
|
||||
def test_dataclass_initialization(self):
|
||||
tokens = np.array([1, 2, 3])
|
||||
logprobs = np.array([0.1, 0.2, 0.3])
|
||||
accept_tokens = np.array([1, 0, 1])
|
||||
accept_num = np.array([2])
|
||||
pooler_output = np.random.rand(2, 4)
|
||||
|
||||
data = StreamTransferData.__new__(StreamTransferData)
|
||||
data.decoder_state = DecoderState.TEXT
|
||||
data.batch_id = 42
|
||||
data.tokens = tokens
|
||||
data.speculaive_decoding = True
|
||||
data.logprobs = logprobs
|
||||
data.accept_tokens = accept_tokens
|
||||
data.accept_num = accept_num
|
||||
data.pooler_output = pooler_output
|
||||
|
||||
self.assertEqual(data.decoder_state, DecoderState.TEXT)
|
||||
self.assertEqual(data.batch_id, 42)
|
||||
self.assertTrue(np.array_equal(data.tokens, tokens))
|
||||
self.assertTrue(data.speculaive_decoding)
|
||||
self.assertTrue(np.array_equal(data.logprobs, logprobs))
|
||||
self.assertTrue(np.array_equal(data.accept_tokens, accept_tokens))
|
||||
self.assertTrue(np.array_equal(data.accept_num, accept_num))
|
||||
self.assertTrue(np.array_equal(data.pooler_output, pooler_output))
|
||||
|
||||
def test_optional_fields_none(self):
|
||||
data = StreamTransferData.__new__(StreamTransferData)
|
||||
data.decoder_state = DecoderState.IMAGE
|
||||
data.batch_id = 1
|
||||
|
||||
self.assertEqual(data.decoder_state, DecoderState.IMAGE)
|
||||
self.assertEqual(data.batch_id, 1)
|
||||
self.assertIsNone(getattr(data, "tokens", None))
|
||||
self.assertFalse(getattr(data, "speculaive_decoding", False))
|
||||
self.assertIsNone(getattr(data, "logprobs", None))
|
||||
self.assertIsNone(getattr(data, "accept_tokens", None))
|
||||
self.assertIsNone(getattr(data, "accept_num", None))
|
||||
self.assertIsNone(getattr(data, "pooler_output", None))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user