STT-tensorflow/tensorflow/compiler/xla/tests/reshape_motion_test.cc
Tim Shen 736a471dc0 Change headers to directly include absl::Span, and clean up the build
dependencies as well.

PiperOrigin-RevId: 211038094
2018-08-30 22:52:05 -07:00

58 lines
2.1 KiB
C++

/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include <memory>
#include <numeric>
#include <random>
#include <vector>
#include "absl/types/span.h"
#include "tensorflow/compiler/xla/array2d.h"
#include "tensorflow/compiler/xla/array4d.h"
#include "tensorflow/compiler/xla/client/global_data.h"
#include "tensorflow/compiler/xla/client/local_client.h"
#include "tensorflow/compiler/xla/client/xla_builder.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/reference_util.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/statusor.h"
#include "tensorflow/compiler/xla/test_helpers.h"
#include "tensorflow/compiler/xla/tests/client_library_test_base.h"
#include "tensorflow/compiler/xla/tests/literal_test_util.h"
#include "tensorflow/compiler/xla/tests/test_macros.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/platform/types.h"
namespace xla {
namespace {
using ReshapeMotionTest = ClientLibraryTestBase;
TEST_F(ReshapeMotionTest, ElementwiseOfReshapesWithNonSameInputShapes) {
XlaBuilder builder(TestName());
auto a = ConstantR2<int32>(&builder, {{2, 3, 5}, {7, 11, 13}});
auto b = ConstantR2<int32>(&builder, {{17, 19}, {23, 29}, {31, 37}});
auto c = Reshape(a, {6});
auto d = Reshape(b, {6});
Mul(c, d);
ComputeAndCompareR1<int32>(&builder, {34, 57, 115, 203, 341, 481}, {});
}
} // namespace
} // namespace xla