mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
* Improve Variable interface * Address comments from @apaszke and @colesbury * string ::operator= is not noexcept * Remove ir.h from tracer_state.h to improve build times * Make Variable a struct and pack SavedVariable fields * Implement as_variable_ref * grad_fn_ptr() -> grad_fn_unsafe() * Reduce hackiness of set_type hack * Include variable.h and edge.h in tracer_state.h because it uses them * class Variable -> struct Variable because Windows cant even * Make Variable::output_nr uint32_t instead of int * Add comment about tracing state * Replaced more static_cast<Variable&> and improve docs * Remove SavedVariable destructor and construct members in init list * Clarify docs for Variable * Variable::set_version -> set_version_counter
20 lines
470 B
C++
20 lines
470 B
C++
#include "torch/csrc/jit/variable_flags.h"
|
|
|
|
#include "torch/csrc/autograd/variable.h"
|
|
#include "torch/csrc/jit/tracer_state.h"
|
|
|
|
using torch::autograd::Variable;
|
|
|
|
namespace torch { namespace jit {
|
|
|
|
// These definitions require Variable struct to be defined, so they can't be
|
|
// in tracer_state.h
|
|
VariableFlags VariableFlags::of(const Variable& var) {
|
|
VariableFlags f;
|
|
f.defined = var.defined();
|
|
f.requires_grad = f.defined && var.requires_grad();
|
|
return f;
|
|
}
|
|
|
|
}}
|