in glide_text2im/clip/attention.py [0:0]
def _make_global_layout(self) -> None:
if not self.is_head_specific:
m = np.ones([self.n_query_block, self.n_key_block], dtype=np.bool)
r = product(*[range(n) for n in m.shape])
for qb, kb in r:
m[qb, kb] = np.any(self.block_layout(None, 0, qb, kb, 0))
else:
m = np.ones([self.n_head, self.n_query_block, self.n_key_block], dtype=np.bool)
r = product(*[range(n) for n in m.shape])
for h, qb, kb in r:
m[h, qb, kb] = np.any(self.block_layout(None, h, qb, kb, 0))
self.global_layout = m