sharding_utils_test.cc
imports tsl/platform/ml_dtypes.himports xla/tsl/platform/env.h
SHA-256b48738e6a094ab9c48e07d913331bd80d8ddb360157bbb7e512b8ba4115fc41d
MaleculeMd₂(In₅Pa)
Evidence
1/* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
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 …
11:42… IND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
15#include "tensorflow/core/tfrt/ifrt/sharding_utils.h"
16
17#include <cstdint>
18#include <initializer_list>
19#include <memory>
20#include <optional>
21#include <utility>
22#include <vector>
23
24#include <gtest/gtest.h>
25#include "absl/status/status.h"
26#include "absl/status/status_matchers.h"
27#include "absl/strings/str_cat.h"
28#include "absl/types/span.h"
29#include "llvm/Support/Casting.h"
30#include "xla/hlo/ir/hlo_sharding.h"
31#include "xla/python/ifrt/array.h"
32#include "xla/python/ifrt/client.h"
33#include "xla/python/ifrt/device.h"
34#include "xla/python/ifrt/layout.h"
35#include "xla/python/ifrt/memory.h"
36#include "xla/python/ifrt/shape.h"
37#include "xla/python/ifrt/sharding.h"
38#include "xla/python/ifrt/test_util.h"
39#include "xla/python/pjrt_ifrt/xla_sharding.h"
40#include "xla/shape.h"
41#include "xla/shape_util.h"
42#include "xla/tsl/concurrency/ref_count.h"
43#include "xla/tsl/lib/core/status_test_util.h"
44#include "xla/tsl/platform/env.h"
45#include "xla/tsl/platform/statusor.h"
46#include "xla/tsl/platform/test.h"
47#include "xla/tsl/platform/threadpool.h"
48#include "xla/xla_data.pb.h"
49#include "tensorflow/core/framework/tensor.h"
50#include "tensorflow/core/framework/tensor_matcher.h"
51#include "tensorflow/core/framework/tensor_shape.h"
52#include "tensorflow/core/framework/tensor_testutil.h"
53#include "tensorflow/core/framework/types.pb.h"
54#include "tensorflow/core/tfrt/ifrt/ifrt_tensor_utils.h"
55#include "tsl/platform/ml_dtypes.h"
56
57namespace tensorflow {
58namespace ifrt_serving {
448:8… minor_to_major.end());
449 EXPECT_EQ(minor_to_major_vec, expected_minor_to_major);
450 }
451
452 TF_ASSERT_OK_AND_ASSIGN(
453 auto disassembled_arrays,
454 assembled_a …
456:11… xla::ifrt::SingleDeviceShardSemantics::kAddressableShards));
457
458 ASSERT_EQ(disassembled_arrays.size(), GetParam().expected_out_tensors.size());
459
460 for (int i = 0; i < disassembled_arrays.size(); ++i) {
859:58… _list));
860
861 if (GetParam().expect_single_device_sharding) {
862 EXPECT_TRUE(
863 llvm::isa<xla::ifrt::SingleDeviceSharding>(ifrt_sharding.get()));
864 EXPECT_EQ(ifrt_sharding->devices()->devices().fr …