mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
As the title stated. `torch.library.impl_abstract` have beed deprecated in PyTorch2.4, so change to use the new API. Pull Request resolved: https://github.com/pytorch/pytorch/pull/158839 Approved by: https://github.com/jingsh, https://github.com/zou3519 ghstack dependencies: #158838
20 lines
462 B
Python
20 lines
462 B
Python
from model import get_custom_op_library_path
|
|
|
|
import torch
|
|
|
|
|
|
torch.ops.load_library(get_custom_op_library_path())
|
|
|
|
|
|
# NB: The impl_abstract_pystub for cos actually
|
|
# specifies it should live in the my_custom_ops2 module.
|
|
@torch.library.register_fake("custom::cos")
|
|
def cos_abstract(x):
|
|
return torch.empty_like(x)
|
|
|
|
|
|
# NB: There is no impl_abstract_pystub for tan
|
|
@torch.library.register_fake("custom::tan")
|
|
def tan_abstract(x):
|
|
return torch.empty_like(x)
|