forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[functorch] disable C++ Function under functorch transforms (pytorch#…
…103957) Fixes pytorch#102720 Pull Request resolved: pytorch#103957 Approved by: https://github.com/zou3519
- Loading branch information
1 parent
ec24f1e
commit 47894bb
Showing
5 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <torch/extension.h> | ||
#include <torch/torch.h> | ||
|
||
using namespace torch::autograd; | ||
|
||
class Identity : public Function<Identity> { | ||
public: | ||
static torch::Tensor forward(AutogradContext* ctx, torch::Tensor input) { | ||
return input; | ||
} | ||
|
||
static tensor_list backward(AutogradContext* ctx, tensor_list grad_outputs) { | ||
return {grad_outputs[0]}; | ||
} | ||
}; | ||
|
||
torch::Tensor identity(torch::Tensor input) { | ||
return Identity::apply(input); | ||
} | ||
|
||
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { | ||
m.def("identity", &identity, "identity"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters