Revert "Add upgrader related logic to flatbuffer"

This reverts commit dfae96171a.
This commit is contained in:
Nikita Shulga 2022-04-17 11:38:59 -07:00
parent d79d9fa283
commit fe8eff3711
17 changed files with 24 additions and 493 deletions

View File

@ -274,8 +274,6 @@ exclude_patterns=[
'**/*.ipynb', '**/*.ipynb',
'**/*.ptl', '**/*.ptl',
'tools/clang_format_hash/**', 'tools/clang_format_hash/**',
'test/cpp/jit/upgrader_models/*.ptl',
'test/cpp/jit/upgrader_models/*.ptl.ff',
] ]
command = [ command = [
'python3', 'python3',
@ -291,8 +289,6 @@ exclude_patterns = [
'**/contrib/**', '**/contrib/**',
'**/*.diff', '**/*.diff',
'third_party/**', 'third_party/**',
'test/cpp/jit/upgrader_models/*.ptl',
'test/cpp/jit/upgrader_models/*.ptl.ff',
] ]
command = [ command = [
'python3', 'python3',
@ -318,8 +314,6 @@ exclude_patterns = [
'third_party/**', 'third_party/**',
'**/.gitattributes', '**/.gitattributes',
'**/.gitmodules', '**/.gitmodules',
'test/cpp/jit/upgrader_models/*.ptl',
'test/cpp/jit/upgrader_models/*.ptl.ff',
] ]
command = [ command = [
'python3', 'python3',

View File

@ -267,6 +267,23 @@ TEST(FlatbufferTest, Inline) {
AT_ASSERT(output.toTensor().item<float>() == 7.0); AT_ASSERT(output.toTensor().item<float>() == 7.0);
} }
#if defined ENABLE_FLATBUFFER
TEST(FlatbufferTest, GetByteCodeVersion) {
Module m("m");
m.define(R"(
def forward(self, input: Tensor):
return input + 1
)");
std::stringstream ss;
m._save_for_mobile(ss, {}, false, /*use_flatbuffer=*/true);
auto version = _get_model_bytecode_version(ss);
AT_ASSERT(version == caffe2::serialize::kProducedBytecodeVersion);
ss.seekg(0, ss.beg);
auto version_again = _get_model_bytecode_version(ss);
AT_ASSERT(version == version_again);
}
#endif
TEST(FlatbufferTest, Tuple) { TEST(FlatbufferTest, Tuple) {
Module m("m"); Module m("m");
m.define(R"JIT( m.define(R"JIT(
@ -1272,429 +1289,5 @@ TEST(TestSourceFlatbuffer,
} }
#endif #endif
#if !defined FB_XPLAT_BUILD
// The following test run in fbcode only
TEST(FlatbufferUpgraderTest, DivTensorV2) {
std::string filePath(__FILE__);
auto test_model_file = filePath.substr(0, filePath.find_last_of("/\\") + 1);
test_model_file.append("upgrader_models/test_versioned_div_tensor_v2.ptl.ff");
/*
(('__torch__.MyModule.forward',
(('instructions',
(('STOREN', 1, 3),
('DROPR', 1, 0),
('LOAD', 2, 0),
('LOAD', 3, 0),
('OP', 0, 0),
('LOAD', 2, 0),
('LOAD', 3, 0),
('OP', 1, 0),
('MOVE', 2, 0),
('MOVE', 3, 0),
('OP', 2, 0),
('TUPLE_CONSTRUCT', 3, 0),
('RET', 0, 0))),
('operators',
(('aten::div', 'Tensor'),
('aten::div', 'Tensor'),
('aten::div', 'Tensor'))),
('constants', ()),
('types', ()),
('register_size', 3))),)
*/
mobile::Module m_module = load_mobile_module_from_file(test_model_file);
auto intrsuction_list =
m_module.get_method("forward").function().get_code().instructions_;
uint64_t number_of_call_instruction = 0;
for (auto& instruction : intrsuction_list) {
number_of_call_instruction += (instruction.op == OpCode::CALL);
}
// 3 operators will use upgrader
ASSERT_EQ(number_of_call_instruction, 3);
std::vector<IValue> inputs = {
IValue(6 * torch::ones({1})), IValue(3 * torch::ones({1}))};
auto actual_output = m_module.forward(inputs);
auto expect_output = 2.0 * torch::ones({1});
auto actual_output_list = actual_output.toTuple()->elements();
ASSERT_TRUE(actual_output_list[0].toTensor().equal(expect_output));
}
TEST(FlatbufferUpgraderTest, DivTensorOutV2) {
std::string filePath(__FILE__);
auto test_model_file = filePath.substr(0, filePath.find_last_of("/\\") + 1);
test_model_file.append(
"upgrader_models/test_versioned_div_tensor_out_v2.ptl.ff");
/*
(('__torch__.MyModule.forward',
(('instructions',
(('STOREN', 1, 4),
('DROPR', 1, 0),
('MOVE', 2, 0),
('MOVE', 3, 0),
('MOVE', 4, 0),
('OP', 0, 0),
('RET', 0, 0))),
('operators', (('aten::div', 'out'),)),
('constants', ()),
('types', ()),
('register_size', 4))),)
*/
mobile::Module m_module = load_mobile_module_from_file(test_model_file);
auto intrsuction_list =
m_module.get_method("forward").function().get_code().instructions_;
uint64_t number_of_call_instruction = 0;
for (auto& instruction : intrsuction_list) {
number_of_call_instruction += (instruction.op == OpCode::CALL);
}
// One operator will use upgrader
ASSERT_EQ(number_of_call_instruction, 1);
std::vector<IValue> inputs{
IValue(6 * torch::ones({1})),
IValue(3 * torch::ones({1})),
IValue(torch::empty({1}))};
m_module.forward(inputs);
auto expect_output = 2.0 * torch::ones({1});
auto actual_output = inputs[2].toTensor();
// The out argument will be overwritten with the output
ASSERT_TRUE(actual_output.equal(expect_output));
}
TEST(FlatbufferUpgraderTest, DivTensorInplaceV2) {
std::string filePath(__FILE__);
auto test_model_file = filePath.substr(0, filePath.find_last_of("/\\") + 1);
test_model_file.append(
"upgrader_models/test_versioned_div_tensor_inplace_v2.ptl.ff");
/*
(('__torch__.MyModule.forward',
(('instructions',
(('STOREN', 1, 3),
('DROPR', 1, 0),
('MOVE', 2, 0),
('MOVE', 3, 0),
('OP', 0, 0),
('RET', 0, 0))),
('operators', (('aten::div_', 'Tensor'),)),
('constants', ()),
('types', ()),
('register_size', 3))),)
*/
mobile::Module m_module = load_mobile_module_from_file(test_model_file);
auto intrsuction_list =
m_module.get_method("forward").function().get_code().instructions_;
uint64_t number_of_call_instruction = 0;
for (auto& instruction : intrsuction_list) {
number_of_call_instruction += (instruction.op == OpCode::CALL);
}
// One operator will use upgrader
ASSERT_EQ(number_of_call_instruction, 1);
std::vector<IValue> inputs{
IValue(6 * torch::ones({1})), IValue(3 * torch::ones({1}))};
m_module.forward(inputs);
auto expect_output = 2.0 * torch::ones({1});
auto actual_output = inputs[0].toTensor();
// The out argument will be overwritten with the output
ASSERT_TRUE(actual_output.equal(expect_output));
}
TEST(FlatbufferUpgraderTest, DivScalarFloatV2) {
std::string filePath(__FILE__);
auto test_model_file = filePath.substr(0, filePath.find_last_of("/\\") + 1);
test_model_file.append(
"upgrader_models/test_versioned_div_scalar_float_v2.ptl.ff");
/*
(('__torch__.MyModuleFloat.forward',
(('instructions',
(('STOREN', 1, 3),
('DROPR', 1, 0),
('MOVE', 2, 0),
('MOVE', 3, 0),
('OP', 0, 0),
('RET', 0, 0))),
('operators', (('aten::div', 'Scalar'),)),
('constants', ()),
('types', ()),
('register_size', 3))),)
*/
mobile::Module m_module = load_mobile_module_from_file(test_model_file);
auto intrsuction_list =
m_module.get_method("forward").function().get_code().instructions_;
uint64_t number_of_call_instruction = 0;
for (auto& instruction : intrsuction_list) {
number_of_call_instruction += (instruction.op == OpCode::CALL);
}
// One operator will use upgrader
ASSERT_EQ(number_of_call_instruction, 1);
std::vector<IValue> inputs{IValue(6 * torch::ones({1})), IValue(3.0)};
auto output = m_module.forward(inputs);
auto expect_output = 2.0 * torch::ones({1});
auto actual_output = output.toTensor();
// The out argument will be overwritten with the output
ASSERT_TRUE(actual_output.equal(expect_output));
}
TEST(FlatbufferUpgraderTest, DivScalarReciprocalFloatV2) {
std::string filePath(__FILE__);
auto test_model_file = filePath.substr(0, filePath.find_last_of("/\\") + 1);
test_model_file.append(
"upgrader_models/test_versioned_div_scalar_reciprocal_float_v2.ptl.ff");
/*
(('__torch__.MyModuleFloat.forward',
(('instructions',
(('STOREN', 1, 3),
('DROPR', 1, 0),
('MOVE', 2, 0),
('OP', 0, 0),
('MOVE', 3, 0),
('OP', 1, 0),
('RET', 0, 0))),
('operators', (('aten::reciprocal', ''), ('aten::mul', 'Scalar'))),
('constants', ()),
('types', ()),
('register_size', 3))),)
*/
mobile::Module m_module = load_mobile_module_from_file(test_model_file);
auto intrsuction_list =
m_module.get_method("forward").function().get_code().instructions_;
uint64_t number_of_call_instruction = 0;
for (auto& instruction : intrsuction_list) {
number_of_call_instruction += (instruction.op == OpCode::CALL);
}
// No operator will use upgrader
ASSERT_EQ(number_of_call_instruction, 0);
std::vector<IValue> inputs{IValue(6 * torch::ones({1})), IValue(3.0)};
auto output = m_module.forward(inputs);
auto expect_output = 0.5 * torch::ones({1});
auto actual_output = output.toTensor();
// The out argument will be overwritten with the output
ASSERT_TRUE(actual_output.equal(expect_output));
}
TEST(FlatbufferUpgraderTest, DivScalarReciprocalIntV2) {
std::string filePath(__FILE__);
auto test_model_file = filePath.substr(0, filePath.find_last_of("/\\") + 1);
test_model_file.append(
"upgrader_models/test_versioned_div_scalar_reciprocal_int_v2.ptl.ff");
/*
(('__torch__.MyModuleInt.forward',
(('instructions',
(('STOREN', 1, 3),
('DROPR', 1, 0),
('MOVE', 2, 0),
('OP', 0, 0),
('MOVE', 3, 0),
('OP', 1, 0),
('RET', 0, 0))),
('operators', (('aten::reciprocal', ''), ('aten::mul', 'Scalar'))),
('constants', ()),
('types', ()),
('register_size', 3))),)
*/
mobile::Module m_module = load_mobile_module_from_file(test_model_file);
auto intrsuction_list =
m_module.get_method("forward").function().get_code().instructions_;
uint64_t number_of_call_instruction = 0;
for (auto& instruction : intrsuction_list) {
number_of_call_instruction += (instruction.op == OpCode::CALL);
}
// No operator will use upgrader
ASSERT_EQ(number_of_call_instruction, 0);
std::vector<IValue> inputs{IValue(6 * torch::ones({1})), IValue(3.0)};
auto output = m_module.forward(inputs);
auto expect_output = 0.5 * torch::ones({1});
auto actual_output = output.toTensor();
// The out argument will be overwritten with the output
ASSERT_TRUE(actual_output.equal(expect_output));
}
TEST(FlatbufferUpgraderTest, DivScalarScalarV2) {
std::string filePath(__FILE__);
auto test_model_file = filePath.substr(0, filePath.find_last_of("/\\") + 1);
test_model_file.append(
"upgrader_models/test_versioned_div_scalar_scalar_v2.ptl.ff");
/*
(('__torch__.MyModule.forward',
(('instructions',
(('STOREN', 1, 5),
('DROPR', 1, 0),
('LOAD', 2, 0),
('LOAD', 3, 0),
('OP', 0, 0),
('MOVE', 2, 0),
('LOAD', 4, 0),
('OP', 1, 0),
('LOAD', 3, 0),
('MOVE', 4, 0),
('OP', 2, 0),
('MOVE', 3, 0),
('MOVE', 5, 0),
('OP', 3, 0),
('TUPLE_CONSTRUCT', 4, 0),
('RET', 0, 0))),
('operators',
(('aten::div', ''),
('aten::div', 'float'),
('aten::div', ''),
('aten::div', 'int'))),
('constants', ()),
('types', ()),
('register_size', 5))),)
*/
mobile::Module m_module = load_mobile_module_from_file(test_model_file);
auto intrsuction_list =
m_module.get_method("forward").function().get_code().instructions_;
uint64_t number_of_call_instruction = 0;
for (auto& instruction : intrsuction_list) {
number_of_call_instruction += (instruction.op == OpCode::CALL);
}
// No operator will use upgrader
ASSERT_EQ(number_of_call_instruction, 0);
std::vector<IValue> inputs{IValue(20.0), IValue(10), IValue(2.0), IValue(5)};
auto output = m_module.forward(inputs);
auto output_list = output.toTupleRef().elements();
auto expect_output = std::vector<IValue>(
{IValue(2.0), IValue(10.0), IValue(5.0), IValue(2.0)});
// auto actual_output = output.toTensor();
for (size_t i = 0; i < expect_output.size(); i++) {
ASSERT_EQ(output_list[i], expect_output[i]);
}
}
TEST(FlatbufferUpgraderTest, DivScalarIntV2) {
std::string filePath(__FILE__);
auto test_model_file = filePath.substr(0, filePath.find_last_of("/\\") + 1);
test_model_file.append(
"upgrader_models/test_versioned_div_scalar_int_v2.ptl.ff");
/*
(('__torch__.MyModuleInt.forward',
(('instructions',
(('STOREN', 1, 3),
('DROPR', 1, 0),
('MOVE', 2, 0),
('MOVE', 3, 0),
('OP', 0, 0),
('RET', 0, 0))),
('operators', (('aten::div', 'Scalar'),)),
('constants', ()),
('types', ()),
('register_size', 3))),)
*/
mobile::Module m_module = load_mobile_module_from_file(test_model_file);
auto intrsuction_list =
m_module.get_method("forward").function().get_code().instructions_;
uint64_t number_of_call_instruction = 0;
for (auto& instruction : intrsuction_list) {
number_of_call_instruction += (instruction.op == OpCode::CALL);
}
// One operator will use upgrader
ASSERT_EQ(number_of_call_instruction, 1);
std::vector<IValue> inputs{IValue(6 * torch::ones({1})), IValue(3)};
auto output = m_module.forward(inputs);
auto expect_output = 2.0 * torch::ones({1});
auto actual_output = output.toTensor();
// The out argument will be overwritten with the output
ASSERT_TRUE(actual_output.equal(expect_output));
}
TEST(FlatbufferUpgraderTest, DivScalarInplaceFloatV2) {
std::string filePath(__FILE__);
auto test_model_file = filePath.substr(0, filePath.find_last_of("/\\") + 1);
test_model_file.append(
"upgrader_models/test_versioned_div_scalar_inplace_float_v2.ptl.ff");
/*
(('__torch__.MyModuleFloat.forward',
(('instructions',
(('STOREN', 1, 3),
('DROPR', 1, 0),
('MOVE', 2, 0),
('MOVE', 3, 0),
('OP', 0, 0),
('RET', 0, 0))),
('operators', (('aten::div_', 'Scalar'),)),
('constants', ()),
('types', ()),
('register_size', 3))),)
*/
mobile::Module m_module = load_mobile_module_from_file(test_model_file);
auto intrsuction_list =
m_module.get_method("forward").function().get_code().instructions_;
uint64_t number_of_call_instruction = 0;
for (auto& instruction : intrsuction_list) {
number_of_call_instruction += (instruction.op == OpCode::CALL);
}
// One operator will use upgrader
ASSERT_EQ(number_of_call_instruction, 1);
std::vector<IValue> inputs{IValue(6 * torch::ones({1})), IValue(3.0)};
auto output = m_module.forward(inputs);
auto expect_output = 2.0 * torch::ones({1});
auto actual_output = output.toTensor();
// The out argument will be overwritten with the output
ASSERT_TRUE(actual_output.equal(expect_output));
}
TEST(FlatbufferUpgraderTest, DivScalarInplaceIntV2) {
std::string filePath(__FILE__);
auto test_model_file = filePath.substr(0, filePath.find_last_of("/\\") + 1);
test_model_file.append(
"upgrader_models/test_versioned_div_scalar_inplace_int_v2.ptl.ff");
/*
(('__torch__.MyModuleInt.forward',
(('instructions',
(('STOREN', 1, 3),
('DROPR', 1, 0),
('MOVE', 2, 0),
('MOVE', 3, 0),
('OP', 0, 0),
('RET', 0, 0))),
('operators', (('aten::div_', 'Scalar'),)),
('constants', ()),
('types', ()),
('register_size', 3))),)
*/
mobile::Module m_module = load_mobile_module_from_file(test_model_file);
auto intrsuction_list =
m_module.get_method("forward").function().get_code().instructions_;
uint64_t number_of_call_instruction = 0;
for (auto& instruction : intrsuction_list) {
number_of_call_instruction += (instruction.op == OpCode::CALL);
}
// One operator will use upgrader
ASSERT_EQ(number_of_call_instruction, 1);
std::vector<IValue> inputs{IValue(6 * torch::ones({1})), IValue(3)};
auto output = m_module.forward(inputs);
auto expect_output = 2.0 * torch::ones({1});
auto actual_output = output.toTensor();
// The out argument will be overwritten with the output
ASSERT_TRUE(actual_output.equal(expect_output));
}
#endif // !defined(FB_XPLAT_BUILD)
} // namespace jit } // namespace jit
} // namespace torch } // namespace torch

View File

@ -248,7 +248,7 @@ class TestUpgraders(JitTestCase):
torch.jit.save(loaded_model, buffer) torch.jit.save(loaded_model, buffer)
buffer.seek(0) buffer.seek(0)
version = self._load_model_version(loaded_model) version = self._load_model_version(loaded_model)
self.assertEqual(version, 4) self.assertTrue(version == 4)
loaded_model_twice = torch.jit.load(buffer) loaded_model_twice = torch.jit.load(buffer)
self.assertEqual(loaded_model(torch.Tensor([5.0, 3.0]), 2.0), self.assertEqual(loaded_model(torch.Tensor([5.0, 3.0]), 2.0),

View File

@ -24,11 +24,6 @@
#include <flatbuffers/flatbuffers.h> #include <flatbuffers/flatbuffers.h>
#ifndef DISABLE_UPGRADER
#include <torch/csrc/jit/mobile/parse_bytecode.h>
#include <torch/csrc/jit/mobile/upgrader_mobile.h>
#endif
#if defined(HAVE_MMAP) #if defined(HAVE_MMAP)
#include <fcntl.h> #include <fcntl.h>
#include <sys/mman.h> #include <sys/mman.h>
@ -215,15 +210,6 @@ mobile::Module FlatbufferLoader::parseModule(
module_parsed_ = true; module_parsed_ = true;
return mobile::Module(module_ivalue.toObject(), mcu_); return mobile::Module(module_ivalue.toObject(), mcu_);
} }
namespace {
void appendUpgraderFunctions(mobile::Function* function) {
#ifndef DISABLE_UPGRADER
for (auto& byteCodeFunctionWithOperator : getUpgraderBytecodeList()) {
function->append_function(byteCodeFunctionWithOperator.function);
}
#endif
}
} // namespace
std::unique_ptr<mobile::Function> FlatbufferLoader::parseFunction( std::unique_ptr<mobile::Function> FlatbufferLoader::parseFunction(
const mobile::serialization::Function* method) { const mobile::serialization::Function* method) {
@ -241,13 +227,6 @@ std::unique_ptr<mobile::Function> FlatbufferLoader::parseFunction(
} }
std::unordered_set<std::string> unsupported_op_names; std::unordered_set<std::string> unsupported_op_names;
appendUpgraderFunctions(function.get());
// 2. Decides if upgrader is needed
const uint32_t operator_version = module_->operator_version();
bool use_upgrader =
(operator_version < caffe2::serialize::kProducedFileFormatVersion);
for (const auto* op : *method->operators()) { for (const auto* op : *method->operators()) {
c10::optional<int> num_args = c10::nullopt; c10::optional<int> num_args = c10::nullopt;
if (op->num_args_serialized() > -1) { if (op->num_args_serialized() > -1) {
@ -272,15 +251,6 @@ std::unique_ptr<mobile::Function> FlatbufferLoader::parseFunction(
function->append_type(getOrCreateTypeAnnotations(i)); function->append_type(getOrCreateTypeAnnotations(i));
} }
// 3. If upgrader is needed, change change the OP instrunction to CALL
// instruction (In next PR, use_upgrader will be parsed to parseInstruction
// function and do the actual change)
if (use_upgrader) {
#ifndef DISABLE_UPGRADER
applyUpgrader(function.get(), operator_version);
#endif
}
function->set_register_size(method->register_size()); function->set_register_size(method->register_size());
if (method->schema()) { if (method->schema()) {
try { try {

View File

@ -135,14 +135,6 @@ class TORCH_API Module {
mem_to_delete_ = delete_mem; mem_to_delete_ = delete_mem;
} }
void set_min_operator_version(int64_t version) {
min_operator_version_ = version;
}
int64_t min_operator_version() const {
return min_operator_version_;
}
void set_bytecode_version(int64_t version) { void set_bytecode_version(int64_t version) {
bytecode_version_ = version; bytecode_version_ = version;
} }
@ -157,8 +149,7 @@ class TORCH_API Module {
std::shared_ptr<CompilationUnit> cu_; std::shared_ptr<CompilationUnit> cu_;
MobileDebugTable debug_table_; MobileDebugTable debug_table_;
bool has_debug_handles_ = false; bool has_debug_handles_ = false;
int64_t min_operator_version_ = 4; int64_t bytecode_version_;
int64_t bytecode_version_ = 4;
// Extra handle for the module to delete when itself is deleted // Extra handle for the module to delete when itself is deleted
std::shared_ptr<char> mem_to_delete_; std::shared_ptr<char> mem_to_delete_;

View File

@ -2,7 +2,6 @@
#include <ATen/ATen.h> #include <ATen/ATen.h>
#include <c10/core/CPUAllocator.h> #include <c10/core/CPUAllocator.h>
#include <caffe2/serialize/versions.h>
#include <flatbuffers/flatbuffers.h> #include <flatbuffers/flatbuffers.h>
#include <torch/csrc/jit/mobile/code.h> #include <torch/csrc/jit/mobile/code.h>
#include <torch/csrc/jit/mobile/flatbuffer_loader.h> #include <torch/csrc/jit/mobile/flatbuffer_loader.h>
@ -29,10 +28,6 @@ using mobile::serialization::CreateTupleDirect;
namespace { namespace {
// TODO: remove once caffe2::kProducedBytecodeVersion is >= 9 and flatbuffer is
// launched.
constexpr uint32_t kMinVersion = 9;
// We will store IValue NONE in index 0 in flatbuffer. // We will store IValue NONE in index 0 in flatbuffer.
constexpr int kNoneIndex = 0; constexpr int kNoneIndex = 0;
@ -388,12 +383,9 @@ flatbuffers::DetachedBuffer FlatbufferSerializer::serializeModule(
for (const auto& ival : jit_constants) { for (const auto& ival : jit_constants) {
jit_constants_indexes.emplace_back(storeIValueAndGetIndex(fbb, ival)); jit_constants_indexes.emplace_back(storeIValueAndGetIndex(fbb, ival));
} }
const uint32_t operator_version =
static_cast<uint32_t>(module.min_operator_version()); const uint32_t bytecode_version =
uint32_t bytecode_version = static_cast<uint32_t>(module.bytecode_version()); static_cast<uint32_t>(module.bytecode_version());
if (bytecode_version < kMinVersion) {
bytecode_version = kMinVersion;
}
auto mod = CreateModule( auto mod = CreateModule(
fbb, fbb,
@ -406,8 +398,7 @@ flatbuffers::DetachedBuffer FlatbufferSerializer::serializeModule(
storage_data_offset, storage_data_offset,
fbb.CreateVector(obj_types_offset_), fbb.CreateVector(obj_types_offset_),
jit_source_offset, jit_source_offset,
fbb.CreateVector(jit_constants_indexes), fbb.CreateVector(jit_constants_indexes));
operator_version);
FinishModuleBuffer(fbb, mod); FinishModuleBuffer(fbb, mod);
return fbb.Release(); return fbb.Release();
} }

View File

@ -2521,18 +2521,10 @@ inline const torch::jit::mobile::serialization::Module *GetModule(const void *bu
return flatbuffers::GetRoot<torch::jit::mobile::serialization::Module>(buf); return flatbuffers::GetRoot<torch::jit::mobile::serialization::Module>(buf);
} }
inline const torch::jit::mobile::serialization::Module *GetSizePrefixedModule(const void *buf) { inline Module* GetMutableModule(void* buf) {
return flatbuffers::GetSizePrefixedRoot<torch::jit::mobile::serialization::Module>(buf);
}
inline Module *GetMutableModule(void *buf) {
return flatbuffers::GetMutableRoot<Module>(buf); return flatbuffers::GetMutableRoot<Module>(buf);
} }
inline torch::jit::mobile::serialization::Module *GetMutableSizePrefixedModule(void *buf) {
return flatbuffers::GetMutableSizePrefixedRoot<torch::jit::mobile::serialization::Module>(buf);
}
inline const char *ModuleIdentifier() { inline const char *ModuleIdentifier() {
return "PTMF"; return "PTMF";
} }