mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 21:49:24 +08:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/67746 Test Plan: Visual inspection. Sandcastle. Reviewed By: zertosh Differential Revision: D31986646 fbshipit-source-id: 91885c20c3cead3853c49abb9fe0a94a67f33cc8
29 lines
827 B
C++
29 lines
827 B
C++
#include <torch/extension.h>
|
|
#include <torch/script.h>
|
|
|
|
using torch::List;
|
|
using torch::Tensor;
|
|
|
|
Tensor consume(Tensor a) {
|
|
return a;
|
|
}
|
|
|
|
List<Tensor> consume_list(List<Tensor> a) {
|
|
return a;
|
|
}
|
|
|
|
// When JIT tracing is used on function with constant for loop,
|
|
// the for loop is optimized away because of dead code elimination.
|
|
// That caused an issue for our op benchmark which needs to run an op
|
|
// in a loop and report the execution time. This diff resolves that issue by
|
|
// registering this consume op with correct alias information which is DEFAULT.
|
|
TORCH_LIBRARY_FRAGMENT(operator_benchmark, m) {
|
|
m.def("_consume", &consume);
|
|
m.def("_consume.list", &consume_list);
|
|
}
|
|
|
|
PYBIND11_MODULE(benchmark_cpp_extension, m) {
|
|
m.def("_consume", &consume, "consume");
|
|
m.def("_consume_list", &consume_list, "consume_list");
|
|
}
|