From 3b7c96afa4c27ee95631b8a44a0150b9430e35dd Mon Sep 17 00:00:00 2001 From: jianghui58 Date: Tue, 30 Mar 2021 10:03:32 +0800 Subject: [PATCH] tensor data type support string && tensor --- mindspore/core/ir/tensor.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mindspore/core/ir/tensor.cc b/mindspore/core/ir/tensor.cc index 5c9578496b..2a18854d25 100644 --- a/mindspore/core/ir/tensor.cc +++ b/mindspore/core/ir/tensor.cc @@ -447,6 +447,10 @@ TensorDataPtr MakeTensorData(TypeId data_type, const ShapeVector &shape, const A return std::make_shared>(shape, args...); case kNumberTypeFloat64: return std::make_shared>(shape, args...); + case kObjectTypeString: + return std::make_shared>(shape, args...); + case kObjectTypeTensorType: + return std::make_shared>(shape, args...); default: break; } @@ -549,8 +553,8 @@ Tensor &Tensor::AssignValue(const Tensor &tensor) { abstract::AbstractBasePtr Tensor::ToAbstract() { auto tens = shared_from_base(); auto dtype = tens->Dtype(); - if (!IsSubType(dtype, kNumber)) { - MS_LOG(EXCEPTION) << "Expect tensor type kNumber but got: " << dtype->ToString() << "."; + if (!IsSubType(dtype, kNumber) && !IsSubType(dtype, kString) && !IsSubType(dtype, kTensorType)) { + MS_LOG(EXCEPTION) << "Expect tensor type kNumber or kString or kTensor but got: " << dtype->ToString() << "."; } auto tensor_shape = tens->shape(); auto abs_tensor = std::make_shared(dtype, tensor_shape);