Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
mindspore-ci-bot | 80f9c96ed3 | 4 years ago |
yanghaoran | b0f450f237 | 4 years ago |
mindspore-ci-bot | 61f6add0d7 | 4 years ago |
caifubi | fc4ee9e531 | 4 years ago |
lujiale | 794ecbdbd4 | 4 years ago |
mindspore-ci-bot | cb39cb2ba7 | 5 years ago |
mindspore-ci-bot | 323e79a77e | 5 years ago |
wuweikang | 47066aea57 | 5 years ago |
gukecai | eed1d913b2 | 5 years ago |
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Copyright 2019-2020 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 INC_COMMON_UTILS_AI_CORE_COMMON_ATTR_DEFINE_H_
|
||||
#define INC_COMMON_UTILS_AI_CORE_COMMON_ATTR_DEFINE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace fe {
|
||||
static const std::string SCOPE_ID_ATTR = "fusion_scope";
|
||||
|
||||
static const std::string FE_IMPLY_TYPE = "_fe_imply_type";
|
||||
|
||||
static const std::string PARENT_OP_TYPE = "parentOpType";
|
||||
|
||||
static const std::string ATTR_NAME_TASK_L2_FUSION_INFO_EXTEND_PTR = "task_l2_fusion_info_extend_content";
|
||||
|
||||
static const std::string ATTR_DATA_DUMP_REF = "_datadump_ref";
|
||||
|
||||
static const std::string ATTR_NAME_L2_FUSION_EXTEND_PTR = "l2_fusion_extend_content";
|
||||
|
||||
static const std::string L1_OPTIMIZED = "l1_optimized";
|
||||
|
||||
static const std::string L2_OPTIMIZED = "l2_optimized";
|
||||
} // namespace fe
|
||||
#endif
|
@ -0,0 +1,118 @@
|
||||
/**
|
||||
* Copyright 2019-2020 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 INC_COMMON_UTILS_AI_CORE_COMMON_TYPES_H_
|
||||
#define INC_COMMON_UTILS_AI_CORE_COMMON_TYPES_H_
|
||||
|
||||
#include "graph/anchor.h"
|
||||
#include "graph/types.h"
|
||||
#include "runtime/kernel.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace fe {
|
||||
struct FusionOpSrc {
|
||||
uint32_t src_op_id;
|
||||
ge::AnchorPtr src_anchor;
|
||||
int32_t fusion_src_index;
|
||||
int32_t fusion_dst_index;
|
||||
};
|
||||
|
||||
struct FusionOpDst {
|
||||
uint32_t dst_op_id;
|
||||
ge::AnchorPtr dst_anchor;
|
||||
};
|
||||
|
||||
struct FusionDataFlow {
|
||||
std::pair<ge::AnchorPtr, ge::AnchorPtr> edge;
|
||||
std::pair<std::string, ge::AnchorPtr> node_dataindex_pair;
|
||||
};
|
||||
|
||||
typedef struct tagL2FusionData {
|
||||
uint32_t l2Index;
|
||||
uint64_t l2Addr;
|
||||
uint64_t l2PageNum;
|
||||
} L2FusionData_t;
|
||||
typedef std::map<uint64_t, L2FusionData_t> L2FusionDataMap_t;
|
||||
|
||||
typedef struct tagFeSmDesc {
|
||||
rtL2Ctrl_t l2ctrl;
|
||||
std::string nodeName[8];
|
||||
uint8_t outputIndex[8];
|
||||
} feSmDesc_t;
|
||||
|
||||
typedef struct TagTaskL2FusionInfo {
|
||||
std::string nodeName;
|
||||
feSmDesc_t l2Info;
|
||||
L2FusionDataMap_t input;
|
||||
L2FusionDataMap_t output;
|
||||
uint32_t isUsed;
|
||||
} TaskL2FusionInfo_t;
|
||||
|
||||
using L2FusionInfoPtr = std::shared_ptr<TaskL2FusionInfo_t>;
|
||||
|
||||
typedef struct ToOpStruct {
|
||||
int64_t opL1Space = 0;
|
||||
std::vector<int64_t> opL1FusionType;
|
||||
int64_t opL1WorkspaceFlag = 0; // for workspace flag
|
||||
int64_t opL1WorkspaceSize = 0;
|
||||
std::vector<std::vector<int64_t>> validInputShape;
|
||||
std::vector<std::vector<int64_t>> validOutputShape;
|
||||
std::vector<std::vector<int64_t>> sliceInputOffset; // conv & pooling & ReadSelect
|
||||
std::vector<std::vector<int64_t>> sliceOutputOffset; // WriteSelect
|
||||
std::vector<uint32_t> totalShape;
|
||||
uint32_t splitIndex = 0;
|
||||
ToOpStruct() {
|
||||
// set invalid value for essential variable
|
||||
opL1Space = -1;
|
||||
opL1WorkspaceSize = -1;
|
||||
}
|
||||
} ToOpStruct_t;
|
||||
|
||||
enum OpImplType {
|
||||
EN_IMPL_CUSTOM_CONSTANT_CCE = 0, // custom constant op
|
||||
EN_IMPL_CUSTOM_TIK, // custom tik op
|
||||
EN_IMPL_CUSTOM_TBE, // custom tbe op
|
||||
EN_IMPL_HW_CONSTANT_CCE, // Huawei built-in constant op
|
||||
EN_IMPL_HW_GENERAL_CCE, // Huawei built-in cce op
|
||||
EN_IMPL_HW_TIK, // Huawei built-in tik op
|
||||
EN_IMPL_HW_TBE, // Huawei built-in tbe op
|
||||
EN_IMPL_RL, // RL op
|
||||
EN_IMPL_PLUGIN_TBE, // Huawei built-in tbe plugin op
|
||||
EN_IMPL_VECTOR_CORE_HW_TBE, // Huawei built-in tbe op
|
||||
EN_IMPL_VECTOR_CORE_CUSTOM_TBE, // custom tbe op
|
||||
EN_IMPL_NON_PERSISTENT_CUSTOM_TBE, // custom tbe op
|
||||
EN_RESERVED // reserved value
|
||||
};
|
||||
|
||||
static const std::map<ge::DataType, uint32_t> DATATYPE_SIZE_MAP{{ge::DT_FLOAT, sizeof(float)},
|
||||
{ge::DT_FLOAT16, sizeof(int16_t)},
|
||||
{ge::DT_INT8, sizeof(int8_t)},
|
||||
{ge::DT_INT32, sizeof(int32_t)},
|
||||
{ge::DT_UINT8, sizeof(uint8_t)},
|
||||
{ge::DT_UINT32, sizeof(uint32_t)},
|
||||
{ge::DT_INT16, sizeof(int16_t)},
|
||||
{ge::DT_UINT16, sizeof(uint16_t)},
|
||||
{ge::DT_INT64, sizeof(int64_t)},
|
||||
{ge::DT_UINT64, sizeof(uint64_t)},
|
||||
{ge::DT_DOUBLE, sizeof(double)},
|
||||
{ge::DT_BOOL, sizeof(bool)},
|
||||
{ge::DT_DUAL, sizeof(float) + sizeof(int8_t)},
|
||||
{ge::DT_DUAL_SUB_UINT8, sizeof(int8_t)},
|
||||
{ge::DT_DUAL_SUB_INT8, sizeof(int8_t)}};
|
||||
} // namespace fe
|
||||
#endif
|
@ -0,0 +1,107 @@
|
||||
/**
|
||||
* Copyright 2019-2020 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 INC_COMMON_UTILS_AI_CORE_COMMON_GRAPH_COMMON_H_
|
||||
#define INC_COMMON_UTILS_AI_CORE_COMMON_GRAPH_COMMON_H_
|
||||
|
||||
#include "graph/compute_graph.h"
|
||||
#include "common/aicore_util_types.h"
|
||||
#include "register/graph_optimizer/graph_optimize_register_error_codes.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace fe {
|
||||
|
||||
using kScopeNodeMap_t = std::map<int64_t, std::vector<ge::NodePtr>>;
|
||||
using kScopeNodePair_t = std::pair<int64_t, std::vector<ge::NodePtr>>;
|
||||
|
||||
class GraphCommImpl;
|
||||
using GraphCommImplPtr = std::unique_ptr<GraphCommImpl>;
|
||||
|
||||
class GraphComm {
|
||||
public:
|
||||
GraphComm(const string &engineName);
|
||||
virtual ~GraphComm();
|
||||
GraphComm(const GraphComm &in) = delete;
|
||||
GraphComm &operator=(const GraphComm &in) = delete;
|
||||
|
||||
Status GetscopeNodeMap(ge::ComputeGraph &graph, kScopeNodeMap_t &fusionMap);
|
||||
|
||||
Status CopyFusionOpNodes(vector<FusionDataFlow> &fusInputEdgeList, vector<FusionDataFlow> &fusOutputEdgeList,
|
||||
vector<ge::NodePtr> &fusNodelist, ge::OpDescPtr fusionOpDesc,
|
||||
ge::ComputeGraphPtr fusionGraph);
|
||||
|
||||
Status CopyFusionOpEdges(ge::OpDescPtr fusionOpDesc, ge::ComputeGraph &origGraph, ge::ComputeGraphPtr fusionGraph);
|
||||
|
||||
Status GetNodeDataFlowMap(const ge::NodePtr &fusNode,
|
||||
std::map<ge::NodePtr, std::map<ge::AnchorPtr, ge::AnchorPtr>> &fusionOpAnchorsMap,
|
||||
ge::kFusionDataFlowVec_t &fusDataflowList, const int &mapType);
|
||||
|
||||
Status GetFusionNodeEdgeList(std::vector<ge::NodePtr> &fusNodelist, std::vector<FusionDataFlow> &fusInputEdgeList,
|
||||
std::vector<FusionDataFlow> &fusOutputEdgeList);
|
||||
void ClearFusionSrc();
|
||||
|
||||
void ClearFusionDst();
|
||||
|
||||
void AddFusionOutputSrc(const uint32_t &src_op_id, const ge::AnchorPtr &src_anchor, const int32_t &fusion_src_index,
|
||||
std::pair<string, ge::AnchorPtr> &node_dataindex_pair);
|
||||
|
||||
void AddFusionInputSrc(const uint32_t &src_op_id, const ge::AnchorPtr &src_anchor, const int32_t &fusion_dst_index,
|
||||
std::pair<string, ge::AnchorPtr> &node_dataindex_pair);
|
||||
|
||||
void SaveFusionDst(const uint32_t &dst_op_id, ge::AnchorPtr dst_anchor);
|
||||
|
||||
bool IsFusionDstExist(const uint32_t &dst_op_id, const ge::AnchorPtr &dst_anchor);
|
||||
|
||||
bool GetFusionSrc(const uint32_t &src_op_id, const ge::AnchorPtr &src_anchor, int32_t &fusion_src_index,
|
||||
int32_t &fusion_dst_index);
|
||||
|
||||
Status GetFusionNodeCtrlEdgeList(vector<ge::NodePtr> &fusNodelist, vector<FusionDataFlow> &fusInputCtrlEdgeList,
|
||||
vector<FusionDataFlow> &fusOutputCtrlEdgeList);
|
||||
|
||||
Status MergeFusionNodeEdgeList(ge::NodePtr &fusNode, vector<ge::NodePtr> &fusNodelist,
|
||||
vector<FusionDataFlow> &fusInputEdgeList, vector<FusionDataFlow> &fusOutputEdgeList);
|
||||
|
||||
Status MergeFusionNodeCtrlEdgeList(ge::NodePtr &fusNode, vector<ge::NodePtr> &fusNodelist,
|
||||
vector<FusionDataFlow> &fusInputEdgeList,
|
||||
vector<FusionDataFlow> &fusOutputEdgeList);
|
||||
|
||||
string GetEngineName();
|
||||
|
||||
private:
|
||||
Status MergeFusionNodeInputEdgeList(ge::NodePtr fusNode, std::vector<ge::NodePtr> &fusNodelist,
|
||||
std::vector<FusionDataFlow> &fusInputEdgeList);
|
||||
Status MergeFusionNodeOutputEdgeList(ge::NodePtr fusNode, std::vector<ge::NodePtr> &fusNodelist,
|
||||
std::vector<FusionDataFlow> &fusOutputEdgeList);
|
||||
|
||||
string engineName_;
|
||||
|
||||
std::vector<FusionOpSrc> exist_fusion_src_list_;
|
||||
std::vector<FusionOpDst> exist_fusion_dst_list_;
|
||||
|
||||
// std::vector<std::multimap<std::string, uint32_t>>
|
||||
ge::kFusionDataFlowVec_t fusion_input_dataflow_list_;
|
||||
|
||||
// std::vector<std::multimap<std::string, ge::AnchorPtr>>
|
||||
ge::kFusionDataFlowVec_t fusion_output_dataflow_list_;
|
||||
|
||||
GraphCommImplPtr graphCommImplPtr_;
|
||||
};
|
||||
} // namespace fe
|
||||
#endif
|
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright 2019-2020 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 INC_COMMON_UTILS_AI_CORE_COMMON_SCOPE_ALLOCATOR_H_
|
||||
#define INC_COMMON_UTILS_AI_CORE_COMMON_SCOPE_ALLOCATOR_H_
|
||||
|
||||
#include "graph/op_desc.h"
|
||||
|
||||
namespace fe {
|
||||
class ScopeAllocator {
|
||||
public:
|
||||
ScopeAllocator();
|
||||
virtual ~ScopeAllocator();
|
||||
ScopeAllocator(const ScopeAllocator& in) = delete;
|
||||
ScopeAllocator& operator=(const ScopeAllocator& in) = delete;
|
||||
|
||||
public:
|
||||
void Init();
|
||||
int64_t GetCurrentScopeId();
|
||||
int64_t AllocateScopeId(void);
|
||||
bool HasScopeAttr(ge::ConstOpDescPtr opdef);
|
||||
bool GetScopeAttr(ge::ConstOpDescPtr opdef, int64_t& scopeId);
|
||||
bool SetScopeAttr(ge::OpDescPtr opdef, int64_t scopeId);
|
||||
|
||||
private:
|
||||
int64_t scopeId;
|
||||
};
|
||||
} // namespace fe
|
||||
#endif
|
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright 2019-2020 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 TENSORSIZE_CALCULATOR_H
|
||||
#define TENSORSIZE_CALCULATOR_H
|
||||
|
||||
#include "graph_optimizer/graph_optimize_register_error_codes.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "graph/compute_graph.h"
|
||||
#include "graph/op_desc.h"
|
||||
|
||||
namespace fe {
|
||||
class TensorSizeCalculator {
|
||||
public:
|
||||
/**
|
||||
* Calculate the tensor size of input and output of each opdesc
|
||||
* @param opDesc opdesc object
|
||||
* @param opImplType op impl type
|
||||
* @return status SUCCESS or FAILED
|
||||
*/
|
||||
static Status CalculateOpTensorSize(ge::OpDesc &opDesc);
|
||||
|
||||
private:
|
||||
static Status CalcInputOpTensorSize(ge::OpDesc &opDesc, int32_t &outputRealCalcFlag);
|
||||
|
||||
static Status CalcOutputOpTensorSize(ge::OpDesc &opDesc, int32_t &outputRealCalcFlag);
|
||||
};
|
||||
} // namespace fe
|
||||
|
||||
#endif // TENSORSIZE_CALCULATOR_H
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue