MCPcopy Create free account
hub / github.com/OpenMeshLab/MeshXL / discretize

Function discretize

models/mesh_xl/tokenizer.py:8–19  ·  view source on GitHub ↗
(
    t: Tensor,
    continuous_range: Tuple[float, float],
    num_discrete: int = 128
)

Source from the content-addressed store, hash-verified

6
7
8def discretize(
9 t: Tensor,
10 continuous_range: Tuple[float, float],
11 num_discrete: int = 128
12) -> Tensor:
13
14 lo, hi = continuous_range
15 assert hi > lo
16 t = (t - lo) / (hi - lo) # cube normalize
17 t *= num_discrete
18 t -= 0.5
19 return t.round().long().clamp(min = 0, max = num_discrete - 1)
20
21
22

Callers 1

tokenizeMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected