| 635 | } |
| 636 | |
| 637 | Status DimensionsFromShape(ShapeHandle shape, TensorFormat format, |
| 638 | DimensionHandle* batch_dim, |
| 639 | gtl::MutableArraySlice<DimensionHandle> spatial_dims, |
| 640 | DimensionHandle* filter_dim, |
| 641 | InferenceContext* context) { |
| 642 | const int32 rank = GetTensorDimsFromSpatialDims(spatial_dims.size(), format); |
| 643 | // Batch. |
| 644 | *batch_dim = context->Dim(shape, GetTensorBatchDimIndex(rank, format)); |
| 645 | // Spatial. |
| 646 | for (int spatial_dim_index = 0; spatial_dim_index < spatial_dims.size(); |
| 647 | ++spatial_dim_index) { |
| 648 | spatial_dims[spatial_dim_index] = context->Dim( |
| 649 | shape, GetTensorSpatialDimIndex(rank, format, spatial_dim_index)); |
| 650 | } |
| 651 | // Channel. |
| 652 | *filter_dim = context->Dim(shape, GetTensorFeatureDimIndex(rank, format)); |
| 653 | if (format == FORMAT_NCHW_VECT_C) { |
| 654 | TF_RETURN_IF_ERROR(context->Multiply( |
| 655 | *filter_dim, |
| 656 | context->Dim(shape, GetTensorInnerFeatureDimIndex(rank, format)), |
| 657 | filter_dim)); |
| 658 | } |
| 659 | return Status::OK(); |
| 660 | } |
| 661 | |
| 662 | Status ShapeFromDimensions(DimensionHandle batch_dim, |
| 663 | gtl::ArraySlice<DimensionHandle> spatial_dims, |
no test coverage detected