forked from huawei/mindspore2022
!14999 fix ci bug nullptr on type id
From: @simson_wu Reviewed-by: @zhoufeng54,@xsmq Signed-off-by: @xsmq
This commit is contained in:
commit
c5b9b1b53a
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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…
Reference in New Issue