forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 1
/
autograd_not_implemented_fallback.h
32 lines (24 loc) · 1.12 KB
/
autograd_not_implemented_fallback.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include <torch/library.h>
namespace torch::autograd {
// Default DispatchKey::Autograd fallback for built-in operators.
// Can be registered for custom operators.
TORCH_API torch::CppFunction autogradNotImplementedFallback();
// Default DispatchKey::AdInplaceOrView fallback for built-in operators
// Can be registered for custom operators.
TORCH_API torch::CppFunction autogradNotImplementedInplaceOrViewFallback();
// Default DispatchKey::Autograd fallback for all other operators (i.e. custom
// operators)
TORCH_API torch::CppFunction basicAutogradNotImplementedFallback();
enum class AutogradFallbackMode {
Nothing, // Fallback is a redispatch
Warn, // Fallback raises a warning if backward is called
Error, // Fallback raises an error if backward is called
};
// Change the behavior of "basicAutogradNotImplementedFallback"
// In Python this is:
// - torch._C._set_autograd_fallback_mode(str) -> None
// - torch._C._get_autograd_fallback_mode() -> str
TORCH_API void setAutogradFallbackMode(AutogradFallbackMode mode);
TORCH_API AutogradFallbackMode getAutogradFallbackMode();
} // namespace torch::autograd