Caffe2 - C++ API
A deep learning, cross platform ML framework
basic_ops.h
1 #pragma once
2 
3 #include <torch/csrc/WindowsTorchApiMacro.h>
4 #include <torch/csrc/autograd/function.h>
5 #include <torch/csrc/autograd/variable.h>
6 #include <torch/csrc/autograd/symbolic.h>
7 
8 #include <memory>
9 #include <string>
10 #include <vector>
11 
12 namespace torch { namespace autograd {
13 
14 struct TORCH_API Error : public Function {
15  Error(std::string msg, edge_list&& next_edges)
16  : Function(std::move(next_edges))
17  , msg(std::move(msg)) {}
18 
19  Error(std::string msg)
20  : msg(std::move(msg)) {}
21 
22  variable_list apply(variable_list&& inputs) override;
23 
24  std::string msg;
25 };
26 
27 // We print grad_fn names in tensor printing. For functions with backward
28 // NYI, grad_fn=<Error> will be printed if we use Error, which is confusing. So
29 // special case with a new NotImplemented function here.
30 struct TORCH_API NotImplemented : public Error {
31  NotImplemented(const std::string& forward_fn, edge_list&& next_edges)
32  : Error("derivative for " + forward_fn + " is not implemented",
33  std::move(next_edges)) {}
34 
35  NotImplemented(const std::string& forward_fn)
36  : Error("derivative for " + forward_fn + " is not implemented") {}
37 };
38 
39 // Identity in forward, Error in backward. Used to implement @once_differentiable
40 struct TORCH_API DelayedError : public Function {
41  DelayedError(std::string msg, int num_inputs)
42  : msg(std::move(msg)) {
43  for (int i = 0; i < num_inputs; i++)
44  add_input_metadata(Function::undefined_input());
45  }
46 
47  variable_list apply(variable_list&& inputs) override;
48 
49  std::string msg;
50 };
51 
52 struct TORCH_API GraphRoot : public Function {
53  GraphRoot(edge_list functions, variable_list inputs)
54  : Function(std::move(functions)),
55  outputs(std::move(inputs)) {}
56 
57  variable_list apply(variable_list&& inputs) override {
58  return outputs;
59  }
60 
61  variable_list outputs;
62 };
63 
64 }}
The primary ATen error class.
Definition: Exception.h:27
Definition: jit_type.h:17