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

Function Pool3DShape

tensorflow/core/framework/common_shape_fns.cc:1411–1491  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1409}
1410
1411Status Pool3DShape(shape_inference::InferenceContext* c) {
1412 ShapeHandle input_shape;
1413 TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 5, &input_shape));
1414
1415 string data_format;
1416 Status s = c->GetAttr("data_format", &data_format);
1417
1418 std::vector<int32> strides;
1419 TF_RETURN_IF_ERROR(c->GetAttr("strides", &strides));
1420 if (strides.size() != 5) {
1421 return errors::InvalidArgument(
1422 "Pool3D ops require the stride attribute to contain 5 values, but "
1423 "got: ",
1424 strides.size());
1425 }
1426
1427 std::vector<int32> kernel_sizes;
1428 TF_RETURN_IF_ERROR(c->GetAttr("ksize", &kernel_sizes));
1429 if (kernel_sizes.size() != 5) {
1430 return errors::InvalidArgument(
1431 "Pool3D requires the ksize attribute to contain 5 values, but got: ",
1432 kernel_sizes.size());
1433 }
1434
1435 int32 stride_planes, stride_rows, stride_cols;
1436 int32 kernel_planes, kernel_rows, kernel_cols;
1437
1438 if (s.ok() && data_format == "NCDHW") {
1439 // Convert input_shape to NDHWC.
1440 auto dim = [&](char dimension) {
1441 return c->Dim(input_shape, GetTensorDimIndex<3>(FORMAT_NCHW, dimension));
1442 };
1443 input_shape =
1444 c->MakeShape({{dim('N'), dim('0'), dim('1'), dim('2'), dim('C')}});
1445 stride_planes = strides[2];
1446 stride_rows = strides[3];
1447 stride_cols = strides[4];
1448 kernel_planes = kernel_sizes[2];
1449 kernel_rows = kernel_sizes[3];
1450 kernel_cols = kernel_sizes[4];
1451 } else {
1452 stride_planes = strides[1];
1453 stride_rows = strides[2];
1454 stride_cols = strides[3];
1455 kernel_planes = kernel_sizes[1];
1456 kernel_rows = kernel_sizes[2];
1457 kernel_cols = kernel_sizes[3];
1458 }
1459
1460 DimensionHandle batch_size_dim = c->Dim(input_shape, 0);
1461 DimensionHandle in_planes_dim = c->Dim(input_shape, 1);
1462 DimensionHandle in_rows_dim = c->Dim(input_shape, 2);
1463 DimensionHandle in_cols_dim = c->Dim(input_shape, 3);
1464 DimensionHandle output_depth_dim = c->Dim(input_shape, 4);
1465
1466 Padding padding;
1467 TF_RETURN_IF_ERROR(c->GetAttr("padding", &padding));
1468

Callers 1

nn_ops.ccFile · 0.85

Calls 11

InvalidArgumentFunction · 0.85
dimEnum · 0.50
WithRankMethod · 0.45
inputMethod · 0.45
GetAttrMethod · 0.45
sizeMethod · 0.45
okMethod · 0.45
DimMethod · 0.45
MakeShapeMethod · 0.45
set_outputMethod · 0.45

Tested by

no test coverage detected