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

Function DimensionsFromShape

tensorflow/core/framework/common_shape_fns.cc:637–660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

635}
636
637Status 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
662Status ShapeFromDimensions(DimensionHandle batch_dim,
663 gtl::ArraySlice<DimensionHandle> spatial_dims,

Callers 1

Conv2DShapeImplFunction · 0.85

Calls 8

GetTensorBatchDimIndexFunction · 0.85
GetTensorSpatialDimIndexFunction · 0.85
GetTensorFeatureDimIndexFunction · 0.85
MultiplyMethod · 0.80
sizeMethod · 0.45
DimMethod · 0.45

Tested by

no test coverage detected