num_exprs_nosharing = 0
with shared_intermediates() as cache:
expr(x, y, z1, backend=backend)
num_exprs_nosharing += len(cache)
with shared_intermediates() as cache:
expr(x, y, z2, backend=backend)
num_exprs_nosharing += len(cache)
print("-" * 40)
print("With sharing:")
with shared_intermediates() as cache:
After Change
print("-" * 40)
print("Without sharing:")
num_exprs_nosharing = Counter()
with shared_intermediates() as cache:
expr(x, y, z1, backend=backend)
num_exprs_nosharing.update(count_cached_ops(cache))
with shared_intermediates() as cache: