mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/27104 * The use case here is to replace prim::ListConstruct, which requires Node, but Node is not available in mobile lite interpreter. * (OPN, X, N), X is the index to the vararg operator-name and operator tables. N is number of inputs. For ListConstruct example, operator name can be "aten::listconstruct" and the overloaded name is the output type ("int", "float", "bool", "tensor" and "generic"). * A vararg operator table is built with void(int input_size, Stack& stack) functions. ## Unit test LiteInterpreterConv covers OPN instruction and conv operator. Test Plan: Imported from OSS Differential Revision: D17762853 fbshipit-source-id: 475aa0c6678e3760cec805862a78510913a89c83
37 lines
967 B
C++
37 lines
967 B
C++
#pragma once
|
|
#include <aten/src/ATen/core/ivalue.h>
|
|
//#include <aten/src/Aten/core/operator_name.h>
|
|
#include <vector>
|
|
|
|
namespace torch{
|
|
namespace jit{
|
|
using Stack = std::vector<c10::IValue>;
|
|
enum OpCode : uint8_t;
|
|
|
|
namespace mobile {
|
|
struct Code;
|
|
|
|
class Function{
|
|
public:
|
|
Function(c10::QualifiedName name);
|
|
bool run(Stack& stack) const;
|
|
const std::string& name() const;
|
|
const c10::QualifiedName& qualname() const;
|
|
void append_instruction(OpCode op, int X, int N);
|
|
void append_operator(const std::string& name,
|
|
const std::string& overload_name);
|
|
void append_vararg_operator(const std::string& name,
|
|
const std::string& overload_name);
|
|
void build_vararg_operator_table();
|
|
void append_constant(const c10::IValue& constant);
|
|
void set_register_size(size_t size);
|
|
|
|
private:
|
|
c10::QualifiedName name_;
|
|
std::shared_ptr<Code> code_;
|
|
};
|
|
|
|
} // namespace mobile
|
|
} // namespace torch
|
|
} // namespace jit
|