TensorFlow Serving C++ API Documentation
thread_pool_factory.cc
1 /* Copyright 2021 Google Inc. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7  http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #include "tensorflow_serving/servables/tensorflow/thread_pool_factory.h"
17 
18 #include <memory>
19 #include <utility>
20 
21 namespace tensorflow {
22 namespace serving {
23 
24 ScopedThreadPools::ScopedThreadPools(
25  std::shared_ptr<thread::ThreadPoolInterface> inter_op_thread_pool,
26  std::shared_ptr<thread::ThreadPoolInterface> intra_op_thread_pool)
27  : inter_op_thread_pool_(std::move(inter_op_thread_pool)),
28  intra_op_thread_pool_(std::move(intra_op_thread_pool)) {}
29 
30 tensorflow::thread::ThreadPoolOptions ScopedThreadPools::get() {
31  tensorflow::thread::ThreadPoolOptions options;
32  options.inter_op_threadpool = inter_op_thread_pool_.get();
33  options.intra_op_threadpool = intra_op_thread_pool_.get();
34  return options;
35 }
36 
37 } // namespace serving
38 } // namespace tensorflow