Return TensorShape that describes the Tensorflow shape of the tensor represented by this MklShape.
| 395 | /// Return TensorShape that describes the Tensorflow shape of the tensor |
| 396 | /// represented by this MklShape. |
| 397 | inline TensorShape GetTfShape() const { |
| 398 | CHECK_EQ(data_.is_mkl_tensor_, true); |
| 399 | |
| 400 | std::vector<int32> shape(data_.dimension_, -1); |
| 401 | // As mentioned in the comment above, we now rely on TF's `data_format` |
| 402 | // attribute to determine if TF shape is in blocked format or not. |
| 403 | if (data_.tf_data_format_ != MklTensorFormat::FORMAT_BLOCKED) { |
| 404 | for (size_t idx = 0; idx < data_.dimension_; ++idx) { |
| 405 | shape[idx] = data_.sizes_[TfDimIdx(idx)]; |
| 406 | } |
| 407 | } else { |
| 408 | // If Tensorflow shape is in Blocked format, then we don't have dimension |
| 409 | // map for it. So we just create Tensorflow shape from sizes in the |
| 410 | // specified order. |
| 411 | for (size_t idx = 0; idx < data_.dimension_; ++idx) { |
| 412 | shape[idx] = data_.sizes_[idx]; |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | TensorShape ts; |
| 417 | bool ret = TensorShapeUtils::MakeShape(shape, &ts).ok(); |
| 418 | CHECK_EQ(ret, true); |
| 419 | return ts; |
| 420 | } |
| 421 | |
| 422 | inline void SetElemType(memory::data_type dt) { data_.T_ = dt; } |
| 423 | inline const memory::data_type GetElemType() { return data_.T_; } |