| 49 | typedef typename gtl::InlinedVector<int64, 8> ShapeArray; |
| 50 | |
| 51 | static Status Create(Tensor ix, Tensor vals, const VarDimArray shape, |
| 52 | const VarDimArray order, SparseTensor* result) { |
| 53 | if (ix.dtype() != DT_INT64) { |
| 54 | return Status( |
| 55 | error::INVALID_ARGUMENT, |
| 56 | strings::StrCat("indices must be type int64 but got: ", ix.dtype())); |
| 57 | } |
| 58 | if (!TensorShapeUtils::IsVector(vals.shape())) { |
| 59 | return Status(error::INVALID_ARGUMENT, |
| 60 | strings::StrCat("vals must be a vec, but got: ", |
| 61 | vals.shape().DebugString())); |
| 62 | } |
| 63 | if (ix.shape().dim_size(0) != vals.shape().dim_size(0)) { |
| 64 | return Status(error::INVALID_ARGUMENT, |
| 65 | strings::StrCat("indices and values rows (indexing " |
| 66 | "dimension) must match. (indices = ", |
| 67 | ix.shape().dim_size(0), ", values = ", |
| 68 | vals.shape().dim_size(0), ")")); |
| 69 | } |
| 70 | int dims = 0; |
| 71 | TF_RETURN_IF_ERROR(GetDimsFromIx(ix, &dims)); |
| 72 | if (order.size() != dims) { |
| 73 | return Status(error::INVALID_ARGUMENT, |
| 74 | "Order length must be SparseTensor rank."); |
| 75 | } |
| 76 | if (shape.size() != dims) { |
| 77 | return Status(error::INVALID_ARGUMENT, |
| 78 | "Shape rank must be SparseTensor rank."); |
| 79 | } |
| 80 | |
| 81 | *result = SparseTensor(ix, vals, shape, order); |
| 82 | return Status(); |
| 83 | } |
| 84 | |
| 85 | static Status Create(Tensor ix, Tensor vals, const TensorShape& shape, |
| 86 | SparseTensor* result) { |