MCPcopy Create free account
hub / github.com/openai/shap-e / encode_position

Function encode_position

shap_e/models/nn/encoding.py:9–17  ·  view source on GitHub ↗
(version: str, *, position: torch.Tensor)

Source from the content-addressed store, hash-verified

7
8
9def encode_position(version: str, *, position: torch.Tensor):
10 if version == "v1":
11 freqs = get_scales(0, 10, position.dtype, position.device).view(1, -1)
12 freqs = position.reshape(-1, 1) * freqs
13 return torch.cat([freqs.cos(), freqs.sin()], dim=1).reshape(*position.shape[:-1], -1)
14 elif version == "nerf":
15 return posenc_nerf(position, min_deg=0, max_deg=15)
16 else:
17 raise ValueError(version)
18
19
20def encode_channels(version: str, *, channels: torch.Tensor):

Callers 8

__init__Method · 0.90
_run_mlpMethod · 0.90
__init__Method · 0.90
encode_positionMethod · 0.90
forwardMethod · 0.85
forwardMethod · 0.85
forwardMethod · 0.85

Calls 2

get_scalesFunction · 0.85
posenc_nerfFunction · 0.85

Tested by

no test coverage detected