Caffe2 - C++ API
A deep learning, cross platform ML framework
basic_ops.cpp
1 #include <torch/csrc/autograd/functions/basic_ops.h>
2 
3 #include <torch/csrc/autograd/function.h>
4 #include <torch/csrc/autograd/variable.h>
5 #include <torch/csrc/autograd/functions/utils.h>
6 
7 #include <ATen/ATen.h>
8 
9 #include <memory>
10 #include <utility>
11 
12 namespace torch { namespace autograd {
13 
14 auto Error::apply(variable_list&& inputs) -> variable_list {
15  throw std::runtime_error(msg);
16 }
17 
18 auto DelayedError::apply(variable_list&& inputs) -> variable_list {
19  tensor_list outputs;
20  outputs.reserve(inputs.size());
21  for (auto& var : inputs) {
22  // FIXME: share version counters
23  outputs.emplace_back(var.defined() ? var.data() : at::Tensor());
24  }
25  return wrap_outputs(inputs, std::move(outputs), [&](edge_list&& next_edges) {
26  return std::make_shared<Error>(msg, std::move(next_edges));
27  });
28 }
29 
30 }} // namespace torch::autograd
Definition: jit_type.h:17