提交 1274acf4 编写于 作者: W willzhang4a58

build proto

上级 f54cf7dd
# cmake configure
cmake_minimum_required(VERSION 3.5)
project(oneflow C CXX)
set(CMAKE_CXX_STANDARD 11)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
enable_testing()
set(oneflow_source_dir "${PROJECT_SOURCE_DIR}/oneflow")
# dependencies
set(PROTOBUF_PROTOC_EXECUTABLE "/opt/oneflow/protobuf3/bin/protoc"
CACHE FILEPATH "")
set(Protobuf_INCLUDE_DIRS "/opt/oneflow/protobuf3/include" CACHE PATH "")
set(Protobuf_LIBRARIES "/opt/oneflow/protobuf3/lib/libprotobuf.so" CACHE PATH "")
include(dependencies)
# proto
include(cmake/dependencies.cmake)
include(proto2cpp)
file(GLOB_RECURSE oneflow_protos
RELATIVE ${oneflow_source_dir}
"*.proto")
RELATIVE_PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS
${oneflow_source_dir}
${oneflow_protos})
include_directories(${PROJECT_BINARY_DIR})
add_library(protocc ${PROTO_SRCS} ${PROTO_HDRS})
# NOTE: temporary solution
# TODO: auto generate by foreach
......
set(ONEFLOW_LINKER_LIBS "")
find_package(Glog REQUIRED)
find_package(GLog REQUIRED)
include_directories(SYSTEM ${GLOG_INCLUDE_DIRS})
list(APPEND ONEFLOW_LINKER_LIBS ${GLOG_LIBRARIES})
find_package(GTest REQUIRED)
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
list(APPEND ONEFLOW_LINKER_LIBS ${GTEST_LIBRARIES})
if(NOT PROTOBUF_PROTOC_EXECUTABLE)
find_package(Protobuf REQUIRED)
endif()
include_directories(${Protobuf_INCLUDE_DIRS})
list(APPEND ONEFLOW_LINKER_LIBS ${Protobuf_LIBRARIES})
function(RELATIVE_PROTOBUF_GENERATE_CPP SRCS HDRS ROOT_DIR)
if(NOT ARGN)
message(SEND_ERROR "Error: RELATIVE_PROTOBUF_GENERATE_CPP() called without any proto files")
return()
endif()
set(${SRCS})
set(${HDRS})
foreach(FIL ${ARGN})
set(ABS_FIL ${ROOT_DIR}/${FIL})
get_filename_component(FIL_WE ${FIL} NAME_WE)
get_filename_component(FIL_DIR ${ABS_FIL} PATH)
file(RELATIVE_PATH REL_DIR ${ROOT_DIR} ${FIL_DIR})
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${REL_DIR}/${FIL_WE}.pb.cc")
list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${REL_DIR}/${FIL_WE}.pb.h")
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${REL_DIR}/${FIL_WE}.pb.cc"
"${CMAKE_CURRENT_BINARY_DIR}/${REL_DIR}/${FIL_WE}.pb.h"
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} -I ${ROOT_DIR} ${ABS_FIL} -I ${Protobuf_INCLUDE_DIRS} -I ${PROJECT_SOURCE_DIR}/oneflow
DEPENDS ${ABS_FIL}
COMMENT "Running C++ protocol buffer compiler on ${FIL}"
VERBATIM )
endforeach()
set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
endfunction()
syntax = "proto3";
syntax = "proto2";
package oneflow;
import "layer_conf.proto"
import "layer/layer_conf.proto";
message DLNetConf {
required string name = 1;
......
syntax = "proto3";
syntax = "proto2";
package oneflow;
import "job/dlnet_conf.proto";
import "job/resource.proto";
import "job/strategy.proto";
message JobUserConf {
required string train_dlnet_conf_filepath;
required string resource_filepath;
required string strategy_filepath;
required string train_dlnet_conf_filepath = 1;
required string resource_filepath = 2;
required string strategy_filepath = 3;
}
message JobSysConf {
required JobUserConf user_conf;
required DLNetConf train_dlnet_conf;
required Resource resource;
required Strategy strategy;
required JobUserConf user_conf = 1;
required DLNetConf train_dlnet_conf = 2;
required Resource resource = 3;
required Strategy strategy = 4;
}
syntax = "proto3";
syntax = "proto2";
package oneflow;
message Machine {
required string addr = 1; // domain name or ip
required string port = 2;
repeated int32 device_vec;
repeated int32 device_vec = 3;
}
message Resource {
......
syntax = "proto3";
syntax = "proto2";
package oneflow;
message Section {
......@@ -7,17 +7,17 @@ message Section {
}
message DeviceGroup {
repeated Section device_section_vec;
repeated Section device_section_vec = 1;
}
message MachineGroup {
repeated Section machine_section_vec;
repeated Section machine_section_vec = 1;
}
message ParallelConf {
enum Policy {
DataParallel,
ModelParallel
DataParallel = 0;
ModelParallel = 1;
}
required Policy policy = 1;
oneof device_or_machine {
......
syntax = "proto3";
syntax = "proto2";
package oneflow;
message ConstantModelParamInitializerConf {
......@@ -20,9 +20,9 @@ message GaussianModelParamInitializerConf {
message ModelParamInitializerConf {
oneof conf_for_specified_initializer {
ConstantModelParamInitializerConf const_conf;
UniformModelParamInitializerConf uniform_conf;
GaussianModelParamInitializerConf gaussian_conf;
ConstantModelParamInitializerConf const_conf = 1;
UniformModelParamInitializerConf uniform_conf = 2;
GaussianModelParamInitializerConf gaussian_conf = 3;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册