MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / floats_tensor

Function floats_tensor

src/diffusers/utils/testing_utils.py:165–178  ·  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

163
164
165def floats_tensor(shape, scale=1.0, rng=None, name=None):
166 """Creates a random float32 tensor"""
167 if rng is None:
168 rng = global_rng
169
170 total_dims = 1
171 for dim in shape:
172 total_dims *= dim
173
174 values = []
175 for _ in range(total_dims):
176 values.append(rng.random() * scale)
177
178 return torch.tensor(data=values, dtype=torch.float).view(shape).contiguous()
179
180
181def slow(test_case):

Callers 15

get_dummy_inputsMethod · 0.90
dummy_imageMethod · 0.90
get_dummy_inputsMethod · 0.90
get_dummy_inputsMethod · 0.90
get_dummy_inputsMethod · 0.90
get_dummy_inputsMethod · 0.90
get_dummy_inputsMethod · 0.90
dummy_imageMethod · 0.90
dummy_imageMethod · 0.90
get_dummy_inputsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected