Skip to content

Commit

Permalink
Merge branch 'decouple_stream_and_instruction' of github.com:Oneflow-…
Browse files Browse the repository at this point in the history
…Inc/oneflow into decouple_stream_and_instruction
  • Loading branch information
lixinqi committed Jun 10, 2022
2 parents f020749 + 7845ebe commit 4775c72
Show file tree
Hide file tree
Showing 63 changed files with 2,027 additions and 955 deletions.
20 changes: 18 additions & 2 deletions cmake/oneflow.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ generate_functional_api_and_pybind11_cpp(FUNCTIONAL_GENERATED_SRCS FUNCTIONAL_GE
FUNCTIONAL_PYBIND11_SRCS ${PROJECT_SOURCE_DIR})
oneflow_add_library(of_functional_obj STATIC ${FUNCTIONAL_GENERATED_SRCS}
${FUNCTIONAL_GENERATED_HRCS})
target_link_libraries(of_functional_obj glog::glog)
target_link_libraries(of_functional_obj LLVMSupportWithHeader glog::glog)
add_dependencies(of_functional_obj prepare_oneflow_third_party)

if(BUILD_PYTHON)
Expand All @@ -214,7 +214,7 @@ if(BUILD_PYTHON)
of_functional_tensor_obj STATIC ${FUNCTIONAL_TENSOR_GENERATED_SRCS}
${FUNCTIONAL_TENSOR_GENERATED_HRCS} ${FUNCTIONAL_OPS_GENERATED_SRCS}
${FUNCTIONAL_OPS_GENERATED_HRCS})
target_link_libraries(of_functional_tensor_obj glog::glog)
target_link_libraries(of_functional_tensor_obj LLVMSupportWithHeader glog::glog)
add_dependencies(of_functional_tensor_obj prepare_oneflow_third_party)
target_include_directories(of_functional_tensor_obj PRIVATE ${Python_INCLUDE_DIRS}
${Python_NumPy_INCLUDE_DIRS})
Expand Down Expand Up @@ -274,6 +274,22 @@ if(WITH_MLIR)
set(ONEFLOW_MLIR_LIBS -Wl,--no-as-needed MLIROneFlowExtension -Wl,--as-needed)
endif()

if("${LLVM_PROVIDER}" STREQUAL "install")
get_property(LLVM_INSTALL_DIR GLOBAL PROPERTY LLVM_INSTALL_DIR)
check_variable_defined(LLVM_INSTALL_DIR)
find_library(LLVMSupportLib LLVMSupport PATHS ${LLVM_INSTALL_DIR}/lib REQUIRED)
add_library(LLVMSupportWithHeader UNKNOWN IMPORTED)
set_property(TARGET LLVMSupportWithHeader PROPERTY IMPORTED_LOCATION ${LLVMSupportLib})
else()
add_library(LLVMSupportWithHeader INTERFACE IMPORTED)
target_link_libraries(LLVMSupportWithHeader INTERFACE LLVMSupport)
endif()
check_variable_defined(LLVM_INCLUDE_DIRS)
set_property(TARGET LLVMSupportWithHeader PROPERTY INTERFACE_INCLUDE_DIRECTORIES
${LLVM_INCLUDE_DIRS})

list(APPEND oneflow_third_party_libs LLVMSupportWithHeader)

include(op_schema)

get_property(EXTERNAL_INCLUDE_DIRS GLOBAL PROPERTY EXTERNAL_INCLUDE_DIRS)
Expand Down
2 changes: 1 addition & 1 deletion cmake/op_schema.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ set_source_files_properties(${GENERATED_OP_SCHEMA_H} ${GENERATED_OP_SCHEMA_CPP}
TRUE)

oneflow_add_library(of_op_schema OBJECT ${GENERATED_OP_SCHEMA_H} ${GENERATED_OP_SCHEMA_CPP})
target_link_libraries(of_op_schema glog::glog)
target_link_libraries(of_op_schema LLVMSupportWithHeader glog::glog)
add_dependencies(of_op_schema prepare_oneflow_third_party)
6 changes: 6 additions & 0 deletions cmake/util.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ function(set_compile_options_to_oneflow_target target)
endif()
endfunction()

function(check_variable_defined variable)
if(NOT DEFINED ${variable})
message(FATAL_ERROR "Variable ${variable} is not defined")
endif()
endfunction()

function(checkDirAndAppendSlash)
set(singleValues DIR;OUTPUT)
set(prefix ARG)
Expand Down
3 changes: 1 addition & 2 deletions docs/source/graph.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ Base class for running neural networks in Static Graph Mode.

.. autoclass:: oneflow.nn.graph.graph_config.GraphConfig
:members: enable_amp,
enable_zero,
allow_fuse_model_update_ops,
allow_fuse_add_to_output,
allow_fuse_cast_scale,
set_gradient_accumulation_steps,
set_zero_redundancy_optimizer_mode,
set_zero_redundancy_optimizer_min_size_after_split,
enable_cudnn_conv_heuristic_search_algo,
:member-order: bysource

Expand Down
10 changes: 8 additions & 2 deletions oneflow/api/python/framework/nn_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,18 @@ ONEFLOW_API_PYBIND11_MODULE("nn.graph.", m) {
m.def("RunLazyNNGraph", &RunLazyNNGraph);
m.def("SoftSyncNNGraphBuffers", &SoftSyncNNGraphBuffers);
m.def("AddTensorAsGraphLoss", &AddTensorAsGraphLoss);
m.def("ConvertJobToTosaIR", [](const std::string& serialized_job) -> Maybe<std::string> {
Job job;
CHECK_OR_RETURN(TxtString2PbMessage(serialized_job, &job))
<< "serialized job conversion failed.";
return ConvertJobToTosaIR(&job);
});
m.def("SaveJobToIR",
[](const std::string& serialized_job, const std::string& path) -> Maybe<void> {
Job job;
CHECK_OR_RETURN(TxtString2PbMessage(serialized_job, &job));
CHECK_OR_RETURN(TxtString2PbMessage(serialized_job, &job))
<< "serialized job conversion failed.";
return SaveJobToIR(&job, path);
;
});
m.def("LoadSerializedJobFromIR", [](const std::string& path) -> Maybe<py::bytes> {
Job job;
Expand Down
7 changes: 3 additions & 4 deletions oneflow/core/autograd/gradient_funcs/normalization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,14 @@ class NormalizationGrad : public OpExprGradFunction<NormalizationGradCaptureStat
return Maybe<void>::Ok();
}

DimVector dim_vec;
Shape shape;
for (int i = 0; i < x->shape()->NumAxes(); ++i) {
if (i != ctx->axis) {
dim_vec.emplace_back(1);
shape.emplace_back(1);
} else {
dim_vec.emplace_back(x->shape()->At(ctx->axis));
shape.emplace_back(x->shape()->At(ctx->axis));
}
}
Shape shape(dim_vec);
const auto& reshaped_gamma = JUST(functional::Reshape(gamma, shape));
const auto& reshaped_inv_variance = JUST(functional::Reshape(inv_variance, shape));

Expand Down
277 changes: 0 additions & 277 deletions oneflow/core/common/fixed_vector.h

This file was deleted.

Loading

0 comments on commit 4775c72

Please sign in to comment.