You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

params_info.cc 2.4 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * Copyright 2021 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include "fl/server/kernel/params_info.h"
  17. #include "utils/log_adapter.h"
  18. namespace mindspore {
  19. namespace fl {
  20. namespace server {
  21. namespace kernel {
  22. ParamsInfo &ParamsInfo::AddInputNameType(const std::string &name, TypeId type) {
  23. inputs_name_type_.push_back(std::make_pair(name, type));
  24. inputs_names_.push_back(name);
  25. return *this;
  26. }
  27. ParamsInfo &ParamsInfo::AddWorkspaceNameType(const std::string &name, TypeId type) {
  28. workspaces_name_type_.push_back(std::make_pair(name, type));
  29. workspace_names_.push_back(name);
  30. return *this;
  31. }
  32. ParamsInfo &ParamsInfo::AddOutputNameType(const std::string &name, TypeId type) {
  33. outputs_name_type_.push_back(std::make_pair(name, type));
  34. outputs_names_.push_back(name);
  35. return *this;
  36. }
  37. size_t ParamsInfo::inputs_num() const { return inputs_name_type_.size(); }
  38. size_t ParamsInfo::outputs_num() const { return outputs_name_type_.size(); }
  39. const std::pair<std::string, TypeId> &ParamsInfo::inputs_name_type(size_t index) const {
  40. if (index >= inputs_name_type_.size()) {
  41. MS_LOG(EXCEPTION) << "Index " << index << " is out of bound of inputs_name_type_.";
  42. }
  43. return inputs_name_type_[index];
  44. }
  45. const std::pair<std::string, TypeId> &ParamsInfo::outputs_name_type(size_t index) const {
  46. if (index >= outputs_name_type_.size()) {
  47. MS_LOG(EXCEPTION) << "Index " << index << " is out of bound of outputs_name_type_.";
  48. }
  49. return outputs_name_type_[index];
  50. }
  51. const std::vector<std::string> &ParamsInfo::inputs_names() const { return inputs_names_; }
  52. const std::vector<std::string> &ParamsInfo::workspace_names() const { return workspace_names_; }
  53. const std::vector<std::string> &ParamsInfo::outputs_names() const { return outputs_names_; }
  54. } // namespace kernel
  55. } // namespace server
  56. } // namespace fl
  57. } // namespace mindspore