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

Function ComputeSums

tensorflow/compiler/xla/client/lib/pooling.cc:73–86  ·  view source on GitHub ↗

Sums all elements in the window specified by 'kernel_size' and 'stride'.

Source from the content-addressed store, hash-verified

71
72// Sums all elements in the window specified by 'kernel_size' and 'stride'.
73XlaOp ComputeSums(XlaOp operand, XlaOp init_value,
74 absl::Span<const int64> kernel_size,
75 absl::Span<const int64> stride,
76 const TensorFormat& data_format) {
77 XlaBuilder* b = operand.builder();
78 return b->ReportErrorOrReturn([&]() -> StatusOr<XlaOp> {
79 TF_ASSIGN_OR_RETURN(Shape operand_shape, b->GetShape(operand));
80 TF_ASSIGN_OR_RETURN(Shape init_shape, b->GetShape(init_value));
81 PrimitiveType accumulation_type = init_shape.element_type();
82 auto add_computation = CreateScalarAddComputation(accumulation_type, b);
83 return ReduceWindow(operand, init_value, add_computation, kernel_size,
84 stride, Padding::kValid);
85 });
86}
87
88// Creates a padding configuration out of spatial padding values.
89PaddingConfig MakeSpatialPaddingConfig(

Callers 1

AvgPoolFunction · 0.85

Calls 5

ReduceWindowFunction · 0.85
ReportErrorOrReturnMethod · 0.80
builderMethod · 0.45
element_typeMethod · 0.45

Tested by

no test coverage detected