Add a global resource manager for TPU specific operations.
PiperOrigin-RevId: 312388244 Change-Id: I30dd6ce3a2f0eed3d257750626e11b3bb6eded97
This commit is contained in:
parent
7f3ef3e1ea
commit
ba48040313
@ -68,6 +68,13 @@ cc_library(
|
||||
deps = ["//tensorflow/core:protos_all_cc"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "tpu_configuration",
|
||||
srcs = ["tpu_configuration.cc"],
|
||||
hdrs = ["tpu_configuration.h"],
|
||||
deps = ["//tensorflow/core:framework"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "tpu_init_mode",
|
||||
srcs = ["tpu_init_mode.cc"],
|
||||
|
44
tensorflow/core/tpu/tpu_configuration.cc
Normal file
44
tensorflow/core/tpu/tpu_configuration.cc
Normal file
@ -0,0 +1,44 @@
|
||||
/* Copyright 2020 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 "tensorflow/core/tpu/tpu_configuration.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
namespace {
|
||||
|
||||
ResourceMgr* GetGlobalResourceMgr() {
|
||||
static ResourceMgr* const rmgr = new ResourceMgr();
|
||||
return rmgr;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#if !defined(PLATFORM_GOOGLE)
|
||||
// Used only by Google-internal tests, so deliberately left empty.
|
||||
void MaybeInitializeTPUSystemForTests() {}
|
||||
#endif
|
||||
|
||||
ResourceMgr* GetTPUConfigResourceMgr() {
|
||||
MaybeInitializeTPUSystemForTests();
|
||||
|
||||
// Put all TPU-related state in the global ResourceMgr. This includes the
|
||||
// TpuPodState, compilation cache, etc. We don't use the TPU_SYSTEM
|
||||
// ResourceMgr because there may be more than one TPU_SYSTEM ResourceMgr when
|
||||
// DirectSession or isolate_session_state are used.
|
||||
return GetGlobalResourceMgr();
|
||||
}
|
||||
|
||||
} // namespace tensorflow
|
30
tensorflow/core/tpu/tpu_configuration.h
Normal file
30
tensorflow/core/tpu/tpu_configuration.h
Normal file
@ -0,0 +1,30 @@
|
||||
/* Copyright 2020 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.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CORE_TPU_TPU_CONFIGURATION_H_
|
||||
#define TENSORFLOW_CORE_TPU_TPU_CONFIGURATION_H_
|
||||
|
||||
#include "tensorflow/core/framework/resource_mgr.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
void MaybeInitializeTPUSystemForTests();
|
||||
|
||||
// Returns a process-wide global ResourceMgr.
|
||||
ResourceMgr* GetTPUConfigResourceMgr();
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CORE_TPU_TPU_CONFIGURATION_H_
|
Loading…
Reference in New Issue
Block a user