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

Function CheckValidPadding

tensorflow/core/util/padding.cc:40–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40Status CheckValidPadding(Padding padding_type,
41 const std::vector<int64>& explicit_paddings,
42 int num_dims, TensorFormat data_format) {
43 if (padding_type == Padding::EXPLICIT) {
44 if (explicit_paddings.size() != 2 * num_dims) {
45 return errors::InvalidArgument(
46 "explicit_paddings attribute must contain ", 2 * num_dims,
47 " values, but got: ", explicit_paddings.size());
48 }
49 for (int64 padding_value : explicit_paddings) {
50 if (padding_value < 0) {
51 return errors::InvalidArgument(
52 "All elements of explicit_paddings must be nonnegative");
53 }
54 }
55 const int32 batch_index = GetTensorBatchDimIndex(num_dims, data_format);
56 const int32 depth_index = GetTensorFeatureDimIndex(num_dims, data_format);
57 if (explicit_paddings[2 * batch_index] != 0 ||
58 explicit_paddings[2 * batch_index + 1] != 0 ||
59 explicit_paddings[2 * depth_index] != 0 ||
60 explicit_paddings[2 * depth_index + 1] != 0) {
61 return errors::InvalidArgument(
62 "Nonzero explicit padding in the batch or depth dimensions is not "
63 "supported");
64 }
65 } else if (!explicit_paddings.empty()) {
66 return errors::InvalidArgument(
67 "explicit_paddings attribute must be empty if the padding attribute is "
68 "not EXPLICIT");
69 }
70 return Status::OK();
71}
72
73string GetPaddingAttrString() { return "padding: {'SAME', 'VALID'}"; }
74

Callers 6

Conv2DShapeImplFunction · 0.85
InitConv2DParametersFunction · 0.85
Conv2DBackpropInputOpMethod · 0.85

Calls 5

InvalidArgumentFunction · 0.85
GetTensorBatchDimIndexFunction · 0.85
GetTensorFeatureDimIndexFunction · 0.85
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected