未验证 提交 784f75fa 编写于 作者: 石晓伟 提交者: GitHub

[cherry-pick] not build naive_buffer when build light framework, test=develop (#4315)

* [cherry-pick] not build naive_buffer when build light framework, test=develop (#4251)

* fix opt fatal errors, test=develop (#4293)

* fix cmake dependencies, test=develop
上级 bd4fd8d3
...@@ -199,13 +199,10 @@ if (LITE_WITH_EXCEPTION) ...@@ -199,13 +199,10 @@ if (LITE_WITH_EXCEPTION)
add_definitions("-DLITE_WITH_EXCEPTION") add_definitions("-DLITE_WITH_EXCEPTION")
endif() endif()
if (LITE_ON_FLATBUFFERS_DESC_VIEW)
add_definitions("-DLITE_ON_FLATBUFFERS_DESC_VIEW")
message(STATUS "Flatbuffers will be used as cpp default program description.")
endif()
if (LITE_ON_TINY_PUBLISH) if (LITE_ON_TINY_PUBLISH)
add_definitions("-DLITE_ON_TINY_PUBLISH") add_definitions("-DLITE_ON_TINY_PUBLISH")
add_definitions("-DLITE_ON_FLATBUFFERS_DESC_VIEW")
message(STATUS "Flatbuffers will be used as cpp default program description.")
else() else()
add_definitions("-DLITE_WITH_FLATBUFFERS_DESC") add_definitions("-DLITE_WITH_FLATBUFFERS_DESC")
endif() endif()
......
...@@ -267,6 +267,10 @@ function(cc_library TARGET_NAME) ...@@ -267,6 +267,10 @@ function(cc_library TARGET_NAME)
list(REMOVE_ITEM cc_library_DEPS warpctc) list(REMOVE_ITEM cc_library_DEPS warpctc)
add_dependencies(${TARGET_NAME} warpctc) add_dependencies(${TARGET_NAME} warpctc)
endif() endif()
if("${cc_library_DEPS};" MATCHES "fbs_headers;")
list(REMOVE_ITEM cc_library_DEPS fbs_headers)
add_dependencies(${TARGET_NAME} fbs_headers)
endif()
# Only deps libmklml.so, not link # Only deps libmklml.so, not link
if("${cc_library_DEPS};" MATCHES "mklml;") if("${cc_library_DEPS};" MATCHES "mklml;")
list(REMOVE_ITEM cc_library_DEPS mklml) list(REMOVE_ITEM cc_library_DEPS mklml)
......
...@@ -17,7 +17,6 @@ if (NOT LITE_ON_TINY_PUBLISH) ...@@ -17,7 +17,6 @@ if (NOT LITE_ON_TINY_PUBLISH)
# Unlike static library, module library has to link target to be able to work # Unlike static library, module library has to link target to be able to work
# as a single .so lib. # as a single .so lib.
target_link_libraries(paddle_lite_jni ${lib_DEPS} ${arm_kernels} ${npu_kernels}) target_link_libraries(paddle_lite_jni ${lib_DEPS} ${arm_kernels} ${npu_kernels})
add_dependencies(paddle_lite_jni fbs_headers)
if (LITE_WITH_NPU) if (LITE_WITH_NPU)
# Strips the symbols of our protobuf functions to fix the conflicts during # Strips the symbols of our protobuf functions to fix the conflicts during
# loading HIAI builder libs (libhiai_ir.so and libhiai_ir_build.so) # loading HIAI builder libs (libhiai_ir.so and libhiai_ir_build.so)
......
...@@ -46,7 +46,6 @@ void LightPredictor::Build(const std::string& model_dir, ...@@ -46,7 +46,6 @@ void LightPredictor::Build(const std::string& model_dir,
case lite_api::LiteModelType::kProtobuf: case lite_api::LiteModelType::kProtobuf:
LoadModelPb(model_dir, "", "", scope_.get(), program_desc_.get()); LoadModelPb(model_dir, "", "", scope_.get(), program_desc_.get());
break; break;
#endif
case lite_api::LiteModelType::kNaiveBuffer: { case lite_api::LiteModelType::kNaiveBuffer: {
if (model_from_memory) { if (model_from_memory) {
LoadModelNaiveFromMemory( LoadModelNaiveFromMemory(
...@@ -56,6 +55,7 @@ void LightPredictor::Build(const std::string& model_dir, ...@@ -56,6 +55,7 @@ void LightPredictor::Build(const std::string& model_dir,
} }
break; break;
} }
#endif
default: default:
LOG(FATAL) << "Unknown model type"; LOG(FATAL) << "Unknown model type";
} }
......
...@@ -9,7 +9,7 @@ if(WIN32) ...@@ -9,7 +9,7 @@ if(WIN32)
target_link_libraries(lite_pybind ${os_dependency_modules}) target_link_libraries(lite_pybind ${os_dependency_modules})
else() else()
lite_cc_library(lite_pybind SHARED SRCS pybind.cc DEPS ${PYBIND_DEPS}) lite_cc_library(lite_pybind SHARED SRCS pybind.cc DEPS ${PYBIND_DEPS})
target_sources(lite_pybind PUBLIC ${__lite_cc_files}) target_sources(lite_pybind PUBLIC ${__lite_cc_files} fbs_headers)
endif(WIN32) endif(WIN32)
if (LITE_ON_TINY_PUBLISH) if (LITE_ON_TINY_PUBLISH)
......
...@@ -2,7 +2,7 @@ if (WITH_TESTING) ...@@ -2,7 +2,7 @@ if (WITH_TESTING)
lite_cc_library(lite_gtest_main SRCS lite_gtest_main.cc DEPS gtest gflags) lite_cc_library(lite_gtest_main SRCS lite_gtest_main.cc DEPS gtest gflags)
endif() endif()
lite_cc_library(target_wrapper SRCS target_wrapper.cc lite_cc_library(target_wrapper SRCS target_wrapper.cc
DEPS target_wrapper_host place DEPS target_wrapper_host place fbs_headers
X86_DEPS target_wrapper_x86 X86_DEPS target_wrapper_x86
CUDA_DEPS target_wrapper_cuda CUDA_DEPS target_wrapper_cuda
XPU_DEPS target_wrapper_xpu XPU_DEPS target_wrapper_xpu
......
...@@ -11,16 +11,15 @@ ...@@ -11,16 +11,15 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "lite/model_parser/compatibility.h" #include "lite/model_parser/compatibility.h"
#ifndef LITE_ON_TINY_PUBLISH
#include "lite/core/type_system.h" #include "lite/core/type_system.h"
#include "lite/model_parser/cpp_desc.h"
#include "lite/model_parser/naive_buffer/block_desc.h" #include "lite/model_parser/naive_buffer/block_desc.h"
#include "lite/model_parser/naive_buffer/op_desc.h" #include "lite/model_parser/naive_buffer/op_desc.h"
#include "lite/model_parser/naive_buffer/program_desc.h" #include "lite/model_parser/naive_buffer/program_desc.h"
#include "lite/model_parser/naive_buffer/var_desc.h" #include "lite/model_parser/naive_buffer/var_desc.h"
#ifndef LITE_ON_TINY_PUBLISH
#include "lite/model_parser/cpp_desc.h"
#endif #endif
namespace paddle { namespace paddle {
......
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
#include "lite/model_parser/compatible_pb.h" #include "lite/model_parser/compatible_pb.h"
#include <string> #include <string>
#include <vector> #include <vector>
#ifndef LITE_ON_TINY_PUBLISH
#include "lite/model_parser/flatbuffers/program_desc.h"
#include "lite/model_parser/naive_buffer/block_desc.h" #include "lite/model_parser/naive_buffer/block_desc.h"
#include "lite/model_parser/naive_buffer/op_desc.h" #include "lite/model_parser/naive_buffer/op_desc.h"
#include "lite/model_parser/naive_buffer/program_desc.h" #include "lite/model_parser/naive_buffer/program_desc.h"
#include "lite/model_parser/naive_buffer/var_desc.h" #include "lite/model_parser/naive_buffer/var_desc.h"
#ifndef LITE_ON_TINY_PUBLISH
#include "lite/model_parser/flatbuffers/program_desc.h"
#include "lite/model_parser/pb/block_desc.h" #include "lite/model_parser/pb/block_desc.h"
#include "lite/model_parser/pb/op_desc.h" #include "lite/model_parser/pb/op_desc.h"
#include "lite/model_parser/pb/program_desc.h" #include "lite/model_parser/pb/program_desc.h"
...@@ -67,7 +67,6 @@ void TransformVarDescAnyToCpp<fbs::VarDesc>(const fbs::VarDesc &any_desc, ...@@ -67,7 +67,6 @@ void TransformVarDescAnyToCpp<fbs::VarDesc>(const fbs::VarDesc &any_desc,
cpp_desc->SetShape(any_desc.GetShape()); cpp_desc->SetShape(any_desc.GetShape());
} }
} }
#endif
template <> template <>
void TransformVarDescAnyToCpp<naive_buffer::VarDesc>( void TransformVarDescAnyToCpp<naive_buffer::VarDesc>(
...@@ -84,7 +83,7 @@ void TransformVarDescAnyToCpp<naive_buffer::VarDesc>( ...@@ -84,7 +83,7 @@ void TransformVarDescAnyToCpp<naive_buffer::VarDesc>(
cpp_desc->SetShape(any_desc.GetShape()); cpp_desc->SetShape(any_desc.GetShape());
}*/ }*/
} }
#endif
/// For OpDesc transform /// For OpDesc transform
template <typename OpDescType> template <typename OpDescType>
void OpInputsAnyToCpp(const OpDescType &any_desc, cpp::OpDesc *cpp_desc) { void OpInputsAnyToCpp(const OpDescType &any_desc, cpp::OpDesc *cpp_desc) {
...@@ -312,12 +311,11 @@ void OpAttrsCppToAny(const cpp::OpDesc &cpp_desc, OpDescType *any_desc) { ...@@ -312,12 +311,11 @@ void OpAttrsCppToAny(const cpp::OpDesc &cpp_desc, OpDescType *any_desc) {
} \ } \
} }
#ifndef LITE_ON_TINY_PUBLISH
TRANS_VAR_ANY_WITH_CPP_IMPL(naive_buffer::VarDesc); TRANS_VAR_ANY_WITH_CPP_IMPL(naive_buffer::VarDesc);
TRANS_OP_ANY_WITH_CPP_IMPL(naive_buffer::OpDesc); TRANS_OP_ANY_WITH_CPP_IMPL(naive_buffer::OpDesc);
TRANS_BLOCK_ANY_WITH_CPP_IMPL(OpDesc, VarDesc, naive_buffer, naive_buffer); TRANS_BLOCK_ANY_WITH_CPP_IMPL(OpDesc, VarDesc, naive_buffer, naive_buffer);
TRANS_PROGRAM_ANY_WITH_CPP_IMPL(BlockDesc, naive_buffer, naive_buffer); TRANS_PROGRAM_ANY_WITH_CPP_IMPL(BlockDesc, naive_buffer, naive_buffer);
#ifndef LITE_ON_TINY_PUBLISH
TRANS_VAR_ANY_WITH_CPP_IMPL(fbs::VarDesc); TRANS_VAR_ANY_WITH_CPP_IMPL(fbs::VarDesc);
TRANS_OP_ANY_WITH_CPP_IMPL(fbs::OpDesc); TRANS_OP_ANY_WITH_CPP_IMPL(fbs::OpDesc);
TRANS_BLOCK_ANY_WITH_CPP_IMPL(OpDescT, VarDescT, fbs, fbs); TRANS_BLOCK_ANY_WITH_CPP_IMPL(OpDescT, VarDescT, fbs, fbs);
......
...@@ -48,7 +48,7 @@ class ProgramDescView : public ProgramDescAPI { ...@@ -48,7 +48,7 @@ class ProgramDescView : public ProgramDescAPI {
void InitProgramDesc() { void InitProgramDesc() {
desc_ = proto::GetProgramDesc(buf_.data()); desc_ = proto::GetProgramDesc(buf_.data());
blocks_.resize(BlocksSize()); blocks_.resize(desc_->blocks()->size());
for (size_t idx = 0; idx < BlocksSize(); ++idx) { for (size_t idx = 0; idx < BlocksSize(); ++idx) {
blocks_[idx] = BlockDescView(desc_->blocks()->Get(idx)); blocks_[idx] = BlockDescView(desc_->blocks()->Get(idx));
} }
...@@ -59,7 +59,7 @@ class ProgramDescView : public ProgramDescAPI { ...@@ -59,7 +59,7 @@ class ProgramDescView : public ProgramDescAPI {
Init(buf_); Init(buf_);
} }
size_t BlocksSize() const override { return desc_->blocks()->size(); } size_t BlocksSize() const override { return blocks_.size(); }
template <typename T> template <typename T>
T const* GetBlock(int32_t idx) const; T const* GetBlock(int32_t idx) const;
......
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
#include "lite/core/version.h" #include "lite/core/version.h"
#include "lite/model_parser/base/apis.h" #include "lite/model_parser/base/apis.h"
#include "lite/model_parser/flatbuffers/io.h" #include "lite/model_parser/flatbuffers/io.h"
#ifndef LITE_ON_TINY_PUBLISH
#include "lite/model_parser/naive_buffer/combined_params_desc.h" #include "lite/model_parser/naive_buffer/combined_params_desc.h"
#include "lite/model_parser/naive_buffer/param_desc.h" #include "lite/model_parser/naive_buffer/param_desc.h"
#include "lite/model_parser/naive_buffer/program_desc.h" #include "lite/model_parser/naive_buffer/program_desc.h"
#include "lite/model_parser/naive_buffer/var_desc.h" #include "lite/model_parser/naive_buffer/var_desc.h"
#ifndef LITE_ON_TINY_PUBLISH
#include "lite/model_parser/pb/program_desc.h" #include "lite/model_parser/pb/program_desc.h"
#include "lite/model_parser/pb/var_desc.h" #include "lite/model_parser/pb/var_desc.h"
#endif #endif
...@@ -618,7 +618,7 @@ void SaveModelNaive(const std::string &model_file, ...@@ -618,7 +618,7 @@ void SaveModelNaive(const std::string &model_file,
LOG(INFO) << "Save naive buffer model in '" << prog_path << " successfully"; LOG(INFO) << "Save naive buffer model in '" << prog_path << " successfully";
} }
#endif // LITE_ON_TINY_PUBLISH
template <typename T> template <typename T>
void SetTensorDataNaive(T *out, size_t size, const std::vector<T> &src) { void SetTensorDataNaive(T *out, size_t size, const std::vector<T> &src) {
CHECK(out); CHECK(out);
...@@ -716,6 +716,7 @@ void LoadCombinedParamsNaive(const std::string &path, ...@@ -716,6 +716,7 @@ void LoadCombinedParamsNaive(const std::string &path,
<< "] not found"; << "] not found";
} }
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/* Old Method of loading and saving model, before V2.3.0 */ /* Old Method of loading and saving model, before V2.3.0 */
/* Warning: this is an old inference and will be abandened in release/v3.0.0 */ /* Warning: this is an old inference and will be abandened in release/v3.0.0 */
...@@ -799,6 +800,7 @@ void LoadModelNaiveFromMemory(const std::string &model_buffer, ...@@ -799,6 +800,7 @@ void LoadModelNaiveFromMemory(const std::string &model_buffer,
VLOG(4) << "Load model from naive buffer memory successfully"; VLOG(4) << "Load model from naive buffer memory successfully";
} }
#endif // LITE_ON_TINY_PUBLISH
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// usage: LoadModelNaiveFromFile is used for loading model from file. // usage: LoadModelNaiveFromFile is used for loading model from file.
...@@ -807,9 +809,8 @@ void ReadModelDataFromFile(T *data, ...@@ -807,9 +809,8 @@ void ReadModelDataFromFile(T *data,
const std::string &prog_path, const std::string &prog_path,
uint64_t *offset, uint64_t *offset,
const uint64_t &size) { const uint64_t &size) {
naive_buffer::BinaryTable data_table; std::vector<char> prog_data = lite::fbs::LoadFile(prog_path, *offset, size);
data_table.LoadFromFile(prog_path, *offset, size); memcpy(data, prog_data.data(), size);
memcpy(data, data_table.cursor(), size);
*offset = *offset + size; *offset = *offset + size;
} }
/* /*
...@@ -835,7 +836,6 @@ void LoadModelNaiveFromFile(const std::string &filename, ...@@ -835,7 +836,6 @@ void LoadModelNaiveFromFile(const std::string &filename,
cpp::ProgramDesc *cpp_prog) { cpp::ProgramDesc *cpp_prog) {
CHECK(cpp_prog); CHECK(cpp_prog);
CHECK(scope); CHECK(scope);
cpp_prog->ClearBlocks();
// ModelFile // ModelFile
const std::string prog_path = filename; const std::string prog_path = filename;
...@@ -850,7 +850,11 @@ void LoadModelNaiveFromFile(const std::string &filename, ...@@ -850,7 +850,11 @@ void LoadModelNaiveFromFile(const std::string &filename,
switch (meta_version) { switch (meta_version) {
case 0: case 0:
#ifndef LITE_ON_TINY_PUBLISH
LoadModelNaiveV0FromFile(filename, scope, cpp_prog); LoadModelNaiveV0FromFile(filename, scope, cpp_prog);
#else
LOG(FATAL) << "Error, this model file is not supported.";
#endif
break; break;
case 1: case 1:
LoadModelFbsFromFile(filename, scope, cpp_prog); LoadModelFbsFromFile(filename, scope, cpp_prog);
...@@ -860,6 +864,7 @@ void LoadModelNaiveFromFile(const std::string &filename, ...@@ -860,6 +864,7 @@ void LoadModelNaiveFromFile(const std::string &filename,
break; break;
} }
} }
#ifndef LITE_ON_TINY_PUBLISH
void LoadModelNaiveV0FromFile(const std::string &filename, void LoadModelNaiveV0FromFile(const std::string &filename,
Scope *scope, Scope *scope,
cpp::ProgramDesc *cpp_prog) { cpp::ProgramDesc *cpp_prog) {
...@@ -917,13 +922,13 @@ void LoadModelNaiveV0FromFile(const std::string &filename, ...@@ -917,13 +922,13 @@ void LoadModelNaiveV0FromFile(const std::string &filename,
VLOG(4) << "Load naive buffer model in '" << filename << "' successfully"; VLOG(4) << "Load naive buffer model in '" << filename << "' successfully";
} }
#endif // LITE_ON_TINY_PUBLISH
void LoadModelFbsFromFile(const std::string &filename, void LoadModelFbsFromFile(const std::string &filename,
Scope *scope, Scope *scope,
cpp::ProgramDesc *cpp_prog) { cpp::ProgramDesc *cpp_prog) {
CHECK(cpp_prog); CHECK(cpp_prog);
CHECK(scope); CHECK(scope);
cpp_prog->ClearBlocks(); CHECK_EQ(cpp_prog->BlocksSize(), 0);
// Offset // Offset
uint64_t offset = sizeof(uint16_t); uint64_t offset = sizeof(uint16_t);
...@@ -973,9 +978,7 @@ void ReadModelDataFromBuffer(T *data, ...@@ -973,9 +978,7 @@ void ReadModelDataFromBuffer(T *data,
const std::string &model_buffer, const std::string &model_buffer,
uint64_t *offset, uint64_t *offset,
const uint64_t &size) { const uint64_t &size) {
naive_buffer::BinaryTable data_table; memcpy(data, model_buffer.c_str() + *offset, size);
data_table.LoadFromMemory(model_buffer.c_str() + *offset, size);
memcpy(data, data_table.cursor(), size);
*offset = *offset + size; *offset = *offset + size;
} }
...@@ -994,7 +997,11 @@ void LoadModelNaiveFromMemory(const std::string &model_buffer, ...@@ -994,7 +997,11 @@ void LoadModelNaiveFromMemory(const std::string &model_buffer,
VLOG(4) << "Meta_version:" << meta_version; VLOG(4) << "Meta_version:" << meta_version;
switch (meta_version) { switch (meta_version) {
case 0: case 0:
#ifndef LITE_ON_TINY_PUBLISH
LoadModelNaiveV0FromMemory(model_buffer, scope, cpp_prog); LoadModelNaiveV0FromMemory(model_buffer, scope, cpp_prog);
#else
LOG(FATAL) << "Error: Unsupported model type.";
#endif
break; break;
case 1: case 1:
LoadModelNaiveV1FromMemory(model_buffer, scope, cpp_prog); LoadModelNaiveV1FromMemory(model_buffer, scope, cpp_prog);
...@@ -1004,7 +1011,7 @@ void LoadModelNaiveFromMemory(const std::string &model_buffer, ...@@ -1004,7 +1011,7 @@ void LoadModelNaiveFromMemory(const std::string &model_buffer,
break; break;
} }
} }
#ifndef LITE_ON_TINY_PUBLISH
void LoadModelNaiveV0FromMemory(const std::string &model_buffer, void LoadModelNaiveV0FromMemory(const std::string &model_buffer,
Scope *scope, Scope *scope,
cpp::ProgramDesc *cpp_prog) { cpp::ProgramDesc *cpp_prog) {
...@@ -1040,7 +1047,7 @@ void LoadModelNaiveV0FromMemory(const std::string &model_buffer, ...@@ -1040,7 +1047,7 @@ void LoadModelNaiveV0FromMemory(const std::string &model_buffer,
VLOG(4) << "Load model from naive buffer memory successfully"; VLOG(4) << "Load model from naive buffer memory successfully";
} }
#endif
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
// Meta_version=1 // Meta_version=1
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
......
...@@ -21,11 +21,11 @@ ...@@ -21,11 +21,11 @@
#include <vector> #include <vector>
#ifndef LITE_ON_TINY_PUBLISH #ifndef LITE_ON_TINY_PUBLISH
#include "lite/core/framework.pb.h" #include "lite/core/framework.pb.h"
#include "lite/model_parser/naive_buffer/proto/framework.nb.h"
#endif #endif
#include "lite/core/scope.h" #include "lite/core/scope.h"
#include "lite/core/variable.h" #include "lite/core/variable.h"
#include "lite/model_parser/compatible_pb.h" #include "lite/model_parser/compatible_pb.h"
#include "lite/model_parser/naive_buffer/proto/framework.nb.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -101,45 +101,39 @@ void SaveModelNaive(const std::string& model_dir, ...@@ -101,45 +101,39 @@ void SaveModelNaive(const std::string& model_dir,
void SaveModelFbs(const std::string& model_dir, void SaveModelFbs(const std::string& model_dir,
const Scope& exec_scope, const Scope& exec_scope,
const cpp::ProgramDesc& cpp_prog); const cpp::ProgramDesc& cpp_prog);
#endif // LITE_ON_TINY_PUBLISH
void LoadModelFbsFromFile(const std::string& filename,
Scope* scope,
cpp::ProgramDesc* cpp_prog);
void LoadParamNaive(const std::string& path, void LoadParamNaive(const std::string& path,
lite::Scope* scope, lite::Scope* scope,
const std::string& name); const std::string& name);
// warning:this old inference will be abandened in release/v3.0.0 // warning:this old inference will be abandened in release/v3.0.0
// and LoadModelNaiveFromFile is suggested. // and LoadModelNaiveFromFile is suggested.
void LoadModelNaive(const std::string& model_dir, void LoadModelNaive(const std::string& model_dir,
lite::Scope* scope, lite::Scope* scope,
cpp::ProgramDesc* prog, cpp::ProgramDesc* prog,
bool combined = true); bool combined = true);
void LoadModelFbsFromFile(const std::string& filename,
Scope* scope,
cpp::ProgramDesc* cpp_prog);
void LoadModelNaiveV0FromFile(const std::string& filename, void LoadModelNaiveV0FromFile(const std::string& filename,
Scope* scope, Scope* scope,
cpp::ProgramDesc* cpp_prog); cpp::ProgramDesc* cpp_prog);
void LoadModelNaiveFromFile(const std::string& filename,
lite::Scope* scope,
cpp::ProgramDesc* prog);
void LoadModelNaiveFromMemory(const std::string& model_buffer, void LoadModelNaiveFromMemory(const std::string& model_buffer,
const std::string& param_buffer, const std::string& param_buffer,
lite::Scope* scope, lite::Scope* scope,
cpp::ProgramDesc* cpp_prog); cpp::ProgramDesc* cpp_prog);
void LoadModelNaiveFromMemory(const std::string& model_buffer, void LoadModelNaiveV0FromMemory(const std::string& model_buffer,
lite::Scope* scope, Scope* scope,
cpp::ProgramDesc* cpp_prog); cpp::ProgramDesc* cpp_prog);
void LoadModelNaiveV1FromMemory(const std::string& model_buffer, #endif // LITE_ON_TINY_PUBLISH
void LoadModelFbsFromFile(const std::string& filename,
Scope* scope, Scope* scope,
cpp::ProgramDesc* cpp_prog); cpp::ProgramDesc* cpp_prog);
void LoadModelFbsFromMemory(const std::string& model_buffer, void LoadModelNaiveFromFile(const std::string& filename,
lite::Scope* scope,
cpp::ProgramDesc* prog);
void LoadModelNaiveFromMemory(const std::string& model_buffer,
lite::Scope* scope, lite::Scope* scope,
cpp::ProgramDesc* cpp_prog); cpp::ProgramDesc* cpp_prog);
void LoadModelNaiveV0FromMemory(const std::string& model_buffer, void LoadModelNaiveV1FromMemory(const std::string& model_buffer,
Scope* scope, Scope* scope,
cpp::ProgramDesc* cpp_prog); cpp::ProgramDesc* cpp_prog);
} // namespace lite } // namespace lite
......
if (LITE_ON_TINY_PUBLISH)
set(naive_wrapper "")
return()
endif()
lite_cc_library(naive_buffer SRCS naive_buffer.cc DEPS types) lite_cc_library(naive_buffer SRCS naive_buffer.cc DEPS types)
add_subdirectory(proto) add_subdirectory(proto)
......
...@@ -37,7 +37,6 @@ WITH_HUAWEI_ASCEND_NPU=OFF # Huawei Ascend Builder/Runtime Libs on X86 host ...@@ -37,7 +37,6 @@ WITH_HUAWEI_ASCEND_NPU=OFF # Huawei Ascend Builder/Runtime Libs on X86 host
# default installation path, ensure acllib/atc/opp directories are all in this root dir # default installation path, ensure acllib/atc/opp directories are all in this root dir
HUAWEI_ASCEND_NPU_DDK_ROOT="/usr/local/Ascend/ascend-toolkit/latest/x86_64-linux_gcc4.8.5" HUAWEI_ASCEND_NPU_DDK_ROOT="/usr/local/Ascend/ascend-toolkit/latest/x86_64-linux_gcc4.8.5"
PYTHON_EXECUTABLE_OPTION="" PYTHON_EXECUTABLE_OPTION=""
ENABLE_FLATBUFFERS_DESC_VIEW=OFF
IOS_DEPLOYMENT_TARGET=9.0 IOS_DEPLOYMENT_TARGET=9.0
readonly THIRDPARTY_TAR=https://paddle-inference-dist.bj.bcebos.com/PaddleLite/third-party-05b862.tar.gz readonly THIRDPARTY_TAR=https://paddle-inference-dist.bj.bcebos.com/PaddleLite/third-party-05b862.tar.gz
...@@ -148,8 +147,7 @@ function make_tiny_publish_so { ...@@ -148,8 +147,7 @@ function make_tiny_publish_so {
-DAPU_DDK_ROOT=$APU_DDK_ROOT \ -DAPU_DDK_ROOT=$APU_DDK_ROOT \
-DLITE_WITH_RKNPU=$BUILD_RKNPU \ -DLITE_WITH_RKNPU=$BUILD_RKNPU \
-DRKNPU_DDK_ROOT=$RKNPU_DDK_ROOT \ -DRKNPU_DDK_ROOT=$RKNPU_DDK_ROOT \
-DARM_TARGET_OS=${os} -DARM_TARGET_ARCH_ABI=${abi} -DARM_TARGET_LANG=${lang} \ -DARM_TARGET_OS=${os} -DARM_TARGET_ARCH_ABI=${abi} -DARM_TARGET_LANG=${lang}
-DLITE_ON_FLATBUFFERS_DESC_VIEW=${ENABLE_FLATBUFFERS_DESC_VIEW}
make publish_inference -j$NUM_PROC make publish_inference -j$NUM_PROC
cd - > /dev/null cd - > /dev/null
...@@ -438,7 +436,6 @@ function print_usage { ...@@ -438,7 +436,6 @@ function print_usage {
echo -e "--build_python: (OFF|ON); controls whether to publish python api lib (ANDROID and IOS is not supported)" echo -e "--build_python: (OFF|ON); controls whether to publish python api lib (ANDROID and IOS is not supported)"
echo -e "--build_java: (OFF|ON); controls whether to publish java api lib (Only ANDROID is supported)" echo -e "--build_java: (OFF|ON); controls whether to publish java api lib (Only ANDROID is supported)"
echo -e "--build_dir: directory for building" echo -e "--build_dir: directory for building"
echo -e "--enable_flatbuffers_view: (OFF|ON); Use the flatbuffers read-only view to load the model. If ON, the naive buffer will no longer be supported."
echo -e "--ios_deployment_target: (default: 9.0); Set the minimum compatible system version for ios deployment." echo -e "--ios_deployment_target: (default: 9.0); Set the minimum compatible system version for ios deployment."
echo echo
echo -e "argument choices:" echo -e "argument choices:"
...@@ -584,10 +581,6 @@ function main { ...@@ -584,10 +581,6 @@ function main {
HUAWEI_ASCEND_NPU_DDK_ROOT="${i#*=}" HUAWEI_ASCEND_NPU_DDK_ROOT="${i#*=}"
shift shift
;; ;;
--enable_flatbuffers_view=*)
ENABLE_FLATBUFFERS_DESC_VIEW="${i#*=}"
shift
;;
--ios_deployment_target=*) --ios_deployment_target=*)
IOS_DEPLOYMENT_TARGET="${i#*=}" IOS_DEPLOYMENT_TARGET="${i#*=}"
shift shift
......
...@@ -189,7 +189,9 @@ class LogMessageFatal : public LogMessage { ...@@ -189,7 +189,9 @@ class LogMessageFatal : public LogMessage {
#ifndef LITE_ON_TINY_PUBLISH #ifndef LITE_ON_TINY_PUBLISH
abort(); abort();
#else #else
assert(false); // If we decide whether the process exits according to the NDEBUG macro
// definition, assert() can be used here.
abort();
#endif #endif
#endif #endif
} }
...@@ -250,7 +252,11 @@ class VoidifyFatal : public Voidify { ...@@ -250,7 +252,11 @@ class VoidifyFatal : public Voidify {
#ifdef LITE_WITH_EXCEPTION #ifdef LITE_WITH_EXCEPTION
~VoidifyFatal() noexcept(false) { throw std::exception(); } ~VoidifyFatal() noexcept(false) { throw std::exception(); }
#else #else
~VoidifyFatal() { assert(false); } ~VoidifyFatal() {
// If we decide whether the process exits according to the NDEBUG macro
// definition, assert() can be used here.
abort();
}
#endif #endif
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册