/usr/local/lib64/python3.6/site-packages/torch/include/torch/csrc/api/include/torch
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/imethod.h (1536B)
#pragma once
#include
#include
namespace torch {
class TORCH_API IMethod {
/*
IMethod provides a portable interface for torch methods, whether
they are backed by torchscript or python/deploy.
This is helpful since torchscript methods provide additional information
(e.g. FunctionSchema, Graph) which aren't available in pure python methods.
Higher level APIs should prefer depending on this interface rather
than a specific implementation of it, to promote portability and reuse, and
avoid unintentional dependencies on e.g. script methods.
Note: This API is experimental, and may evolve.
*/
public:
using IValueList = std::vector;
using IValueMap = std::unordered_map;
virtual ~IMethod() = default;
virtual c10::IValue operator()(
std::vector args,
const IValueMap& kwargs = IValueMap()) const = 0;
virtual const std::string& name() const = 0;
// Returns an ordered list of argument names, possible in both
// script and python methods. This is a more portable dependency
// than a ScriptMethod FunctionSchema, which has more information
// than can be generally expected from a python method.
const std::vector& getArgumentNames() const;
protected:
virtual void setArgumentNames(std::vector& argumentNames) const = 0;
private:
mutable bool isArgumentNamesInitialized_ { false };
mutable std::vector argumentNames_;
};
} // namespace torch