MCPcopy Create free account
hub / github.com/AlayaLab/Hive / floats_tensor

Function floats_tensor

models/flowsep/diffusers/utils/testing_utils.py:128–141  ·  view source on GitHub ↗

Creates a random float32 tensor

(shape, scale=1.0, rng=None, name=None)

Source from the content-addressed store, hash-verified

126
127
128def floats_tensor(shape, scale=1.0, rng=None, name=None):
129 """Creates a random float32 tensor"""
130 if rng is None:
131 rng = global_rng
132
133 total_dims = 1
134 for dim in shape:
135 total_dims *= dim
136
137 values = []
138 for _ in range(total_dims):
139 values.append(rng.random() * scale)
140
141 return torch.tensor(data=values, dtype=torch.float).view(shape).contiguous()
142
143
144def slow(test_case):

Callers

nothing calls this directly

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected