| 161 | } |
| 162 | |
| 163 | Status OpKernel::MakeShape(const Tensor& shape, TensorShape* out) const { |
| 164 | if (!IsLegacyVector(shape.shape())) { |
| 165 | return errors::InvalidArgument( |
| 166 | "shape must be a vector of {int32,int64}, got shape ", |
| 167 | shape.shape().DebugString()); |
| 168 | } |
| 169 | if (shape.dtype() == DataType::DT_INT32) { |
| 170 | auto vec = shape.flat<int32>(); |
| 171 | return TensorShapeUtils::MakeShape(vec.data(), vec.size(), out); |
| 172 | } else if (shape.dtype() == DataType::DT_INT64) { |
| 173 | auto vec = shape.flat<int64>(); |
| 174 | return TensorShapeUtils::MakeShape(vec.data(), vec.size(), out); |
| 175 | } else { |
| 176 | return errors::InvalidArgument("shape must be a vector of {int32,int64}."); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | void AsyncOpKernel::Compute(OpKernelContext* context) { |
| 181 | Notification n; |