Browse Source

fix ci bug nullptr on type id

pull/14999/head
simson 4 years ago
parent
commit
d0766d2aad
2 changed files with 10 additions and 2 deletions
  1. +8
    -2
      mindspore/core/utils/tensor_construct_utils.cc
  2. +2
    -0
      mindspore/core/utils/tensor_construct_utils.h

+ 8
- 2
mindspore/core/utils/tensor_construct_utils.cc View File

@@ -53,8 +53,14 @@ tensor::TensorPtr TensorConstructUtils::CreateTensor(const TypePtr type_ptr, con

TypeId TensorConstructUtils::ExtractTypeId(const TypePtr type_ptr) {
MS_EXCEPTION_IF_NULL(type_ptr);
auto tensor_type = type_ptr->cast<TensorTypePtr>();
auto type_id = tensor_type->element()->type_id();
TypeId type_id;
if (type_ptr->isa<TensorType>()) {
auto tensor_type = type_ptr->cast<TensorTypePtr>();
MS_EXCEPTION_IF_NULL(tensor_type);
type_id = tensor_type->element()->type_id();
} else {
type_id = type_ptr->type_id();
}
return type_id;
}
} // namespace mindspore

+ 2
- 0
mindspore/core/utils/tensor_construct_utils.h View File

@@ -33,6 +33,8 @@ class TensorConstructUtils {
static tensor::TensorPtr CreateZerosTensor(const TypePtr type, const std::vector<int64_t> &shape);
static tensor::TensorPtr CreateOnesTensor(const TypePtr type, const std::vector<int64_t> &shape);
static tensor::TensorPtr CreateTensor(const TypePtr type, const std::vector<int64_t> &shape, void *data);

private:
static TypeId ExtractTypeId(const TypePtr type);
};
} // namespace mindspore


Loading…
Cancel
Save