!49128 fix aicpu op SparseToDenseV2

Merge pull request !49128 from yanzhenxiang2020/fix_aicpu_sparsetodensev2
This commit is contained in:
i-robot 2023-02-21 01:38:56 +00:00 committed by Gitee
commit d18529fc0c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 4 additions and 2 deletions

View File

@ -760,6 +760,7 @@ constexpr auto kSparseTensorDenseMatmulOpName = "SparseTensorDenseMatmul";
constexpr auto kSparseTensorDenseAddOpName = "SparseTensorDenseAdd";
constexpr auto kSparseTensorToCSRSparseMatrixOpName = "SparseTensorToCSRSparseMatrix";
constexpr auto kSparseToDenseOpName = "SparseToDense";
constexpr auto kSparseToDenseV2OpName = "SparseToDenseV2";
constexpr auto kSplitOpName = "Split";
constexpr auto kSplitDOpName = "SplitD";
constexpr auto kSplitVOpName = "SplitV";

View File

@ -147,7 +147,7 @@ KernelStatus SparseToDenseCpuKernel::ValidParam(const CpuKernelContext &ctx) {
}
// default_value
if (default_value_shape->GetDims() != 0) {
if (default_value_shape->GetDims() != 0 && default_value_tensor->NumElements() != 1) {
KERNEL_LOG_ERROR("Default_value should be a scalar, and got dim size [%d].", default_value_shape->GetDims());
return KERNEL_STATUS_PARAM_INVALID;
}

View File

@ -323,7 +323,7 @@ bool AICpuLibSelectPass::Process(const AnfNodePtr &node) const {
mindspore::kMultiMarginLossGradOpName,
mindspore::kSspaddmmOpName,
mindspore::kBatchMatMulOpName,
mindspore::kSparseToDenseOpName,
mindspore::kSparseToDenseV2OpName,
mindspore::kTrilOpName,
mindspore::kBernoulliOpName};

View File

@ -505,6 +505,7 @@ class SparseToDenseV2(Primitive):
"""Initialize SparseToDenseV2."""
self.add_prim_attr("max_length", 1000000)
self.validate_indices = validate_indices
validator.check_value_type('validate_indices', validate_indices, [bool], self.name)
self.add_prim_attr("validate_indices", self.validate_indices)
self.init_prim_io_names(
inputs=['indices', 'output_shape', 'values', 'default_value'], outputs=['output'])