Use flatbuffer of alternate namespace (#82952)

Summary: Minimal change to make use of flatbuffer with fbsource namespace.

Test Plan: existing unit tests

Differential Revision: D38494999

Pull Request resolved: https://github.com/pytorch/pytorch/pull/82952
Approved by: https://github.com/cccclai
This commit is contained in:
Han Qi (qihqi) 2022-08-09 07:40:59 +00:00 committed by PyTorch MergeBot
parent b4b60c2a2e
commit f9533560cc
4 changed files with 17 additions and 6 deletions

View file

@ -125,8 +125,8 @@ THIRD_PARTY_LIBS = {
"XNNPACK": ["//xplat/third-party/XNNPACK:XNNPACK", "//third_party:XNNPACK"],
"clog": ["//xplat/third-party/clog:clog", "//third_party:clog"],
"cpuinfo": ["//third-party/cpuinfo:cpuinfo", "//third_party:cpuinfo"],
"flatbuffers-api": ["//third-party/flatbuffers:flatbuffers-api", "//third_party:flatbuffers-api"],
"flatc": ["//third-party/flatbuffers:flatc", "//third_party:flatc"],
"flatbuffers-api": ["//third-party/flatbuffers/fbsource_namespace:flatbuffers-api", "//third_party:flatbuffers-api"],
"flatc": ["//third-party/flatbuffers/fbsource_namespace:flatc", "//third_party:flatc"],
"fmt": ["//third-party/fmt:fmt", "//third_party:fmt"],
"glog": ["//third-party/glog:glog", "//third_party:glog"],
"gmock": ["//xplat/third-party/gmock:gtest", "//third_party:gmock"],
@ -1497,8 +1497,6 @@ def define_buck_targets(
# "torch/csrc/jit/mobile/compatibility/runtime_compatibility.cpp",
# "torch/csrc/jit/serialization/unpickler.cpp",
"torch/csrc/jit/mobile/compatibility/model_compatibility.cpp",
"torch/csrc/jit/serialization/pickle.cpp",
"torch/csrc/jit/serialization/pickler.cpp",
],
header_namespace = "",
exported_headers = [
@ -1714,7 +1712,7 @@ def define_buck_targets(
"-fexceptions",
"-frtti",
"-Wno-deprecated-declarations",
],
] + (["-DFB_XPLAT_BUILD"] if not IS_OSS else []),
visibility = ["PUBLIC"],
deps = [
":torch_mobile_module",
@ -1743,7 +1741,7 @@ def define_buck_targets(
# Need this otherwise USE_KINETO is undefed
# for mobile
"-DEDGE_PROFILER_USE_KINETO",
],
] + (["-DFB_XPLAT_BUILD"] if not IS_OSS else []),
extra_flags = {
"fbandroid_compiler_flags": ["-frtti"],
},

View file

@ -1800,6 +1800,9 @@ TEST(FlatbufferUpgraderTest, DivScalarInplaceIntV2) {
namespace torch {
namespace jit {
#if defined(FBCODE_CAFFE2) or defined(FB_XPLAT_BUILD)
namespace flatbuffers = flatbuffers_fbsource;
#endif
/**
* An Allocator that can only deallocate (using delete []), counting
* the number of times that it has been asked to deallocate.

View file

@ -50,6 +50,11 @@
#include <cstdlib>
#endif
#if defined(FBCODE_CAFFE2) or defined(FB_XPLAT_BUILD)
namespace flatbuffers = flatbuffers_fbsource;
#define FLATBUFFERS_MAX_ALIGNMENT FLATBUFFERS_FBSOURCE_MAX_ALIGNMENT
#endif
namespace torch {
namespace jit {

View file

@ -23,6 +23,11 @@
#include <torch/csrc/jit/serialization/export.h>
#include <torch/csrc/jit/serialization/mobile_bytecode_generated.h> // NOLINT
#if defined(FBCODE_CAFFE2) or defined(FB_XPLAT_BUILD)
namespace flatbuffers = flatbuffers_fbsource;
#define FLATBUFFERS_MAX_ALIGNMENT FLATBUFFERS_FBSOURCE_MAX_ALIGNMENT
#endif
namespace torch {
namespace jit {