3 #include <ATen/core/jit_type.h> 4 #include <ATen/core/interned_strings.h> 5 #include <ATen/core/ivalue.h> 6 #include <ATen/core/alias_info.h> 16 std::string name =
"",
17 TypePtr type =
nullptr,
20 bool kwarg_only =
false,
22 : name_(std::move(name)),
23 type_(type ? type : TensorType::get()),
25 default_value_(std::move(default_value)),
26 kwarg_only_(kwarg_only),
27 alias_info_(std::move(alias_info)) {
28 if (default_value_ && default_value_->isTensor()) {
29 auto t = default_value_->toTensor();
33 const std::string& name()
const {
36 TypePtr type()
const {
43 return default_value_;
45 bool kwarg_only()
const {
70 std::string overload_name,
71 std::vector<Argument> arguments,
72 std::vector<Argument> returns,
73 bool is_vararg =
false,
74 bool is_varret =
false)
75 : name_(std::move(name)),
76 overload_name_(std::move(overload_name)),
77 arguments_(std::move(arguments)),
78 returns_(std::move(returns)),
79 is_vararg_(is_vararg),
80 is_varret_(is_varret) {}
84 std::string overload_name,
85 std::vector<Argument> arguments,
86 std::vector<Argument> returns,
87 bool is_vararg =
false,
88 bool is_varret =
false,
89 std::vector<std::string> writes = {})
92 std::move(overload_name),
93 std::move(std::move(arguments)),
94 std::move(std::move(returns)),
99 const std::string name_;
100 const std::string overload_name_;
101 const std::vector<Argument> arguments_;
102 const std::vector<Argument> returns_;
107 const bool is_vararg_;
108 const bool is_varret_;
111 const std::string& name()
const {
114 const std::string& overload_name()
const {
115 return overload_name_;
117 const std::vector<Argument>& arguments()
const {
120 const std::vector<Argument>& returns()
const {
123 bool is_vararg()
const {
126 bool is_varret()
const {
129 bool is_mutable()
const {
131 arguments_.cbegin(), arguments_.cend(), [](
const Argument& arg) {
132 const auto& aliasInfo = arg.alias_info();
133 return aliasInfo && aliasInfo.value().isWrite();
137 for(
size_t i = 0; i < arguments().size(); ++i) {
138 if(name == arguments()[i].name())
146 inline std::ostream& operator<<(std::ostream& out,
const Argument& arg) {
147 return out << arg.type()->str() <<
" " << arg.name() << (arg.default_value() ?
"=<default>" :
"");
150 inline std::ostream& operator<<(std::ostream& out,
const FunctionSchema& schema) {
154 out << schema.name();
157 bool seen_kwarg_only =
false;
158 for(
size_t i = 0; i < schema.arguments().size(); ++i) {
159 if (i > 0) out <<
", ";
160 if (schema.arguments()[i].kwarg_only() && !seen_kwarg_only) {
162 seen_kwarg_only =
true;
164 out << schema.arguments()[i];
167 if(schema.is_vararg()) {
168 if(schema.arguments().size() > 0)
174 if (schema.returns().size() == 1) {
175 out << schema.returns().at(0).type()->str();
176 }
else if (schema.returns().size() > 1) {
178 for (
size_t i = 0; i < schema.returns().size(); ++i) {
179 if (i > 0) out <<
", ";
180 out << schema.returns()[i].type()->str();
bool is_variable() const noexcept
Returns true if the Tensor is actually a torch::autograd::Variable.
To register your own kernel for an operator, do in one (!) cpp file: C10_REGISTER_KERNEL(OperatorHand...