• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2017 The TensorFlow Authors. 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/core/tpu/tpu_embedding_output_layout_utils.h"
17 #include "tensorflow/core/lib/core/errors.h"
18 #include "tensorflow/core/protobuf/tpu/tpu_embedding_output_layout.pb.h"
19 
20 namespace tensorflow {
21 namespace tpu {
22 
ComputeOutputTensorShapes(const TPUEmbeddingConfiguration & config,std::vector<TensorShapeProto> * shapes)23 Status ComputeOutputTensorShapes(const TPUEmbeddingConfiguration& config,
24                                  std::vector<TensorShapeProto>* shapes) {
25   int batch_size = config.batch_size_per_tensor_core();
26 
27   for (const TPUEmbeddingConfiguration::TableDescriptor& table :
28        config.table_descriptor()) {
29     TensorShapeProto shape;
30     auto* dim0 = shape.add_dim();
31     dim0->set_size(table.num_features() * batch_size);
32     auto* dim1 = shape.add_dim();
33     dim1->set_size(table.dimension());
34     shapes->push_back(shape);
35   }
36   return Status::OK();
37 }
38 
39 }  // namespace tpu
40 }  // namespace tensorflow
41