pytorch/scripts/gen_flatbuffer.sh
Han Qi d3649309e6 [pytorch][PR] Add ability for a mobile::Module to save as flatbuffer (#69306)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69306

Included functions:

save_mobile_module -> saves a mobile::Module to flatbuffer
load_mobile_module_from_file -> loads a flatbuffer into mobile::Module
parse_mobile_module -> parses from bytes or deserialized flatbuffer
Module object

Test Plan: unittests

Reviewed By: gmagogsfm

Differential Revision: D32806835

fbshipit-source-id: 71913c6650e225634f878946bd16960d377a7f57
2021-12-09 14:53:31 -08:00

27 lines
810 B
Bash
Executable File

#!/bin/bash
echo "Running gen_flatbuffers.sh OSTYPE is $OSTYPE"
ROOT=$(pwd)
FF_LOCATION="$ROOT/third_party/flatbuffers"
cd "$FF_LOCATION" || exit
mkdir build
cd build || exit
py() { command python "$@"; }
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Current arch is $CMAKE_OSX_ARCHITECTURES"
printenv
echo "====================="
cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64 ..
cmake --build . --target flatc
FLATC=./Debug/flatc
else
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --target flatc
FLATC=./flatc
fi
mkdir -p "$ROOT/build/torch/csrc/jit/serialization"
$FLATC --cpp --gen-mutable --scoped-enums \
-o "$ROOT/build/torch/csrc/jit/serialization" \
-c "$ROOT/torch/csrc/jit/serialization/mobile_bytecode.fbs"
cd "$ROOT" || exit
exit