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

Function MakeShapeFromFormat

tensorflow/core/framework/common_shape_fns.cc:613–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611}
612
613Status MakeShapeFromFormat(TensorFormat format, DimensionOrConstant N,
614 const std::vector<DimensionOrConstant>& spatial,
615 DimensionOrConstant C, ShapeHandle* out,
616 shape_inference::InferenceContext* context) {
617 const int num_dims = GetTensorDimsFromSpatialDims(spatial.size(), format);
618 std::vector<DimensionHandle> dims_actual(num_dims);
619 dims_actual[GetTensorBatchDimIndex(num_dims, format)] = context->MakeDim(N);
620 int outer_c_index = GetTensorFeatureDimIndex(num_dims, format);
621 dims_actual[outer_c_index] = context->MakeDim(C);
622 if (format == FORMAT_NCHW_VECT_C) {
623 dims_actual[GetTensorInnerFeatureDimIndex(num_dims, format)] =
624 context->MakeDim(4);
625 } else if (format == FORMAT_NHWC_VECT_W) {
626 dims_actual[GetTensorInnerWidthDimIndex(num_dims, format)] =
627 context->MakeDim(4);
628 }
629 for (int spatial_dim = 0; spatial_dim < spatial.size(); spatial_dim++) {
630 dims_actual[GetTensorSpatialDimIndex(num_dims, format, spatial_dim)] =
631 context->MakeDim(spatial[spatial_dim]);
632 }
633 *out = context->MakeShape(dims_actual);
634 return Status::OK();
635}
636
637Status DimensionsFromShape(ShapeHandle shape, TensorFormat format,
638 DimensionHandle* batch_dim,

Callers 4

array_ops.ccFile · 0.85
AvgPoolShapeFunction · 0.85
MaxPoolShapeFunction · 0.85
MaxPoolV2ShapeFunction · 0.85

Calls 9

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

Tested by

no test coverage detected