Files
pytorch/torch/csrc/jit/variable_flags.cpp
Peter Goldsborough 2d5fbe6e0d Improve Variable interface (#5127)
* 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
2018-02-12 23:26:26 -05:00

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;
}
}}