reduce_window_test.cc
Google Test frameworkimports tsl/platform/errors.h
SHA-256a6bfffd5c30a1b45c776b68558c67a9579fa9006e6617cffc3f525ae8904accb
MaleculeMd₂(In₃Pa)
Evidence
1/* Copyright 2017 The OpenXLA Authors.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is …
14:77… ==*/
15
16// Tests the reduce-window XLA operation.
17
18#include <algorithm>
19#include <array>
20#include <cstdint>
21#include <iterator>
22#include <memory>
23#include <numeric>
24#include <optional>
25#include <string>
26#include <utility>
27#include <vector>
28
29#include "xla/tests/xla_test_backend_predicates.h"
30#include <gtest/gtest.h>
31#include "absl/log/check.h"
32#include "absl/strings/str_cat.h"
33#include "absl/strings/str_join.h"
34#include "absl/types/span.h"
35#include "xla/array2d.h"
36#include "xla/array3d.h"
37#include "xla/array4d.h"
38#include "xla/error_spec.h"
39#include "xla/hlo/builder/lib/arithmetic.h"
40#include "xla/hlo/builder/padding.h"
41#include "xla/hlo/builder/xla_builder.h"
42#include "xla/hlo/builder/xla_computation.h"
43#include "xla/layout_util.h"
44#include "xla/literal.h"
45#include "xla/literal_util.h"
46#include "xla/primitive_util.h"
47#include "xla/reference_util.h"
48#include "xla/shape.h"
49#include "xla/shape_util.h"
50#include "xla/tests/client_library_test_base.h"
51#include "xla/tests/hlo_test_base.h"
52#include "xla/tsl/lib/core/status_test_util.h"
53#include "xla/xla_data.pb.h"
54#include "tsl/platform/errors.h"
55#include "tsl/platform/statusor.h"
56#include "tsl/platform/test.h"
57
58namespace xla {
59namespace {
60
61static std::array<PrimitiveType, 2> test_type_params = {F32, BF16};
123:41… 2},
124 /*window_strides=*/{1}, Padding::kValid);
125 ASSERT_EQ(builder_.first_error().code(), tsl::error::INVALID_ARGUMENT)
126 << builder_.first_error();
127 ASSERT_THAT(builder_.first_erro …
1611:19… interpreter backend.
1612using ReduceWindowTextTest = HloTestBase;
1613
1614TEST_F(ReduceWindowTextTest, R2General256x384) {
1615 const std::string hlo_string = R"(
1616HloModule R2Window
1617mul {
1618 lhs = f32[] parameter …
1625:52… dow(operand, constant), window={size=2x3 pad=0_1x1_1}, to_apply=mul
1626}
1627)";
1628 EXPECT_TRUE(RunAndCompare(hlo_string, ErrorSpec{0.001}));
1629}
1630
1631TEST_F(ReduceWindowTextTest, R2General256x384Layout01) {
1632 const std::string h …