#pragma once #include #include #include #include namespace torch::jit { // Try to match a list of inputs and keyword 'attributes' to this // schema. Return the flat list of positional inputs to the call or // `std::nullopt` on failure (`failure_messages` contains a good error // report in this case) struct MatchedSchema { std::vector inputs; std::vector return_types; c10::OptNameList return_field_names; std::string schema_name; }; TORCH_API bool isBlockListedSchema(const FunctionSchema& schema); TORCH_API MatchedSchema matchSchema( const ::c10::FunctionSchema& schema, const SourceRange& loc, Graph& graph, at::ArrayRef args, at::ArrayRef kwargs, const std::optional& self = std::nullopt); TORCH_API std::pair matchSchemas( const std::vector& schemas, const SourceRange& loc, Graph& graph, at::ArrayRef args, at::ArrayRef kwargs, const std::optional& self = std::nullopt, bool render_errors = false); TORCH_API bool convertibleToList( const TypePtr& type, const TypePtr& list_type_); TORCH_API std::string getFullSchemaName(const ::c10::FunctionSchema& schema); TORCH_API Value* emitBuiltinCall( const SourceRange& loc, Graph& graph, Symbol name, at::ArrayRef args, at::ArrayRef kwargs, const std::optional& self = std::nullopt); TORCH_API std::optional findInputWithName( const std::string& name, at::ArrayRef kwargs, bool is_aten = false); // applies implicit conversion from value trying to turn it into type // concrete_type it succeeds if the return_value->isSubtypeOf(concrete_type) TORCH_API Value* tryConvertToType( const SourceRange& loc, Graph& graph, const TypePtr& concrete_type, Value* value, bool allow_conversions); } // namespace torch::jit