mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/65964 ghstack-source-id: 141425519 Test Plan: buck run xplat/caffe2:test_lite_interpreter Reviewed By: cccclai Differential Revision: D31326149 fbshipit-source-id: 8a599d92f3fa4e6c125100adb36d89592e71e547
56 lines
1.7 KiB
C++
56 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <ATen/core/function_schema.h>
|
|
#include <ATen/core/ivalue.h>
|
|
#include <vector>
|
|
|
|
namespace torch {
|
|
namespace jit {
|
|
using Stack = std::vector<c10::IValue>;
|
|
enum OpCode : uint8_t;
|
|
|
|
namespace mobile {
|
|
struct Code;
|
|
|
|
class Function {
|
|
public:
|
|
TORCH_API Function(c10::QualifiedName name);
|
|
TORCH_API bool run(Stack& stack) const;
|
|
c10::IValue operator()(Stack& stack) const;
|
|
const std::string& name() const;
|
|
TORCH_API const c10::QualifiedName& qualname() const;
|
|
void append_instruction(OpCode op, int X, int N, int64_t dbg_handle);
|
|
void append_instruction(OpCode op, int X, int N);
|
|
bool append_operator(
|
|
const std::string& name,
|
|
const std::string& overload_name,
|
|
const c10::optional<int>& num_specified_args,
|
|
int64_t model_version); /* TODO: T90339189 deprecate all v3 when v3 models
|
|
are removed */
|
|
void append_constant(const c10::IValue& constant);
|
|
void append_type(const c10::TypePtr& type);
|
|
TORCH_API void append_function(mobile::Function& func);
|
|
|
|
void set_register_size(size_t size);
|
|
|
|
int64_t get_debug_handle(size_t pc) const;
|
|
const std::shared_ptr<Code> get_code() const;
|
|
|
|
void setSchema(c10::FunctionSchema schema);
|
|
const at::optional<c10::FunctionSchema>& getSchema() const;
|
|
|
|
// Returns the debug handle corresponding to where the execution
|
|
// is halted due to exception.
|
|
// If no corresponding debug handle is found then -1 is returned.
|
|
int64_t getExceptionDebugHandle() const;
|
|
|
|
private:
|
|
c10::QualifiedName name_;
|
|
std::shared_ptr<Code> code_;
|
|
at::optional<c10::FunctionSchema> schema_; // (byte-code version 4+)
|
|
};
|
|
|
|
} // namespace mobile
|
|
} // namespace jit
|
|
} // namespace torch
|