ttnn-visualizer 0.24.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ttnn_visualizer/__init__.py +4 -0
- ttnn_visualizer/app.py +193 -0
- ttnn_visualizer/bin/docker-entrypoint-web +16 -0
- ttnn_visualizer/bin/pip3-install +17 -0
- ttnn_visualizer/csv_queries.py +618 -0
- ttnn_visualizer/decorators.py +117 -0
- ttnn_visualizer/enums.py +12 -0
- ttnn_visualizer/exceptions.py +40 -0
- ttnn_visualizer/extensions.py +14 -0
- ttnn_visualizer/file_uploads.py +78 -0
- ttnn_visualizer/models.py +275 -0
- ttnn_visualizer/queries.py +388 -0
- ttnn_visualizer/remote_sqlite_setup.py +91 -0
- ttnn_visualizer/requirements.txt +24 -0
- ttnn_visualizer/serializers.py +249 -0
- ttnn_visualizer/sessions.py +245 -0
- ttnn_visualizer/settings.py +118 -0
- ttnn_visualizer/sftp_operations.py +486 -0
- ttnn_visualizer/sockets.py +118 -0
- ttnn_visualizer/ssh_client.py +85 -0
- ttnn_visualizer/static/assets/allPaths-CKt4gwo3.js +1 -0
- ttnn_visualizer/static/assets/allPathsLoader-Dzw0zTnr.js +2 -0
- ttnn_visualizer/static/assets/index-BXlT2rEV.js +5247 -0
- ttnn_visualizer/static/assets/index-CsS_OkTl.js +1 -0
- ttnn_visualizer/static/assets/index-DTKBo2Os.css +7 -0
- ttnn_visualizer/static/assets/index-DxLGmC6o.js +1 -0
- ttnn_visualizer/static/assets/site-BTBrvHC5.webmanifest +19 -0
- ttnn_visualizer/static/assets/splitPathsBySizeLoader-HHqSPeQM.js +1 -0
- ttnn_visualizer/static/favicon/android-chrome-192x192.png +0 -0
- ttnn_visualizer/static/favicon/android-chrome-512x512.png +0 -0
- ttnn_visualizer/static/favicon/favicon-32x32.png +0 -0
- ttnn_visualizer/static/favicon/favicon.svg +3 -0
- ttnn_visualizer/static/index.html +36 -0
- ttnn_visualizer/static/sample-data/cluster-desc.yaml +763 -0
- ttnn_visualizer/tests/__init__.py +4 -0
- ttnn_visualizer/tests/test_queries.py +444 -0
- ttnn_visualizer/tests/test_serializers.py +582 -0
- ttnn_visualizer/utils.py +185 -0
- ttnn_visualizer/views.py +794 -0
- ttnn_visualizer-0.24.0.dist-info/LICENSE +202 -0
- ttnn_visualizer-0.24.0.dist-info/LICENSE_understanding.txt +3 -0
- ttnn_visualizer-0.24.0.dist-info/METADATA +144 -0
- ttnn_visualizer-0.24.0.dist-info/RECORD +46 -0
- ttnn_visualizer-0.24.0.dist-info/WHEEL +5 -0
- ttnn_visualizer-0.24.0.dist-info/entry_points.txt +2 -0
- ttnn_visualizer-0.24.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,582 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
|
4
|
+
|
5
|
+
import unittest
|
6
|
+
|
7
|
+
from ttnn_visualizer.models import (
|
8
|
+
Operation,
|
9
|
+
OperationArgument,
|
10
|
+
Tensor,
|
11
|
+
Device,
|
12
|
+
InputTensor,
|
13
|
+
OutputTensor,
|
14
|
+
ProducersConsumers,
|
15
|
+
StackTrace,
|
16
|
+
DeviceOperation,
|
17
|
+
Buffer,
|
18
|
+
BufferType,
|
19
|
+
BufferPage,
|
20
|
+
)
|
21
|
+
from ttnn_visualizer.serializers import (
|
22
|
+
serialize_operations,
|
23
|
+
serialize_inputs_outputs,
|
24
|
+
serialize_operation,
|
25
|
+
serialize_tensors,
|
26
|
+
serialize_buffer_pages,
|
27
|
+
serialize_operation_buffers,
|
28
|
+
serialize_operations_buffers,
|
29
|
+
serialize_devices,
|
30
|
+
)
|
31
|
+
|
32
|
+
|
33
|
+
class TestSerializers(unittest.TestCase):
|
34
|
+
|
35
|
+
def test_serialize_operations(self):
|
36
|
+
inputs = [InputTensor(1, 0, 1), InputTensor(2, 1, 2)]
|
37
|
+
operation_arguments = [
|
38
|
+
OperationArgument(1, "arg1", "value1"),
|
39
|
+
OperationArgument(1, "arg2", "value2"),
|
40
|
+
]
|
41
|
+
operations = [Operation(1, "op1", 0.5)]
|
42
|
+
outputs = [OutputTensor(1, 0, 1)]
|
43
|
+
stack_traces = [StackTrace(1, "trace1")]
|
44
|
+
tensors = [
|
45
|
+
Tensor(
|
46
|
+
1,
|
47
|
+
"shape1",
|
48
|
+
"dtype1",
|
49
|
+
"layout1",
|
50
|
+
"MemoryConfig(memory_layout=TensorMemoryLayout::INTERLEAVED,buffer_type=BufferType::DRAM,shard_spec=std::nullopt)",
|
51
|
+
1,
|
52
|
+
1000,
|
53
|
+
BufferType.DRAM,
|
54
|
+
[25],
|
55
|
+
),
|
56
|
+
Tensor(
|
57
|
+
2,
|
58
|
+
"shape2",
|
59
|
+
"dtype2",
|
60
|
+
"layout2",
|
61
|
+
"MemoryConfig(memory_layout=TensorMemoryLayout::INTERLEAVED,buffer_type=BufferType::DRAM,shard_spec=std::nullopt)",
|
62
|
+
2,
|
63
|
+
2000,
|
64
|
+
BufferType.L1,
|
65
|
+
[25],
|
66
|
+
),
|
67
|
+
]
|
68
|
+
devices = [
|
69
|
+
Device(1, 4, 4, 2, 2, 256, 4, 64, 0, 0, 1, 2, 512, 256, 128, 64, 1, 512)
|
70
|
+
]
|
71
|
+
producers_consumers = [ProducersConsumers(1, [2], [3])]
|
72
|
+
device_operations = [DeviceOperation(1, '[{"counter": 1, "op_id": 1}]')]
|
73
|
+
|
74
|
+
result = serialize_operations(
|
75
|
+
inputs,
|
76
|
+
operation_arguments,
|
77
|
+
operations,
|
78
|
+
outputs,
|
79
|
+
stack_traces,
|
80
|
+
tensors,
|
81
|
+
devices,
|
82
|
+
producers_consumers,
|
83
|
+
device_operations,
|
84
|
+
)
|
85
|
+
|
86
|
+
expected = [
|
87
|
+
{
|
88
|
+
"id": 1,
|
89
|
+
"name": "op1",
|
90
|
+
"duration": 0.5,
|
91
|
+
"stack_trace": "trace1",
|
92
|
+
"device_operations": [{"id": 1, "op_id": 1}],
|
93
|
+
"arguments": [
|
94
|
+
{"operation_id": 1, "name": "arg1", "value": "value1"},
|
95
|
+
{"operation_id": 1, "name": "arg2", "value": "value2"},
|
96
|
+
],
|
97
|
+
"inputs": [
|
98
|
+
{
|
99
|
+
"input_index": 0,
|
100
|
+
"id": 1,
|
101
|
+
"operation_id": 1,
|
102
|
+
"consumers": [3],
|
103
|
+
"producers": [2],
|
104
|
+
"shape": "shape1",
|
105
|
+
"dtype": "dtype1",
|
106
|
+
"layout": "layout1",
|
107
|
+
"memory_config": {
|
108
|
+
"memory_layout": "TensorMemoryLayout::INTERLEAVED",
|
109
|
+
"shard_spec": "std::nullopt",
|
110
|
+
},
|
111
|
+
"device_id": 1,
|
112
|
+
"address": 1000,
|
113
|
+
"buffer_type": 0,
|
114
|
+
"device_addresses": [25],
|
115
|
+
}
|
116
|
+
],
|
117
|
+
"outputs": [
|
118
|
+
{
|
119
|
+
"output_index": 0,
|
120
|
+
"id": 1,
|
121
|
+
"operation_id": 1,
|
122
|
+
"consumers": [3],
|
123
|
+
"producers": [2],
|
124
|
+
"shape": "shape1",
|
125
|
+
"dtype": "dtype1",
|
126
|
+
"layout": "layout1",
|
127
|
+
"memory_config": {
|
128
|
+
"memory_layout": "TensorMemoryLayout::INTERLEAVED",
|
129
|
+
"shard_spec": "std::nullopt",
|
130
|
+
},
|
131
|
+
"device_id": 1,
|
132
|
+
"address": 1000,
|
133
|
+
"buffer_type": 0,
|
134
|
+
"device_addresses": [25],
|
135
|
+
}
|
136
|
+
],
|
137
|
+
}
|
138
|
+
]
|
139
|
+
|
140
|
+
self.assertEqual(result, expected)
|
141
|
+
|
142
|
+
def test_serialize_operations_buffers(self):
|
143
|
+
operations = [
|
144
|
+
Operation(1, "op1", 0.5),
|
145
|
+
Operation(2, "op2", 1.0),
|
146
|
+
]
|
147
|
+
buffers = [
|
148
|
+
Buffer(1, 1, 1000, 256, BufferType.DRAM),
|
149
|
+
Buffer(1, 2, 2000, 512, BufferType.L1),
|
150
|
+
Buffer(2, 3, 3000, 1024, BufferType.L1),
|
151
|
+
]
|
152
|
+
|
153
|
+
result = serialize_operations_buffers(operations, buffers)
|
154
|
+
|
155
|
+
expected = [
|
156
|
+
{
|
157
|
+
"id": 1,
|
158
|
+
"name": "op1",
|
159
|
+
"buffers": [
|
160
|
+
{
|
161
|
+
"device_id": 1,
|
162
|
+
"address": 1000,
|
163
|
+
"buffer_type": 0,
|
164
|
+
"size": 256,
|
165
|
+
},
|
166
|
+
{
|
167
|
+
"device_id": 2,
|
168
|
+
"address": 2000,
|
169
|
+
"buffer_type": 1,
|
170
|
+
"size": 512,
|
171
|
+
},
|
172
|
+
],
|
173
|
+
},
|
174
|
+
{
|
175
|
+
"id": 2,
|
176
|
+
"name": "op2",
|
177
|
+
"buffers": [
|
178
|
+
{
|
179
|
+
"device_id": 3,
|
180
|
+
"address": 3000,
|
181
|
+
"buffer_type": 1,
|
182
|
+
"size": 1024,
|
183
|
+
},
|
184
|
+
],
|
185
|
+
},
|
186
|
+
]
|
187
|
+
|
188
|
+
self.assertEqual(repr(result), repr(expected))
|
189
|
+
|
190
|
+
def test_serialize_devices(self):
|
191
|
+
devices = [
|
192
|
+
Device(1, 4, 4, 2, 2, 256, 4, 64, 0, 0, 1, 2, 512, 256, 128, 64, 1, 512),
|
193
|
+
Device(
|
194
|
+
2, 8, 8, 4, 4, 512, 8, 128, 1, 1, 2, 4, 1024, 512, 256, 128, 2, 1024
|
195
|
+
),
|
196
|
+
]
|
197
|
+
|
198
|
+
result = serialize_devices(devices)
|
199
|
+
|
200
|
+
expected = [
|
201
|
+
{
|
202
|
+
"address_at_first_l1_bank": 0,
|
203
|
+
"address_at_first_l1_cb_buffer": 0,
|
204
|
+
"cb_limit": 512,
|
205
|
+
"device_id": 1,
|
206
|
+
"l1_bank_size": 64,
|
207
|
+
"l1_num_banks": 4,
|
208
|
+
"num_banks_per_storage_core": 1,
|
209
|
+
"num_compute_cores": 2,
|
210
|
+
"num_storage_cores": 512,
|
211
|
+
"num_x_compute_cores": 2,
|
212
|
+
"num_x_cores": 4,
|
213
|
+
"num_y_compute_cores": 2,
|
214
|
+
"num_y_cores": 4,
|
215
|
+
"total_l1_for_interleaved_buffers": 64,
|
216
|
+
"total_l1_for_sharded_buffers": 1,
|
217
|
+
"total_l1_for_tensors": 128,
|
218
|
+
"total_l1_memory": 256,
|
219
|
+
"worker_l1_size": 256,
|
220
|
+
},
|
221
|
+
{
|
222
|
+
"address_at_first_l1_bank": 1,
|
223
|
+
"address_at_first_l1_cb_buffer": 1,
|
224
|
+
"cb_limit": 1024,
|
225
|
+
"device_id": 2,
|
226
|
+
"l1_bank_size": 128,
|
227
|
+
"l1_num_banks": 8,
|
228
|
+
"num_banks_per_storage_core": 2,
|
229
|
+
"num_compute_cores": 4,
|
230
|
+
"num_storage_cores": 1024,
|
231
|
+
"num_x_compute_cores": 4,
|
232
|
+
"num_x_cores": 8,
|
233
|
+
"num_y_compute_cores": 4,
|
234
|
+
"num_y_cores": 8,
|
235
|
+
"total_l1_for_interleaved_buffers": 128,
|
236
|
+
"total_l1_for_sharded_buffers": 2,
|
237
|
+
"total_l1_for_tensors": 256,
|
238
|
+
"total_l1_memory": 512,
|
239
|
+
"worker_l1_size": 512,
|
240
|
+
},
|
241
|
+
]
|
242
|
+
|
243
|
+
# Assert that the serialized devices match the expected output
|
244
|
+
self.assertEqual(result, expected)
|
245
|
+
|
246
|
+
def test_serialize_operation_buffers(self):
|
247
|
+
operation = Operation(1, "op1", 0.5)
|
248
|
+
operation_buffers = [
|
249
|
+
Buffer(1, 1, 1000, 256, BufferType.DRAM),
|
250
|
+
Buffer(1, 2, 2000, 512, BufferType.L1),
|
251
|
+
]
|
252
|
+
|
253
|
+
result = serialize_operation_buffers(operation, operation_buffers)
|
254
|
+
|
255
|
+
expected = {
|
256
|
+
"id": 1,
|
257
|
+
"name": "op1",
|
258
|
+
"buffers": [
|
259
|
+
{
|
260
|
+
"device_id": 1,
|
261
|
+
"address": 1000,
|
262
|
+
"buffer_type": 0,
|
263
|
+
"size": 256,
|
264
|
+
},
|
265
|
+
{
|
266
|
+
"device_id": 2,
|
267
|
+
"address": 2000,
|
268
|
+
"buffer_type": 1,
|
269
|
+
"size": 512,
|
270
|
+
},
|
271
|
+
],
|
272
|
+
}
|
273
|
+
|
274
|
+
self.assertEqual(repr(result), repr(expected))
|
275
|
+
|
276
|
+
def test_serialize_inputs_outputs(self):
|
277
|
+
inputs = [InputTensor(1, 0, 1)]
|
278
|
+
outputs = [OutputTensor(1, 0, 1)]
|
279
|
+
producers_consumers = [ProducersConsumers(1, [2], [3])]
|
280
|
+
tensors_dict = {
|
281
|
+
1: Tensor(
|
282
|
+
1,
|
283
|
+
"shape1",
|
284
|
+
"dtype1",
|
285
|
+
"layout1",
|
286
|
+
"MemoryConfig(memory_layout=TensorMemoryLayout::INTERLEAVED,buffer_type=BufferType::DRAM,shard_spec=std::nullopt)",
|
287
|
+
1,
|
288
|
+
1000,
|
289
|
+
BufferType.DRAM,
|
290
|
+
[25],
|
291
|
+
)
|
292
|
+
}
|
293
|
+
|
294
|
+
inputs_dict, outputs_dict = serialize_inputs_outputs(
|
295
|
+
inputs, outputs, producers_consumers, tensors_dict
|
296
|
+
)
|
297
|
+
|
298
|
+
expected_inputs = {
|
299
|
+
1: [
|
300
|
+
{
|
301
|
+
"operation_id": 1,
|
302
|
+
"input_index": 0,
|
303
|
+
"id": 1,
|
304
|
+
"consumers": [3],
|
305
|
+
"producers": [2],
|
306
|
+
"shape": "shape1",
|
307
|
+
"dtype": "dtype1",
|
308
|
+
"layout": "layout1",
|
309
|
+
"memory_config": {
|
310
|
+
"memory_layout": "TensorMemoryLayout::INTERLEAVED",
|
311
|
+
"shard_spec": "std::nullopt",
|
312
|
+
},
|
313
|
+
"device_id": 1,
|
314
|
+
"address": 1000,
|
315
|
+
"buffer_type": 0,
|
316
|
+
"device_addresses": [25],
|
317
|
+
}
|
318
|
+
]
|
319
|
+
}
|
320
|
+
|
321
|
+
expected_outputs = {
|
322
|
+
1: [
|
323
|
+
{
|
324
|
+
"operation_id": 1,
|
325
|
+
"output_index": 0,
|
326
|
+
"id": 1,
|
327
|
+
"consumers": [3],
|
328
|
+
"producers": [2],
|
329
|
+
"shape": "shape1",
|
330
|
+
"dtype": "dtype1",
|
331
|
+
"layout": "layout1",
|
332
|
+
"memory_config": {
|
333
|
+
"memory_layout": "TensorMemoryLayout::INTERLEAVED",
|
334
|
+
"shard_spec": "std::nullopt",
|
335
|
+
},
|
336
|
+
"device_id": 1,
|
337
|
+
"address": 1000,
|
338
|
+
"buffer_type": 0,
|
339
|
+
"device_addresses": [25],
|
340
|
+
}
|
341
|
+
]
|
342
|
+
}
|
343
|
+
|
344
|
+
self.assertEqual(inputs_dict, expected_inputs)
|
345
|
+
self.assertEqual(outputs_dict, expected_outputs)
|
346
|
+
|
347
|
+
def test_serialize_operation(self):
|
348
|
+
buffers = [Buffer(1, 1, 1000, 256, BufferType.DRAM)]
|
349
|
+
inputs = [InputTensor(1, 0, 1)]
|
350
|
+
operation = Operation(1, "op1", 0.5)
|
351
|
+
operation_arguments = [OperationArgument(1, "arg1", "value1")]
|
352
|
+
outputs = [OutputTensor(1, 0, 1)]
|
353
|
+
stack_trace = StackTrace(1, "trace1")
|
354
|
+
tensors = [
|
355
|
+
Tensor(
|
356
|
+
1,
|
357
|
+
"shape1",
|
358
|
+
"dtype1",
|
359
|
+
"layout1",
|
360
|
+
"MemoryConfig(memory_layout=TensorMemoryLayout::INTERLEAVED,buffer_type=BufferType::DRAM,shard_spec=std::nullopt)",
|
361
|
+
1,
|
362
|
+
1000,
|
363
|
+
BufferType.DRAM,
|
364
|
+
[200, 300]
|
365
|
+
)
|
366
|
+
]
|
367
|
+
devices = [
|
368
|
+
Device(1, 4, 4, 2, 2, 256, 4, 64, 0, 0, 1, 2, 512, 256, 128, 64, 1, 512)
|
369
|
+
]
|
370
|
+
producers_consumers = [ProducersConsumers(1, [2], [3])]
|
371
|
+
device_operations = [DeviceOperation(1, '[{"counter": 1, "op_id": 1}]')]
|
372
|
+
|
373
|
+
result = serialize_operation(
|
374
|
+
buffers,
|
375
|
+
inputs,
|
376
|
+
operation,
|
377
|
+
operation_arguments,
|
378
|
+
outputs,
|
379
|
+
stack_trace,
|
380
|
+
tensors,
|
381
|
+
[],
|
382
|
+
[],
|
383
|
+
devices,
|
384
|
+
producers_consumers,
|
385
|
+
device_operations,
|
386
|
+
)
|
387
|
+
expected = {
|
388
|
+
"arguments": [{"name": "arg1", "operation_id": 1, "value": "value1"}],
|
389
|
+
"buffers": [
|
390
|
+
{
|
391
|
+
"address": 1000,
|
392
|
+
"buffer_type": 0,
|
393
|
+
"device_id": 1,
|
394
|
+
"max_size_per_bank": 256,
|
395
|
+
"operation_id": 1,
|
396
|
+
}
|
397
|
+
],
|
398
|
+
"device_operations": [{"id": 1, "op_id": 1}],
|
399
|
+
"duration": 0.5,
|
400
|
+
"id": 1,
|
401
|
+
"inputs": [
|
402
|
+
{
|
403
|
+
"address": 1000,
|
404
|
+
"buffer_type": 0,
|
405
|
+
"consumers": [3],
|
406
|
+
"device_id": 1,
|
407
|
+
"dtype": "dtype1",
|
408
|
+
"id": 1,
|
409
|
+
"input_index": 0,
|
410
|
+
"layout": "layout1",
|
411
|
+
"memory_config": {
|
412
|
+
"memory_layout": "TensorMemoryLayout::INTERLEAVED",
|
413
|
+
"shard_spec": "std::nullopt",
|
414
|
+
},
|
415
|
+
"operation_id": 1,
|
416
|
+
"producers": [2],
|
417
|
+
"shape": "shape1",
|
418
|
+
"device_addresses": [200, 300]
|
419
|
+
}
|
420
|
+
],
|
421
|
+
"l1_sizes": [256],
|
422
|
+
"name": "op1",
|
423
|
+
"outputs": [
|
424
|
+
{
|
425
|
+
"address": 1000,
|
426
|
+
"buffer_type": 0,
|
427
|
+
"consumers": [3],
|
428
|
+
"device_id": 1,
|
429
|
+
"dtype": "dtype1",
|
430
|
+
"id": 1,
|
431
|
+
"layout": "layout1",
|
432
|
+
"memory_config": {
|
433
|
+
"memory_layout": "TensorMemoryLayout::INTERLEAVED",
|
434
|
+
"shard_spec": "std::nullopt",
|
435
|
+
},
|
436
|
+
"operation_id": 1,
|
437
|
+
"output_index": 0,
|
438
|
+
"producers": [2],
|
439
|
+
"shape": "shape1",
|
440
|
+
"device_addresses": [200, 300],
|
441
|
+
}
|
442
|
+
],
|
443
|
+
"stack_trace": "trace1",
|
444
|
+
}
|
445
|
+
|
446
|
+
self.assertEqual(result, expected)
|
447
|
+
|
448
|
+
def test_serialize_buffer_pages(self):
|
449
|
+
buffer_pages = [
|
450
|
+
BufferPage(
|
451
|
+
operation_id=1,
|
452
|
+
device_id=1,
|
453
|
+
address=1234,
|
454
|
+
core_y=0,
|
455
|
+
core_x=0,
|
456
|
+
bank_id=1,
|
457
|
+
page_index=0,
|
458
|
+
page_address=1000,
|
459
|
+
page_size=4096,
|
460
|
+
buffer_type=BufferType.DRAM,
|
461
|
+
),
|
462
|
+
BufferPage(
|
463
|
+
operation_id=2,
|
464
|
+
device_id=2,
|
465
|
+
address=5678,
|
466
|
+
core_y=1,
|
467
|
+
core_x=1,
|
468
|
+
bank_id=2,
|
469
|
+
page_index=1,
|
470
|
+
page_address=2000,
|
471
|
+
page_size=8192,
|
472
|
+
buffer_type=BufferType.L1,
|
473
|
+
),
|
474
|
+
]
|
475
|
+
|
476
|
+
result = serialize_buffer_pages(buffer_pages)
|
477
|
+
|
478
|
+
expected = [
|
479
|
+
{
|
480
|
+
"operation_id": 1,
|
481
|
+
"device_id": 1,
|
482
|
+
"address": 1234,
|
483
|
+
"core_y": 0,
|
484
|
+
"core_x": 0,
|
485
|
+
"bank_id": 1,
|
486
|
+
"page_index": 0,
|
487
|
+
"page_address": 1000,
|
488
|
+
"page_size": 4096,
|
489
|
+
"buffer_type": 0,
|
490
|
+
"id": "1_0",
|
491
|
+
},
|
492
|
+
{
|
493
|
+
"operation_id": 2,
|
494
|
+
"device_id": 2,
|
495
|
+
"address": 5678,
|
496
|
+
"core_y": 1,
|
497
|
+
"core_x": 1,
|
498
|
+
"bank_id": 2,
|
499
|
+
"page_index": 1,
|
500
|
+
"page_address": 2000,
|
501
|
+
"page_size": 8192,
|
502
|
+
"buffer_type": 1,
|
503
|
+
"id": "2_1",
|
504
|
+
},
|
505
|
+
]
|
506
|
+
|
507
|
+
self.assertEqual(result, expected)
|
508
|
+
|
509
|
+
def test_serialize_tensors(self):
|
510
|
+
tensors = [
|
511
|
+
Tensor(
|
512
|
+
1,
|
513
|
+
"shape1",
|
514
|
+
"dtype1",
|
515
|
+
"layout1",
|
516
|
+
"MemoryConfig(memory_layout=TensorMemoryLayout::INTERLEAVED,buffer_type=BufferType::DRAM,shard_spec=std::nullopt)",
|
517
|
+
1,
|
518
|
+
1000,
|
519
|
+
BufferType.DRAM,
|
520
|
+
[500, 1500],
|
521
|
+
),
|
522
|
+
Tensor(
|
523
|
+
2,
|
524
|
+
"shape2",
|
525
|
+
"dtype2",
|
526
|
+
"layout2",
|
527
|
+
"MemoryConfig(memory_layout=TensorMemoryLayout::INTERLEAVED,buffer_type=BufferType::DRAM,shard_spec=std::nullopt)",
|
528
|
+
2,
|
529
|
+
2000,
|
530
|
+
BufferType.L1,
|
531
|
+
[2000, 2500],
|
532
|
+
),
|
533
|
+
]
|
534
|
+
producers_consumers = [
|
535
|
+
ProducersConsumers(1, [2], [3]),
|
536
|
+
ProducersConsumers(2, [], []),
|
537
|
+
]
|
538
|
+
|
539
|
+
result = serialize_tensors(tensors, producers_consumers, [], [])
|
540
|
+
|
541
|
+
expected = [
|
542
|
+
{
|
543
|
+
"id": 1,
|
544
|
+
"shape": "shape1",
|
545
|
+
"dtype": "dtype1",
|
546
|
+
"layout": "layout1",
|
547
|
+
"memory_config": {
|
548
|
+
"memory_layout": "TensorMemoryLayout::INTERLEAVED",
|
549
|
+
"shard_spec": "std::nullopt",
|
550
|
+
},
|
551
|
+
"device_id": 1,
|
552
|
+
"address": 1000,
|
553
|
+
"buffer_type": 0,
|
554
|
+
"comparison": None,
|
555
|
+
"consumers": [3],
|
556
|
+
"producers": [2],
|
557
|
+
"device_addresses": [500, 1500],
|
558
|
+
},
|
559
|
+
{
|
560
|
+
"id": 2,
|
561
|
+
"shape": "shape2",
|
562
|
+
"dtype": "dtype2",
|
563
|
+
"layout": "layout2",
|
564
|
+
"memory_config": {
|
565
|
+
"memory_layout": "TensorMemoryLayout::INTERLEAVED",
|
566
|
+
"shard_spec": "std::nullopt",
|
567
|
+
},
|
568
|
+
"device_id": 2,
|
569
|
+
"address": 2000,
|
570
|
+
"buffer_type": 1,
|
571
|
+
"comparison": None,
|
572
|
+
"consumers": [],
|
573
|
+
"producers": [],
|
574
|
+
"device_addresses": [2000, 2500],
|
575
|
+
},
|
576
|
+
]
|
577
|
+
|
578
|
+
self.assertEqual(result, expected)
|
579
|
+
|
580
|
+
|
581
|
+
if __name__ == "__main__":
|
582
|
+
unittest.main()
|