@@ -439,6 +439,27 @@ def __init__(self, f, b, clusters):
439439
440440 self .indices = extract_indices (f , self .dim , clusters )
441441
442+ def __repr__ (self ):
443+ return "Descriptor[%s -> %s]" % (self .f , self .b )
444+
445+ @property
446+ def size (self ):
447+ return self .xd .symbolic_size
448+
449+ @property
450+ def exprs (self ):
451+ return flatten (c .exprs for c in self .clusters )
452+
453+ @property
454+ def itdims (self ):
455+ """
456+ The Dimensions defining an IterationSpace in which the buffer
457+ may be accessed.
458+ """
459+ return (self .xd , self .dim .root )
460+
461+ @cached_property
462+ def ispace (self ):
442463 # The IterationSpace within which the buffer will be accessed
443464 # NOTE: The `key` is to avoid Clusters including `f` but not directly
444465 # using it in an expression, such as HaloTouch Clusters
@@ -448,20 +469,22 @@ def key(c):
448469 return bufferdim or timeonly
449470
450471 ispaces = set ()
451- for c in clusters :
472+ for c in self . clusters :
452473 if not key (c ):
453474 continue
454475
455476 # Skip wild clusters (e.g. HaloTouch Clusters)
456477 if c .is_wild :
457478 continue
479+
458480 # Iterations space and buffering dims
459481 ispace = c .ispace
460482 edims = [d for d in self .bdims if d not in ispace .dimensions ]
461483 if not edims :
462484 ispaces .add (ispace )
463485 else :
464- # Add all missing buffering dimensions
486+ # Add all missing buffering dimensions and reorder to
487+ # avoid duplicates with different ordering
465488 ispaces .add (ispace .insert (self .dim , edims ).reorder ())
466489
467490 if len (ispaces ) > 1 :
@@ -471,31 +494,10 @@ def key(c):
471494 ispaces = {i .lift (self .bdims , v = stamp ) for i in ispaces }
472495
473496 if len (ispaces ) > 1 :
474- print (ispaces )
475497 raise CompilationError ("Unsupported `buffering` over different "
476498 "IterationSpaces" )
477499
478- assert len (ispaces ) == 1 , "Unexpected form of `buffering`"
479- self .ispace = ispaces .pop ()
480-
481- def __repr__ (self ):
482- return "Descriptor[%s -> %s]" % (self .f , self .b )
483-
484- @property
485- def size (self ):
486- return self .xd .symbolic_size
487-
488- @property
489- def exprs (self ):
490- return flatten (c .exprs for c in self .clusters )
491-
492- @property
493- def itdims (self ):
494- """
495- The Dimensions defining an IterationSpace in which the buffer
496- may be accessed.
497- """
498- return (self .xd , self .dim .root )
500+ return ispaces .pop ()
499501
500502 @cached_property
501503 def subdims_mapper (self ):
0 commit comments