Suppress xformers impl_abstract FutureWarning at import
Browse files
model.py
CHANGED
|
@@ -1,4 +1,14 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
import torch
|
| 4 |
from torch import nn
|
|
|
|
| 1 |
+
import warnings
|
| 2 |
+
|
| 3 |
+
# xformers 0.0.27 still calls `torch.library.impl_abstract`, which torch
|
| 4 |
+
# deprecated in favor of `register_fake`. Suppress the FutureWarning before
|
| 5 |
+
# importing xformers so anyone doing `AutoModel.from_pretrained(...)` gets
|
| 6 |
+
# clean output. xformers 0.0.28+ fixed it; this filter is a no-op there.
|
| 7 |
+
warnings.filterwarnings(
|
| 8 |
+
"ignore",
|
| 9 |
+
message=r"`torch\.library\.impl_abstract` was renamed.*",
|
| 10 |
+
category=FutureWarning,
|
| 11 |
+
)
|
| 12 |
|
| 13 |
import torch
|
| 14 |
from torch import nn
|