File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 14
14
import torch
15
15
import numpy as np
16
16
import pyflexfloat as ff
17
+ import humanize
18
+
19
+ # Maximum available size in TCDM (in bytes)
20
+ TCDM_HEAP_SIZE = 112 * 1024
17
21
18
22
19
23
def emit_license ():
@@ -295,3 +299,20 @@ def main(self):
295
299
# Emit header file
296
300
with open (args .output , 'w' ) as f :
297
301
f .write (self .emit_header (** param ))
302
+
303
+
304
+ def validate_tcdm_footprint (size , silent = False ):
305
+ """Check whether data of specified size fits in TCDM.
306
+
307
+ Throws an assertion error if the specified size exceeds the space
308
+ available for the heap in TCDM.
309
+
310
+ Args:
311
+ size: The size of the data in bytes.
312
+ silent: If True, will not print the size to stdout.
313
+ """
314
+ assert size < TCDM_HEAP_SIZE , \
315
+ f'Total heap space required { humanize .naturalsize (size , binary = True )} exceeds ' \
316
+ f'limit of { humanize .naturalsize (L1_HEAP_SIZE , binary = True )} '
317
+ if not silent :
318
+ print (f'Total heap space required { humanize .naturalsize (size , binary = True )} ' )
You can’t perform that action at this time.
0 commit comments