xref: /aosp_15_r20/external/tensorflow/tensorflow/compiler/xla/service/dynamic_window_utils.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_COMPILER_XLA_SERVICE_DYNAMIC_WINDOW_UTILS_H_
17 #define TENSORFLOW_COMPILER_XLA_SERVICE_DYNAMIC_WINDOW_UTILS_H_
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 #include "tensorflow/compiler/xla/service/hlo_instruction.h"
24 #include "tensorflow/compiler/xla/service/hlo_module.h"
25 #include "tensorflow/compiler/xla/status.h"
26 #include "tensorflow/compiler/xla/statusor.h"
27 #include "tensorflow/compiler/xla/types.h"
28 namespace xla {
29 struct DynamicWindowDims {
30   HloInstruction* padding_before;
31   HloInstruction* output_size;
32 };
33 
34 // This mirrors the logic in GetWindowedOutputSizeVerboseV2 but with HLOs as
35 // inputs and outputs.
36 DynamicWindowDims GetWindowedOutputSize(HloInstruction* input_size,
37                                         int64_t window_size,
38                                         int64_t window_dilation,
39                                         int64_t window_stride,
40                                         PaddingType padding_type);
41 
42 DynamicWindowDims GetWindowedInputGradSize(HloInstruction* input_size,
43                                            int64_t window_size,
44                                            int64_t window_dilation,
45                                            int64_t window_stride,
46                                            PaddingType padding_type);
47 
48 }  // namespace xla
49 
50 #endif  // TENSORFLOW_COMPILER_XLA_SERVICE_DYNAMIC_WINDOW_UTILS_H_
51