facebookresearch / facebookresearch/sam2

A small error that will cause onnx compilation at fp16 precision to fail

Open
#650 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
19.9k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

https://github.com/facebookresearch/sam2/blob/2b90b9f5ceec907a1c18123530e92e794ad901a4/sam2/modeling/position_encoding.py#L160

Here the gird is set to be at float32 precision. If we try to complie onnx in fp16 precision, this will report an error. We may modify it to:
```
device: Any = self.positional_encoding_gaussian_matrix.device
dtype: Any = self.positional_encoding_gaussian_matrix.dtype
grid = torch.ones((h, w), device=device, dtype=dtype)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.