!17028 clear warnings on master

From: @huaweib
Reviewed-by: @jjfeing,@kisnwang
Signed-off-by: @kisnwang
This commit is contained in:
mindspore-ci-bot 2021-05-27 09:14:03 +08:00 committed by Gitee
commit aa49147f31
9 changed files with 37 additions and 50 deletions

View File

@ -64,16 +64,10 @@ bool SetIOIputSize(const std::shared_ptr<AnfNode> &anf_node, const size_t &input
} }
} else { } else {
auto type_ptr = TypeIdToType(AnfAlgo::GetInputDeviceDataType(anf_node, i)); auto type_ptr = TypeIdToType(AnfAlgo::GetInputDeviceDataType(anf_node, i));
MS_EXCEPTION_IF_NULL(type_ptr);
int64_t size_i = 1; int64_t size_i = 1;
for (size_t j = 0; j < shape_i.size(); j++) { if (!GetShapeSize(shape_i, type_ptr, &size_i)) {
size_i = LongMulWithOverflowCheck(size_i, static_cast<int>(shape_i[j]));
}
size_t type_byte = GetTypeByte(type_ptr);
if (type_byte == 0) {
return false; return false;
} }
size_i = LongMulWithOverflowCheck(size_i, SizeToInt(type_byte));
input_size_list->push_back(LongToSize(size_i)); input_size_list->push_back(LongToSize(size_i));
} }
} }
@ -98,16 +92,10 @@ bool SetIOSize(const std::shared_ptr<AnfNode> &anf_node, const std::shared_ptr<A
for (size_t i = 0; i < output_num; i++) { for (size_t i = 0; i < output_num; i++) {
std::vector<size_t> shape_i = AnfAlgo::GetOutputDeviceShape(anf_node, i); std::vector<size_t> shape_i = AnfAlgo::GetOutputDeviceShape(anf_node, i);
TypePtr type_ptr = TypeIdToType(AnfAlgo::GetOutputDeviceDataType(anf_node, i)); TypePtr type_ptr = TypeIdToType(AnfAlgo::GetOutputDeviceDataType(anf_node, i));
MS_EXCEPTION_IF_NULL(type_ptr);
int64_t size_i = 1; int64_t size_i = 1;
for (size_t j = 0; j < shape_i.size(); j++) { if (!GetShapeSize(shape_i, type_ptr, &size_i)) {
size_i = LongMulWithOverflowCheck(size_i, static_cast<int>(shape_i[j]));
}
size_t type_byte = GetTypeByte(type_ptr);
if (type_byte == 0) {
return false; return false;
} }
size_i = LongMulWithOverflowCheck(size_i, SizeToInt(type_byte));
output_size_list.push_back(LongToSize(size_i)); output_size_list.push_back(LongToSize(size_i));
} }
kernel_mod_ptr->SetOutputSizeList(output_size_list); kernel_mod_ptr->SetOutputSizeList(output_size_list);

View File

@ -848,5 +848,17 @@ void ComputeInterpolationWeights(const size_t out_size, const size_t in_size, co
} }
} }
bool GetShapeSize(const std::vector<size_t> &shape, const TypePtr &type_ptr, int64_t *size_i) {
MS_EXCEPTION_IF_NULL(type_ptr);
size_t type_byte = GetTypeByte(type_ptr);
if (type_byte == 0) {
return false;
}
for (size_t j = 0; j < shape.size(); j++) {
size_i[0] = LongMulWithOverflowCheck(size_i[0], static_cast<int>(shape[j]));
}
size_i[0] = LongMulWithOverflowCheck(size_i[0], SizeToInt(type_byte));
return true;
}
} // namespace kernel } // namespace kernel
} // namespace mindspore } // namespace mindspore

View File

@ -80,6 +80,7 @@ TypeId DtypeToTypeId(const std::string &dtypes);
std::string Dtype2ShortType(const std::string &dtypes); std::string Dtype2ShortType(const std::string &dtypes);
std::string TypeId2String(TypeId type_id, bool unknown_as_default = false); std::string TypeId2String(TypeId type_id, bool unknown_as_default = false);
size_t GetDtypeNbyte(const std::string &dtypes); size_t GetDtypeNbyte(const std::string &dtypes);
bool GetShapeSize(const std::vector<size_t> &shape, const TypePtr &type_ptr, int64_t *size_i);
bool ParseMetadata(const CNodePtr &kernel_node, const std::shared_ptr<const OpInfo> &op_info_ptr, Processor processor, bool ParseMetadata(const CNodePtr &kernel_node, const std::shared_ptr<const OpInfo> &op_info_ptr, Processor processor,
std::vector<std::shared_ptr<KernelBuildInfo>> *const kernel_info_list); std::vector<std::shared_ptr<KernelBuildInfo>> *const kernel_info_list);
void SaveJsonInfo(const std::string &json_name, const std::string &info, const std::string &base_path = kCceKernelMeta); void SaveJsonInfo(const std::string &json_name, const std::string &info, const std::string &base_path = kCceKernelMeta);

View File

@ -19,9 +19,8 @@
#include "utils/ms_context.h" #include "utils/ms_context.h"
namespace mindspore { namespace mindspore {
namespace kernel { namespace kernel {
bool HcomReceiveKernel::Launch(const std::vector<AddressPtr> & /*inputs*/, bool HcomReceiveKernel::Launch(const std::vector<AddressPtr> &, const std::vector<AddressPtr> &,
const std::vector<AddressPtr> & /*workspace*/, const std::vector<AddressPtr> &, void *) {
const std::vector<AddressPtr> & /*outputs*/, void * /*stream_ptr*/) {
MS_LOG(INFO) << "HcomReceive launch"; MS_LOG(INFO) << "HcomReceive launch";
return true; return true;
} }

View File

@ -20,8 +20,8 @@
namespace mindspore { namespace mindspore {
namespace kernel { namespace kernel {
bool HcomSendKernel::Launch(const std::vector<AddressPtr> & /*inputs*/, const std::vector<AddressPtr> & /*workspace*/, bool HcomSendKernel::Launch(const std::vector<AddressPtr> &, const std::vector<AddressPtr> &,
const std::vector<AddressPtr> & /*outputs*/, void * /*stream_ptr*/) { const std::vector<AddressPtr> &, void *) {
MS_LOG(INFO) << "HcomSend launch"; MS_LOG(INFO) << "HcomSend launch";
return true; return true;
} }

View File

@ -113,6 +113,7 @@ bool HcomUtil::GetHcomCount(const AnfNodePtr &anf_node, const vector<HcclDataTyp
size_t input_size; size_t input_size;
uint32_t type_size = 4; uint32_t type_size = 4;
size_t size = AnfAlgo::GetInputTensorNum(anf_node); size_t size = AnfAlgo::GetInputTensorNum(anf_node);
auto cnode = anf_node->cast<CNodePtr>();
if (AnfAlgo::GetCNodeName(anf_node) == kReceiveOpName) { if (AnfAlgo::GetCNodeName(anf_node) == kReceiveOpName) {
size = AnfAlgo::GetOutputTensorNum(anf_node); size = AnfAlgo::GetOutputTensorNum(anf_node);
} }
@ -128,7 +129,6 @@ bool HcomUtil::GetHcomCount(const AnfNodePtr &anf_node, const vector<HcclDataTyp
if (AnfAlgo::GetCNodeName(anf_node) == kReduceScatterOpName) { if (AnfAlgo::GetCNodeName(anf_node) == kReduceScatterOpName) {
int64_t rank_size; int64_t rank_size;
auto cnode = anf_node->cast<CNodePtr>();
auto primitive = AnfAlgo::GetCNodePrimitive(anf_node); auto primitive = AnfAlgo::GetCNodePrimitive(anf_node);
MS_EXCEPTION_IF_NULL(primitive); MS_EXCEPTION_IF_NULL(primitive);
if (primitive->GetAttr("rank_size") != nullptr) { if (primitive->GetAttr("rank_size") != nullptr) {
@ -145,7 +145,6 @@ bool HcomUtil::GetHcomCount(const AnfNodePtr &anf_node, const vector<HcclDataTyp
total_size = total_size + block_size; total_size = total_size + block_size;
} else { } else {
if (AnfAlgo::GetCNodeName(anf_node) == kAllGatherOpName) { if (AnfAlgo::GetCNodeName(anf_node) == kAllGatherOpName) {
auto cnode = anf_node->cast<CNodePtr>();
if (AnfAlgo::HasNodeAttr(kAttrFusion, cnode) && AnfAlgo::GetNodeAttr<int64_t>(anf_node, kAttrFusion) && if (AnfAlgo::HasNodeAttr(kAttrFusion, cnode) && AnfAlgo::GetNodeAttr<int64_t>(anf_node, kAttrFusion) &&
AnfAlgo::GetInputTensorNum(anf_node) > 1) { AnfAlgo::GetInputTensorNum(anf_node) > 1) {
block_size = (input_size + align_size - 1 + filled_size) / align_size * align_size; block_size = (input_size + align_size - 1 + filled_size) / align_size * align_size;
@ -177,8 +176,7 @@ bool HcomUtil::GetHcomOperationType(const AnfNodePtr &anf_node, HcclReduceOp *op
MS_LOG(ERROR) << "Get HCOM_ATTR_REDUCE_TYPE fail, not support!"; MS_LOG(ERROR) << "Get HCOM_ATTR_REDUCE_TYPE fail, not support!";
return false; return false;
} }
auto hcom_op_type_get = GetValue<const char *>(primitive->GetAttr("op")); auto hcom_op_type = GetValue<std::string>(primitive->GetAttr("op"));
string hcom_op_type(hcom_op_type_get);
if (hcom_op_type == "min") { if (hcom_op_type == "min") {
*op_type = HCCL_REDUCE_MIN; *op_type = HCCL_REDUCE_MIN;
} else if (hcom_op_type == "max") { } else if (hcom_op_type == "max") {

View File

@ -22,12 +22,13 @@
#include <utility> #include <utility>
#include "runtime/mem.h" #include "runtime/mem.h"
#include "utils/ms_context.h" #include "utils/ms_context.h"
#include "backend/kernel_compiler/common_utils.h"
#include "runtime/device/kernel_runtime.h" #include "runtime/device/kernel_runtime.h"
#include "runtime/device/ascend/executor/host_dynamic_kernel.h" #include "runtime/device/ascend/executor/host_dynamic_kernel.h"
namespace mindspore { namespace mindspore {
namespace kernel { namespace kernel {
void HostKernelFactory::Registe(const std::string &name, HostKernelCreater &&fun) { void HostKernelFactory::Register(const std::string &name, HostKernelCreater &&fun) {
hostKernelMap_.emplace(name, std::move(fun)); hostKernelMap_.emplace(name, std::move(fun));
} }
@ -56,16 +57,10 @@ bool HostKernelMod::Init(const AnfNodePtr &anf_node) {
for (size_t i = 0; i < input_num; i++) { for (size_t i = 0; i < input_num; i++) {
std::vector<size_t> shape_i = AnfAlgo::GetInputDeviceShape(anf_node, i); std::vector<size_t> shape_i = AnfAlgo::GetInputDeviceShape(anf_node, i);
TypePtr type_ptr = TypeIdToType(AnfAlgo::GetInputDeviceDataType(anf_node, i)); TypePtr type_ptr = TypeIdToType(AnfAlgo::GetInputDeviceDataType(anf_node, i));
MS_EXCEPTION_IF_NULL(type_ptr);
int64_t size_i = 1; int64_t size_i = 1;
for (size_t j = 0; j < shape_i.size(); j++) { if (!GetShapeSize(shape_i, type_ptr, &size_i)) {
size_i = LongMulWithOverflowCheck(size_i, static_cast<int>(shape_i[j]));
}
size_t type_byte = GetTypeByte(type_ptr);
if (type_byte == 0) {
return false; return false;
} }
size_i = LongMulWithOverflowCheck(size_i, SizeToInt(type_byte));
input_size_list_.push_back(LongToSize(size_i)); input_size_list_.push_back(LongToSize(size_i));
} }
@ -74,14 +69,9 @@ bool HostKernelMod::Init(const AnfNodePtr &anf_node) {
TypePtr type_ptr = TypeIdToType(AnfAlgo::GetOutputDeviceDataType(anf_node, i)); TypePtr type_ptr = TypeIdToType(AnfAlgo::GetOutputDeviceDataType(anf_node, i));
MS_EXCEPTION_IF_NULL(type_ptr); MS_EXCEPTION_IF_NULL(type_ptr);
int64_t size_i = 1; int64_t size_i = 1;
for (size_t j = 0; j < shape_i.size(); j++) { if (!GetShapeSize(shape_i, type_ptr, &size_i)) {
size_i = LongMulWithOverflowCheck(size_i, static_cast<int>(shape_i[j]));
}
size_t type_byte = GetTypeByte(type_ptr);
if (type_byte == 0) {
return false; return false;
} }
size_i = LongMulWithOverflowCheck(size_i, SizeToInt(type_byte));
output_size_list_.push_back(LongToSize(size_i)); output_size_list_.push_back(LongToSize(size_i));
} }
return true; return true;

View File

@ -55,7 +55,7 @@ class HostKernelFactory {
public: public:
static HostKernelFactory &Get(); static HostKernelFactory &Get();
void Registe(const string &name, HostKernelCreater &&fun); void Register(const string &name, HostKernelCreater &&fun);
static std::shared_ptr<HostKernelMod> Get(const string &name); static std::shared_ptr<HostKernelMod> Get(const string &name);
private: private:
@ -65,7 +65,7 @@ class HostKernelFactory {
class _HostKernelRegister { class _HostKernelRegister {
public: public:
_HostKernelRegister(const string &name, HostKernelCreater &&fun) { _HostKernelRegister(const string &name, HostKernelCreater &&fun) {
HostKernelFactory::Get().Registe(name, std::move(fun)); HostKernelFactory::Get().Register(name, std::move(fun));
} }
~_HostKernelRegister() = default; ~_HostKernelRegister() = default;
}; };

View File

@ -106,7 +106,7 @@ std::vector<size_t> TransShapeToSizet(const abstract::ShapePtr &shape) {
return shape_size_t; return shape_size_t;
} }
enum ShapeType { kMaxShape, kMinShape }; enum class ShapeType { kMaxShape, kMinShape };
void GetRealOutputRecursively(const AnfNodePtr &node, size_t output_index, void GetRealOutputRecursively(const AnfNodePtr &node, size_t output_index,
std::vector<session::KernelWithIndex> *inputs) { std::vector<session::KernelWithIndex> *inputs) {
@ -1102,19 +1102,19 @@ void AnfRuntimeAlgorithm::SetOutputInferTypeAndShape(const std::vector<TypeId> &
MS_LOG(EXCEPTION) << "Types size " << types.size() << "should be same with shapes size " << shapes.size() MS_LOG(EXCEPTION) << "Types size " << types.size() << "should be same with shapes size " << shapes.size()
<< " trace: " << trace::DumpSourceLines(node); << " trace: " << trace::DumpSourceLines(node);
} }
auto abstract_ptr = node_ptr->abstract();
if (shapes.empty()) { if (shapes.empty()) {
node->set_abstract(std::make_shared<abstract::AbstractNone>()); node->set_abstract(std::make_shared<abstract::AbstractNone>());
} else if (shapes.size() == 1) { } else if (shapes.size() == 1) {
// single output handle // single output handle
ShapeVector shape_int; ShapeVector shape_int;
auto abstract_ptr = node_ptr->abstract();
abstract::AbstractTensorPtr abstract = nullptr; abstract::AbstractTensorPtr abstract = nullptr;
if (abstract_ptr != nullptr) { if (abstract_ptr != nullptr) {
auto max_shape = GetOutputMaxShape(node_ptr, 0); auto max_shape0 = GetOutputMaxShape(node_ptr, 0);
auto min_shape = GetOutputMinShape(node_ptr, 0); auto min_shape0 = GetOutputMinShape(node_ptr, 0);
std::transform(shapes[0].begin(), shapes[0].end(), std::back_inserter(shape_int), SizeToLong); std::transform(shapes[0].begin(), shapes[0].end(), std::back_inserter(shape_int), SizeToLong);
abstract = std::make_shared<AbstractTensor>(TypeIdToType(types[0]), abstract = std::make_shared<AbstractTensor>(TypeIdToType(types[0]),
std::make_shared<abstract::Shape>(shape_int, min_shape, max_shape)); std::make_shared<abstract::Shape>(shape_int, min_shape0, max_shape0));
} else { } else {
abstract = std::make_shared<AbstractTensor>(TypeIdToType(types[0]), shape_int); abstract = std::make_shared<AbstractTensor>(TypeIdToType(types[0]), shape_int);
} }
@ -1124,7 +1124,6 @@ void AnfRuntimeAlgorithm::SetOutputInferTypeAndShape(const std::vector<TypeId> &
std::vector<AbstractBasePtr> abstract_list; std::vector<AbstractBasePtr> abstract_list;
for (size_t i = 0; i < types.size(); ++i) { for (size_t i = 0; i < types.size(); ++i) {
ShapeVector shape_int; ShapeVector shape_int;
auto abstract_ptr = node_ptr->abstract();
abstract::AbstractTensorPtr abstract = nullptr; abstract::AbstractTensorPtr abstract = nullptr;
if (abstract_ptr != nullptr) { if (abstract_ptr != nullptr) {
auto max_shape = GetOutputMaxShape(node_ptr, i); auto max_shape = GetOutputMaxShape(node_ptr, i);
@ -1800,7 +1799,7 @@ std::vector<int64_t> GetShapeFromSequeueShape(const abstract::SequeueShapePtr &s
MS_EXCEPTION_IF_NULL(shape); MS_EXCEPTION_IF_NULL(shape);
if (shape->isa<abstract::Shape>()) { if (shape->isa<abstract::Shape>()) {
auto shape_ptr = shape->cast<abstract::ShapePtr>(); auto shape_ptr = shape->cast<abstract::ShapePtr>();
if (type == kMaxShape) { if (type == ShapeType::kMaxShape) {
return shape_ptr->max_shape().empty() ? shape_ptr->shape() : shape_ptr->max_shape(); return shape_ptr->max_shape().empty() ? shape_ptr->shape() : shape_ptr->max_shape();
} else { } else {
return shape_ptr->min_shape().empty() ? shape_ptr->shape() : shape_ptr->min_shape(); return shape_ptr->min_shape().empty() ? shape_ptr->shape() : shape_ptr->min_shape();
@ -1828,8 +1827,8 @@ std::vector<int64_t> AnfRuntimeAlgorithm::GetOutputMaxShape(const AnfNodePtr &an
auto shape_ptr = shape->cast<abstract::ShapePtr>(); auto shape_ptr = shape->cast<abstract::ShapePtr>();
return shape_ptr->max_shape().empty() ? shape_ptr->shape() : shape_ptr->max_shape(); return shape_ptr->max_shape().empty() ? shape_ptr->shape() : shape_ptr->max_shape();
} else if (shape->isa<abstract::SequeueShape>()) { } else if (shape->isa<abstract::SequeueShape>()) {
auto shape_ptr = shape->cast<abstract::SequeueShapePtr>(); auto sequeue_shape_ptr = shape->cast<abstract::SequeueShapePtr>();
return GetShapeFromSequeueShape(shape_ptr, index, kMaxShape); return GetShapeFromSequeueShape(sequeue_shape_ptr, index, ShapeType::kMaxShape);
} else if (shape->isa<abstract::NoShape>()) { } else if (shape->isa<abstract::NoShape>()) {
return {}; return {};
} else { } else {
@ -1846,8 +1845,8 @@ std::vector<int64_t> AnfRuntimeAlgorithm::GetOutputMinShape(const AnfNodePtr &an
auto shape_ptr = shape->cast<abstract::ShapePtr>(); auto shape_ptr = shape->cast<abstract::ShapePtr>();
return shape_ptr->min_shape().empty() ? shape_ptr->shape() : shape_ptr->min_shape(); return shape_ptr->min_shape().empty() ? shape_ptr->shape() : shape_ptr->min_shape();
} else if (shape->isa<abstract::SequeueShape>()) { } else if (shape->isa<abstract::SequeueShape>()) {
auto shape_ptr = shape->cast<abstract::SequeueShapePtr>(); auto sequeue_shape_ptr = shape->cast<abstract::SequeueShapePtr>();
return GetShapeFromSequeueShape(shape_ptr, index, kMinShape); return GetShapeFromSequeueShape(sequeue_shape_ptr, index, ShapeType::kMinShape);
} else if (shape->isa<abstract::NoShape>()) { } else if (shape->isa<abstract::NoShape>()) {
return {}; return {};
} else { } else {