提交 b667193f 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!3260 check tbe kernel property in kernel select process

Merge pull request !3260 from jjfeing/master
......@@ -31,6 +31,7 @@
#include "backend/kernel_compiler/tbe/tbe_kernel_select/tbe_kernel_broadcast_selecter.h"
#include "backend/kernel_compiler/tbe/tbe_kernel_select/tbe_kernel_reduce_selecter.h"
#include "backend/kernel_compiler/tbe/tbe_kernel_select/common_utils.h"
#include "backend/kernel_compiler/tbe/tbe_kernel_select/tbe_property_checker.h"
namespace mindspore {
namespace kernel {
......@@ -59,6 +60,10 @@ void TbeKernelSelect::TbeMetadataInfoEx() {
MS_LOG(INFO) << "Warning: Cann't find tbe core opinfo, node type: " << node_name_;
return;
}
if (!TbePropertyChecker::CheckTbeProperties(cnode_ptr_)) {
MS_LOG(INFO) << "Warning: node(" << cnode_ptr_->fullname_with_scope() << ") not support tbe aicore.";
return;
}
MS_LOG(INFO) << "Start to tbe metadata info. node type: " << node_name_
<< ", node name: " << cnode_ptr_->fullname_with_scope();
OpPattern pattern = op_info_ptr->op_pattern();
......
/**
* Copyright 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.
*/
#include "backend/kernel_compiler/tbe/tbe_kernel_select/tbe_property_checker.h"
#include <map>
#include <string>
#include <vector>
#include "backend/session/anf_runtime_algorithm.h"
#include "frontend/parallel/ops_info/ops_utils.h"
namespace mindspore {
namespace kernel {
using CheckSupportFun = bool (*)(const CNodePtr &cnode);
constexpr char kAttrStrides[] = "strides";
static bool CheckStridedSlice(const CNodePtr &cnode) {
// check stride[-1] != 1 TODO
if (AnfAlgo::HasNodeAttr(kAttrStrides, cnode)) {
auto strides = AnfAlgo::GetNodeAttr<std::vector<int>>(cnode, kAttrStrides);
if (!strides.empty() && strides[strides.size() - 1] == 1) {
return true;
}
}
// last tensor TODO
return true;
}
bool TbePropertyChecker::CheckTbeProperties(const mindspore::CNodePtr &cnode) {
MS_EXCEPTION_IF_NULL(cnode);
static std::map<std::string, CheckSupportFun> tbe_property_checker = {{parallel::KStridedSlice, CheckStridedSlice}};
auto cnode_type = AnfAlgo::GetCNodeName(cnode);
auto find_iter = tbe_property_checker.find(cnode_type);
if (find_iter != tbe_property_checker.end()) {
return find_iter->second(cnode);
}
return true;
}
} // namespace kernel
} // namespace mindspore
/**
* Copyright 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 MINDSPORE_BACKEND_KERNEL_COMPILER_TBE_TBE_KERNEL_SELECT_TBE_PROPERTY_CHECKER_H
#define MINDSPORE_BACKEND_KERNEL_COMPILER_TBE_TBE_KERNEL_SELECT_TBE_PROPERTY_CHECKER_H
#include "mindspore/core/ir/anf.h"
namespace mindspore {
namespace kernel {
class TbePropertyChecker {
public:
TbePropertyChecker() = default;
~TbePropertyChecker() = default;
static bool CheckTbeProperties(const mindspore::CNodePtr &cnode);
};
} // namespace kernel
} // namespace mindspore
#endif // MINDSPORE_BACKEND_KERNEL_COMPILER_TBE_TBE_KERNEL_SELECT_TBE_PROPERTY_CHECKER_H
......@@ -232,6 +232,7 @@ constexpr char UNSORTEF_SEGMENT_PRODD[] = "UnsortedSegmentProdD";
constexpr char DEPTHWISE_CONV2D_NATIVE[] = "DepthwiseConv2dNative";
constexpr char DEPTHWISE_CONV2D[] = "DepthwiseConv2D";
constexpr char ADD[] = "Add";
constexpr char KStridedSlice[] = "StridedSlice";
// Parallel don't care
constexpr char TUPLE_GETITEM[] = "tuple_getitem";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册