| 660 | } |
| 661 | |
| 662 | Status ShapeFromDimensions(DimensionHandle batch_dim, |
| 663 | gtl::ArraySlice<DimensionHandle> spatial_dims, |
| 664 | DimensionHandle filter_dim, TensorFormat format, |
| 665 | InferenceContext* context, ShapeHandle* shape) { |
| 666 | const int32 rank = GetTensorDimsFromSpatialDims(spatial_dims.size(), format); |
| 667 | std::vector<DimensionHandle> out_dims(rank); |
| 668 | |
| 669 | // Batch. |
| 670 | out_dims[tensorflow::GetTensorBatchDimIndex(rank, format)] = batch_dim; |
| 671 | // Spatial. |
| 672 | for (int spatial_dim_index = 0; spatial_dim_index < spatial_dims.size(); |
| 673 | ++spatial_dim_index) { |
| 674 | out_dims[tensorflow::GetTensorSpatialDimIndex( |
| 675 | rank, format, spatial_dim_index)] = spatial_dims[spatial_dim_index]; |
| 676 | } |
| 677 | // Channel. |
| 678 | if (format == tensorflow::FORMAT_NCHW_VECT_C) { |
| 679 | // When format is NCHW_VECT_C, factor the feature map count |
| 680 | // into the outer feature count and the inner feature count (=4). |
| 681 | TF_RETURN_IF_ERROR(context->Divide( |
| 682 | filter_dim, 4, /*evenly_divisible=*/true, |
| 683 | &out_dims[tensorflow::GetTensorFeatureDimIndex(rank, format)])); |
| 684 | out_dims[GetTensorInnerFeatureDimIndex(rank, format)] = context->MakeDim(4); |
| 685 | } else { |
| 686 | out_dims[tensorflow::GetTensorFeatureDimIndex(rank, format)] = filter_dim; |
| 687 | } |
| 688 | |
| 689 | *shape = context->MakeShape(out_dims); |
| 690 | return tensorflow::Status::OK(); |
| 691 | } |
| 692 | |
| 693 | namespace { |
| 694 |
no test coverage detected