MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ShapeFromDimensions

Function ShapeFromDimensions

tensorflow/core/framework/common_shape_fns.cc:662–691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

660}
661
662Status 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
693namespace {
694

Callers 1

Conv2DShapeImplFunction · 0.85

Calls 9

GetTensorBatchDimIndexFunction · 0.85
GetTensorSpatialDimIndexFunction · 0.85
GetTensorFeatureDimIndexFunction · 0.85
sizeMethod · 0.45
DivideMethod · 0.45
MakeDimMethod · 0.45
MakeShapeMethod · 0.45

Tested by

no test coverage detected