Caffe2 - C++ API
A deep learning, cross platform ML framework
schema_matching.h
1 #pragma once
2 #include <torch/csrc/WindowsTorchApiMacro.h>
3 #include <torch/csrc/jit/ir.h>
4 #include <torch/csrc/jit/named_value.h>
5 
6 #include <ATen/core/function_schema.h>
7 
8 namespace torch {
9 namespace jit {
10 namespace script {
11 
12 // try to match a list if inputs and keyword 'attributes' to this schema,
13 // if it works return the flat list of positional inputs to the call
14 // if it returns nullopt, then failure_messages contains a good error report
15 // set convert_tensor_to_num to true if ImplicitTensorToNums should be inserted
16 // to match the schema
17 
18 struct MatchedSchema {
19  std::vector<Value*> inputs;
20  std::vector<TypePtr> return_types;
21  c10::OptNameList return_field_names;
22 };
23 
24 TORCH_API c10::optional<MatchedSchema> tryMatchSchema(
25  const ::c10::FunctionSchema& schema,
26  const SourceRange& loc,
27  Graph& graph,
30  at::ArrayRef<NamedValue> attributes,
31  std::ostream& failure_messages,
32  bool allow_conversions);
33 
34 TORCH_API Value* emitBuiltinCall(
35  const SourceRange& loc,
36  Graph& graph,
37  Symbol name,
38  const c10::optional<NamedValue>& self,
40  at::ArrayRef<NamedValue> attributes,
41  // if true, emitBuiltinCall will throw an exception if this builtin does not
42  // exist, otherwise it will return nullptr if the builtin is not found.
43  bool required);
44 
45 TORCH_API c10::optional<size_t> findInputWithName(
46  const std::string& name,
48 
49 // applies implict conversion from value trying to turn it into type
50 // concrete_type it succeeds if the return_value->isSubclassOf(concrete_type)
51 TORCH_API Value* tryConvertToType(
52  const SourceRange& loc,
53  Graph& graph,
54  const TypePtr& concrete_type,
55  Value* value,
56  bool allow_conversions);
57 
58 } // namespace script
59 } // namespace jit
60 } // namespace torch
Definition: jit_type.h:17
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:41