remove ge depend in cpu

pull/52/head
Wei Luning 5 years ago committed by kingfo
parent 0f2ed0b134
commit 73ba399364

@ -42,11 +42,13 @@ else()
include(${CMAKE_SOURCE_DIR}/cmake/dependency_graphengine.cmake)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/inc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/inc/external)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/inc/framework)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/third_party/fwkacllib/inc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/third_party/fwkacllib/inc/toolchain)
if (ENABLE_GE OR ENABLE_D OR ENABLE_TESTCASES)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/inc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/inc/external)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/inc/framework)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/third_party/fwkacllib/inc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/third_party/fwkacllib/inc/toolchain)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
add_subdirectory(mindspore/ccsrc)

@ -40,7 +40,7 @@ if (ENABLE_GE)
include_directories(${CMAKE_SOURCE_DIR}/third_party/ge/include)
include_directories(${CMAKE_SOURCE_DIR}/third_party/ge/include/external)
include_directories(${CMAKE_SOURCE_DIR}/third_party/ge/include/external/graph)
else()
elseif(ENABLE_D OR ENABLE_TESTCASES)
include_directories(${CMAKE_SOURCE_DIR}/graphengine/inc)
include_directories(${CMAKE_SOURCE_DIR}/graphengine/inc/ops)
include_directories(${CMAKE_SOURCE_DIR}/graphengine/inc/external)

@ -34,6 +34,8 @@ if(ENABLE_GPU)
"device/gpu/*.cu"
"kernel/gpu/*.cu"
"kernel/akg/gpu/*.cc"
"kernel/akg/akgkernelbuild.cc"
"kernel/akg/akg_kernel_attrs_process.cc"
)
file(GLOB_RECURSE GPU_KERNEL_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"kernel/gpu/*.cc"
@ -100,14 +102,14 @@ file(GLOB_RECURSE MINDSPORE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"debug/*.cc"
"onnx/onnx_exporter.cc"
"operator/*.cc"
"transform/*.cc"
"session/kernel_graph.cc"
"utils/node_utils.cc"
"session/session_basic.cc"
"session/session_factory.cc"
"session/anf_runtime_algorithm.cc"
"vm/*.cc"
"pynative/*.cc"
"pynative/base.cc"
"pynative/pynative_execute.cc"
"pybind_api/*.cc"
"device/common/*.cc"
"kernel/kernel_query.cc"
@ -117,7 +119,6 @@ file(GLOB_RECURSE MINDSPORE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"device/kernel_runtime.cc"
"device/kernel_runtime_manager.cc"
"device/convert_tensor_utils.cc"
"pre_activate/ascend/*.cc"
"pre_activate/common/*.cc"
"pre_activate/pass/*.cc"
"pre_activate/gpu/*.cc"
@ -168,6 +169,15 @@ if(ENABLE_DUMP_PROTO)
add_compile_definitions(ENABLE_DUMP_PROTO)
endif()
if(ENABLE_GE)
file(GLOB_RECURSE GE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"transform/*.cc"
"pynative/pynative_execute_ge.cc"
"pipeline/pipeline_ge.cc"
)
list(APPEND MINDSPORE_SRC_LIST ${GE_SRC_LIST})
endif()
if(ENABLE_D)
include_directories("${CMAKE_BINARY_DIR}/kernel/aicpu")
file(GLOB_RECURSE PROTO_IN RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
@ -188,6 +198,9 @@ if(ENABLE_D)
"device/kernel_adjust.cc"
"kernel/kernel_fusion.cc"
"kernel/tbe/*.cc"
"pre_activate/ascend/*.cc"
"transform/*.cc"
"pipeline/pipeline_ge.cc"
)
list(APPEND MINDSPORE_SRC_LIST ${D_SRC_LIST})
list(APPEND MINDSPORE_PROTO_AICPU_LIST ${PROTOSRCS})
@ -246,9 +259,11 @@ if (ENABLE_GE)
target_link_libraries(mindspore graph ge_client)
endif()
target_link_libraries(mindspore tsdclient)
else()
elseif(ENABLE_D)
add_compile_definitions(NO_GE_CLIENT)
target_link_libraries(mindspore graph)
else()
add_compile_definitions(NO_GE_CLIENT)
endif()
if(ENABLE_D)
@ -288,8 +303,6 @@ endif()
set(PYTHON_MODULE_SOURCE
pipeline/init.cc
kernel/oplib/oplib.cc
kernel/akg/akgkernelbuild.cc
kernel/akg/akg_kernel_attrs_process.cc
${MS_STEPS_SRC_LIST} ${MS_CCE_SRC_LIST} ${MS_AICPU_SRC_LIST} ${MS_TASKINFO_LIST} ${MS_RT_SRC_LIST}
${GPU_NCCL_LIST} ${MS_HCCL_SRC_LIST} ${MS_PREDICT_SRC_LIST} ${CPU_SRC_LIST} ${MEM_REUSE_SRC_LIST} ${GPU_KERNEL_SRC_LIST})
@ -350,6 +363,7 @@ if(ENABLE_GPU)
assign_source_group("Include" ${GROUP_INCLUDE})
file(GLOB COMPILER_SRCS
"pre_activate/gpu/*.cc"
${TVM_DIR}/src/api/*.cc
${TVM_DIR}/src/arithmetic/*.cc
${TVM_DIR}/src/autotvm/*.cc

@ -49,7 +49,7 @@ bool Dump::IsKernelNeedDump(const std::string& kernel_name) {
return false;
}
bool Dump::ParseDumpConfig(const string& dump_config_file) {
bool Dump::ParseDumpConfig(const std::string& dump_config_file) {
std::ifstream jsonFile(dump_config_file);
if (!jsonFile.is_open()) {
MS_LOG(ERROR) << dump_config_file << " open failed.";

@ -94,7 +94,7 @@ static bool KernelBuildParallelCompile(const mindspore::session::KernelGraph *ke
return ret;
}
static vector<int> CalCleanZerosSize(const CNodePtr &pre_node) {
static std::vector<int> CalCleanZerosSize(const CNodePtr &pre_node) {
MS_EXCEPTION_IF_NULL(pre_node);
std::vector<int> clean_size_list;
// clean output

@ -27,6 +27,7 @@
#include "utils/log_adapter.h"
#include "utils/context/ms_context.h"
#include "common/utils.h"
#include "utils/convert_utils.h"
using std::vector;
using Json = nlohmann::json;

@ -121,8 +121,8 @@ bool TaskGenerator::LaunchKernel(const CNodePtr &anf_node_ptr, uint32_t stream_i
LaunchAddrCleanKernel(anf_node_ptr, &kernel_inputs);
}
std::vector<TaskInfoPtr> task_info_ptrs =
kernel_mod->GenTask(kernel_inputs, kernel_workspaces, kernel_outputs, stream_id);
std::vector<TaskInfoPtr> task_info_ptrs = dynamic_cast<kernel::AscendKernelMod *>(kernel_mod)
->GenTask(kernel_inputs, kernel_workspaces, kernel_outputs, stream_id);
task_info_list->insert(task_info_list->end(), task_info_ptrs.begin(), task_info_ptrs.end());
return true;
}

@ -24,7 +24,7 @@
#include <vector>
#include "device/kernel_runtime.h"
#include "ir/anf.h"
#include "kernel/kernel.h"
#include "kernel/ascend_kernel_mod.h"
#include "framework/ge_runtime/task_info.h"
namespace mindspore {

@ -21,7 +21,6 @@
#include "kernel/gpu/gpu_kernel_factory.h"
#include "operator/ops.h"
#include "pybind11/stl.h"
#include "transform/convert.h"
#include "session/anf_runtime_algorithm.h"
namespace mindspore {
namespace device {

@ -91,7 +91,7 @@ std::string SupportedTypeList(const CNodePtr& kernel_node) {
return supported_type_lists;
}
bool SelectAkgKernel(const CNodePtr& kernel_node, const shared_ptr<KernelBuildInfo>& selected_kernel_info) {
bool SelectAkgKernel(const CNodePtr& kernel_node, const std::shared_ptr<KernelBuildInfo>& selected_kernel_info) {
MS_EXCEPTION_IF_NULL(kernel_node);
MS_EXCEPTION_IF_NULL(selected_kernel_info);
std::vector<std::shared_ptr<KernelBuildInfo>> kernel_info_list;

@ -32,6 +32,7 @@
#include "device/ascend/profiling/profiling_manager.h"
#include "device/ascend/kernel_select_ascend.h"
#include "device/kernel_info.h"
#include "runtime/base.h"
constexpr auto kLoopCountParamName = "loop_count";
constexpr auto kIterLoopParamName = "iter_loop";

@ -197,6 +197,23 @@ PrimitivePtr GetCNodePrimitive(const AnfNodePtr& node) {
return nullptr;
}
std::string GetCNodeFuncName(const CNodePtr cnode) {
if (cnode->inputs().empty()) {
return "";
}
AnfNodePtr valuenode = cnode->input(0);
if (valuenode->isa<ValueNode>()) {
auto value = GetValueNode(valuenode);
// check whether the valuenode is primitive
if (value->isa<Primitive>()) {
return value->cast<PrimitivePtr>()->name();
}
return value->ToString();
}
return "";
}
bool IsPrimitive(const AnfNodePtr& node, const PrimitivePtr& value) {
if (IsValueNode<Primitive>(node)) {
PrimitivePtr fn_value = GetValueNode<PrimitivePtr>(node);

@ -384,6 +384,8 @@ static S GetValue(const ValuePtr &value) {
return v;
}
std::string GetCNodeFuncName(CNodePtr cnode);
// used to check whether an AnfNode is a cnode with a kind of Primitive as first input
bool IsPrimitiveCNode(const AnfNodePtr &node, const PrimitivePtr &value);

@ -25,7 +25,6 @@
#include "device/device_address.h"
#include "pybind_api/api_register.h"
#include "pybind_api/export_flags.h"
#include "pynative/pynative_execute.h"
#include "pipeline/static_analysis/abstract_value.h"
namespace mindspore {

@ -18,11 +18,11 @@
#include <vector>
#include <memory>
#include <string>
#include "kernel/kernel.h"
#include "kernel/ascend_kernel_mod.h"
#include "kernel/aicpu/aicpu_util.h"
namespace mindspore {
namespace kernel {
class AicpuOpKernelMod : public KernelMod {
class AicpuOpKernelMod : public AscendKernelMod {
public:
AicpuOpKernelMod();
~AicpuOpKernelMod() override;

@ -35,7 +35,6 @@
#include "utils/convert_utils.h"
#include "utils/any.h"
#include "utils/utils.h"
#include "transform/convert.h"
#include "session/anf_runtime_algorithm.h"
#include "kernel/akg/akg_kernel_attrs_process.h"
@ -240,8 +239,8 @@ bool AkgKernelBuild::CreateOutputDescJson(const AnfNodePtr &anf_node, nlohmann::
return true;
}
void GetJson(const AnfNodePtr &anf_node, const vector<int> &dyn_input_sizes, const shared_ptr<OpAttr> &op_attr,
nlohmann::json *const attr_json, const ValuePtr &attr_value) {
void GetJson(const AnfNodePtr &anf_node, const std::vector<int> &dyn_input_sizes,
const std::shared_ptr<OpAttr> &op_attr, nlohmann::json *const attr_json, const ValuePtr &attr_value) {
MS_EXCEPTION_IF_NULL(anf_node);
MS_EXCEPTION_IF_NULL(op_attr);
MS_EXCEPTION_IF_NULL(attr_json);

@ -0,0 +1,36 @@
/**
* Copyright 2019 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MINDSPORE_CCSRC_KERNEL_ASCEND_KERNEL_MOD_H_
#define MINDSPORE_CCSRC_KERNEL_ASCEND_KERNEL_MOD_H_
#include <vector>
#include <memory>
#include "framework/ge_runtime/task_info.h"
#include "kernel/kernel.h"
using TaskInfoPtr = std::shared_ptr<ge::model_runner::TaskInfo>;
namespace mindspore {
namespace kernel {
class AscendKernelMod : public KernelMod {
public:
virtual std::vector<TaskInfoPtr> GenTask(const std::vector<AddressPtr> &, const std::vector<AddressPtr> &,
const std::vector<AddressPtr> &, uint32_t) = 0;
};
} // namespace kernel
} // namespace mindspore
#endif // MINDSPORE_CCSRC_KERNEL_ASCEND_KERNEL_MOD_H_

@ -19,7 +19,6 @@
#include <map>
#include <iostream>
#include <fstream>
#include "runtime/rt.h"
#include "nlohmann/json.hpp"
#include "session/anf_runtime_algorithm.h"
#include "common/utils.h"
@ -490,7 +489,7 @@ void SaveJsonInfo(const std::string &json_name, const std::string &info) {
if (!filewrite.is_open()) {
return;
}
filewrite << info << endl;
filewrite << info << std::endl;
filewrite.close();
if (nullptr == realpath(path.c_str(), real_path)) {
MS_LOG(DEBUG) << "dir " << path << " does not exit.";

@ -226,12 +226,12 @@ class LstmGpuKernel : public GpuKernel {
size_t reserved_size_;
// input desc
unique_ptr<cudnnTensorDescriptor_t[]> x_desc_;
std::unique_ptr<cudnnTensorDescriptor_t[]> x_desc_;
cudnnTensorDescriptor_t hx_desc_;
cudnnTensorDescriptor_t cx_desc_;
cudnnFilterDescriptor_t w_desc_;
cudnnDropoutDescriptor_t dropout_desc_;
unique_ptr<cudnnTensorDescriptor_t[]> y_desc_;
std::unique_ptr<cudnnTensorDescriptor_t[]> y_desc_;
cudnnTensorDescriptor_t hy_desc_;
cudnnTensorDescriptor_t cy_desc_;
cudnnRNNDescriptor_t rnn_desc_;

@ -258,8 +258,8 @@ class LstmGradDataGpuKernel : public GpuKernel {
cudnnRNNDescriptor_t rnn_desc_;
// input desc
unique_ptr<cudnnTensorDescriptor_t[]> y_desc_;
unique_ptr<cudnnTensorDescriptor_t[]> dy_desc_;
std::unique_ptr<cudnnTensorDescriptor_t[]> y_desc_;
std::unique_ptr<cudnnTensorDescriptor_t[]> dy_desc_;
cudnnTensorDescriptor_t dhy_desc_;
cudnnTensorDescriptor_t dcy_desc_;
cudnnFilterDescriptor_t w_desc_;
@ -269,7 +269,7 @@ class LstmGradDataGpuKernel : public GpuKernel {
cudnnDropoutDescriptor_t dropout_desc_;
// output desc
unique_ptr<cudnnTensorDescriptor_t[]> dx_desc_;
std::unique_ptr<cudnnTensorDescriptor_t[]> dx_desc_;
cudnnTensorDescriptor_t dhx_desc_;
cudnnTensorDescriptor_t dcx_desc_;

@ -214,9 +214,9 @@ class LstmGradWeightGpuKernel : public GpuKernel {
cudnnDropoutDescriptor_t dropout_desc_;
// input desc
unique_ptr<cudnnTensorDescriptor_t[]> x_desc_;
std::unique_ptr<cudnnTensorDescriptor_t[]> x_desc_;
cudnnTensorDescriptor_t hx_desc_;
unique_ptr<cudnnTensorDescriptor_t[]> y_desc_;
std::unique_ptr<cudnnTensorDescriptor_t[]> y_desc_;
// output desc
cudnnFilterDescriptor_t dw_desc_;

@ -23,14 +23,14 @@
#include <vector>
#include <algorithm>
#include <utility>
#include "kernel/kernel.h"
#include "kernel/ascend_kernel_mod.h"
#include "kernel/hccl/hcom_util.h"
#include "hccl/hcom.h"
#include "common/utils.h"
namespace mindspore {
namespace kernel {
class HcclKernel : public KernelMod {
class HcclKernel : public AscendKernelMod {
public:
HcclKernel();
~HcclKernel() override;

@ -25,7 +25,6 @@
#include "ir/meta_tensor.h"
#include "pipeline/static_analysis/dshape.h"
#include "utils/log_adapter.h"
#include "framework/ge_runtime/task_info.h"
namespace mindspore {
enum KernelType : int { UNKNOWN_KERNEL_TYPE = 0, AUTO_DIFF_KERNEL, AICPU_KERNEL, RT_KERNEL, HCCL_KERNEL, TBE_KERNEL };
@ -111,7 +110,6 @@ struct Address {
size_t size;
};
using AddressPtr = std::shared_ptr<Address>;
using TaskInfoPtr = std::shared_ptr<ge::model_runner::TaskInfo>;
class KernelMod {
public:
@ -120,10 +118,6 @@ class KernelMod {
virtual const std::vector<size_t> &GetWorkspaceSizeList() const = 0;
virtual bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
const std::vector<AddressPtr> &outputs, uintptr_t stream_ptr) = 0;
virtual std::vector<TaskInfoPtr> GenTask(const std::vector<AddressPtr> &, const std::vector<AddressPtr> &,
const std::vector<AddressPtr> &, uint32_t) {
return {};
}
virtual std::vector<size_t> GenParameters() { return {}; }
virtual ~KernelMod() = default;

@ -22,12 +22,12 @@
#include <memory>
#include <map>
#include <string>
#include "kernel/kernel.h"
#include "kernel/ascend_kernel_mod.h"
#include "kernel/task_stream.h"
namespace mindspore {
namespace kernel {
class RtKernel : public KernelMod {
class RtKernel : public AscendKernelMod {
public:
RtKernel();
~RtKernel() override;

@ -19,7 +19,7 @@
#include <unordered_map>
#include <memory>
#include "utils/log_adapter.h"
#include "kernel/oplib/opinfo.h"
#include "utils/overload.h"
#include "utils/context/ms_context.h"
namespace mindspore {
@ -50,7 +50,7 @@ constexpr auto kNeedCompile = "need_compile";
constexpr auto kShape = "shape";
std::vector<std::shared_ptr<OpInfo>> OpLib::op_info_;
string ImplTypeToStr(OpImplyType impl_type) {
std::string ImplTypeToStr(OpImplyType impl_type) {
switch (impl_type) {
case kTBE:
return kTbe;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save