ifrt_executable_registry_test.cc
imports tensorflow/core/platform/resource_loader.himports tensorflow/core/platform/status_matchers.h
SHA-25661ea0ee1ce6754b1f2cb35b0ac97a4b702be41f26cd9ff6c3d97bacf085f1c53
MaleculeMd₂(In₆Pa)
Evidence
1/* Copyright 2024 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
16#include "tensorflow/core/tfrt/ifrt/ifrt_executable_registry.h"
17
18#include <cstdint>
19#include <memory>
20#include <string>
21#include <utility>
22
23#include <gmock/gmock.h>
24#include <gtest/gtest.h>
25#include "absl/status/status.h"
26#include "absl/status/status_matchers.h"
27#include "absl/status/statusor.h"
28#include "absl/strings/str_cat.h"
29#include "absl/strings/string_view.h"
30#include "mlir/IR/BuiltinOps.h" // from @llvm-project
31#include "mlir/IR/DialectRegistry.h" // from @llvm-project
32#include "mlir/IR/MLIRContext.h" // from @llvm-project
33#include "mlir/IR/OwningOpRef.h" // from @llvm-project
34#include "mlir/InitAllDialects.h" // from @llvm-project
35#include "mlir/Parser/Parser.h" // from @llvm-project
36#include "tensorflow/compiler/mlir/tensorflow/dialect_registration.h"
37#include "tensorflow/compiler/tf2xla/xla_helpers.h"
38#include "xla/python/ifrt/array.h"
39#include "xla/python/ifrt/client.h"
40#include "xla/python/ifrt/test_util.h"
41#include "xla/tsl/platform/env.h"
42#include "xla/tsl/platform/statusor.h"
43#include "xla/tsl/platform/threadpool.h"
44#include "tensorflow/core/common_runtime/device_mgr.h"
45#include "tensorflow/core/framework/types.pb.h"
46#include "tensorflow/core/platform/resource_loader.h"
47#include "tensorflow/core/platform/status_matchers.h"
48#include "tensorflow/core/platform/test.h"
49#include "tensorflow/core/tfrt/ifrt/ifrt_loaded_variable_registry.h"
50#include "tensorflow/core/tfrt/ifrt/ifrt_restore_tensor_registry.h"
51#include "tensorflow/core/tfrt/ifrt/ifrt_serving_executable.h"
52#include "tensorflow/core/tfrt/ifrt/sharding_utils.h"
53#include "tensorflow/core/tfrt/ifrt/tf_host_callback.h"
54#include "tfrt/host_context/concurrent_work_queue.h" // from @tf_runtime
55
56namespace tensorflow {
57namespace ifrt_serving {
58namespace {
123:34… le_ptr =
124 ServingExecutableRegistry::Lookup(program_id);
125 ASSERT_EQ(executable_ptr, raw_ptr);
126}
127
128TEST(IfrtExecutableRegistry, DuplicateRegistrationFails) {
129 mlir::DialectRegistry registry;
130 mli …
159:41… program_id, std::move(executable)));
160
161 handle.Release();
162
163 EXPECT_EQ(ServingExecutableRegistry::Lookup(program_id), nullptr);
164}
165
166TEST(IfrtExecutableRegistry, FreezeOk) {
167 mlir::DialectRegistry re …