workspace.cc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Copyright 2016 Google Inc. All Rights Reserved.
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. ==============================================================================*/
  12. #include "syntaxnet/workspace.h"
  13. #include "tensorflow/core/lib/strings/strcat.h"
  14. namespace syntaxnet {
  15. string WorkspaceRegistry::DebugString() const {
  16. string str;
  17. for (auto &it : workspace_names_) {
  18. const string &type_name = workspace_types_.at(it.first);
  19. for (size_t index = 0; index < it.second.size(); ++index) {
  20. const string &workspace_name = it.second[index];
  21. tensorflow::strings::StrAppend(&str, "\n ", type_name, " :: ",
  22. workspace_name);
  23. }
  24. }
  25. return str;
  26. }
  27. VectorIntWorkspace::VectorIntWorkspace(int size) : elements_(size) {}
  28. VectorIntWorkspace::VectorIntWorkspace(int size, int value)
  29. : elements_(size, value) {}
  30. VectorIntWorkspace::VectorIntWorkspace(const std::vector<int> &elements)
  31. : elements_(elements) {}
  32. string VectorIntWorkspace::TypeName() { return "Vector"; }
  33. VectorVectorIntWorkspace::VectorVectorIntWorkspace(int size)
  34. : elements_(size) {}
  35. string VectorVectorIntWorkspace::TypeName() { return "VectorVector"; }
  36. } // namespace syntaxnet