mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Summary:
This PR moves tracing logic out of the generated VariableType kernels, to associate it with a new dedicated dispatch key Tracer.
It also toggles the dispatch key set at various places to keep the semantics unchanged - see the inline [Tracing Mode Switches] note.
Sample generated code:
```
Tensor & __ilshift___Tensor(Tensor & self, const Tensor & other) {
#if !defined(PYTORCH_DISABLE_TRACING)
torch::jit::Node* node = nullptr;
std::shared_ptr<jit::tracer::TracingState> tracer_state;
if (jit::tracer::isTracing()) {
tracer_state = jit::tracer::getTracingState();
at::Symbol op_name;
op_name = jit::Symbol::fromQualString("aten::__ilshift__");
node = tracer_state->graph->create(op_name, /*num_outputs=*/0);
jit::tracer::recordSourceLocation(node);
jit::tracer::addInputs(node, "self", self);
jit::tracer::addInputs(node, "other", other);
tracer_state->graph->insertNode(node);
jit::tracer::setTracingState(nullptr);
}
#endif
static auto op = c10::Dispatcher::singleton().findSchemaOrThrow("aten::__ilshift__", "Tensor");
c10::Dispatcher::singleton().redispatch<Tensor &, Tensor &, const Tensor &>(op, c10::DispatchKey::Tracer, self, other);
#if !defined(PYTORCH_DISABLE_TRACING)
if (tracer_state) {
jit::tracer::setTracingState(std::move(tracer_state));
jit::tracer::addOutput(node, self);
}
#endif
return self;
}
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/38467
ghstack-source-id: 105215150
Test Plan: CI
Differential Revision: D21570684
fbshipit-source-id: 1a96761830307f9a934f38bfb9fe8b5b1763e0e0
|
||
|---|---|---|
| .. | ||
| contrib | ||
| core | ||
| cuda_rtc | ||
| db | ||
| distributed | ||
| experiments | ||
| ideep | ||
| image | ||
| mobile | ||
| mpi | ||
| observers | ||
| onnx | ||
| operators | ||
| opt | ||
| perfkernels | ||
| predictor | ||
| proto | ||
| python | ||
| quantization | ||
| queue | ||
| serialize | ||
| sgd | ||
| share | ||
| test | ||
| transforms | ||
| utils | ||
| video | ||
| .clang-format | ||
| __init__.py | ||
| c2_aten_srcs.bzl | ||
| CMakeLists.txt | ||
| README.md | ||
| release-notes.md | ||
| requirements.txt | ||
| VERSION_NUMBER | ||
Caffe2
Caffe2 is a lightweight, modular, and scalable deep learning framework. Building on the original Caffe, Caffe2 is designed with expression, speed, and modularity in mind.
Questions and Feedback
Please use Github issues (https://github.com/pytorch/pytorch/issues) to ask questions, report bugs, and request new features.