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.h 2.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #ifndef MINDSPORE_CCSRC_PS_SERVER_KERNEL_PARAMS_INFO_H_
  17. #define MINDSPORE_CCSRC_PS_SERVER_KERNEL_PARAMS_INFO_H_
  18. #include <utility>
  19. #include <string>
  20. #include <vector>
  21. #include "ir/dtype/type_id.h"
  22. namespace mindspore {
  23. namespace ps {
  24. namespace server {
  25. namespace kernel {
  26. // ParamsInfo is used for server computation kernel's register, e.g, ApplyMomentumKernel, FedAvgKernel, etc.
  27. // Register of a server kernel needs every inputs/workspace/outputs parameters' name and type.
  28. // For example:
  29. // ParamsInfo()
  30. // .AddInputNameType("input1_name", kNumberTypeFloat32)
  31. // .AddInputNameType("input2_name", kNumberTypeUInt64)
  32. // .AddWorkspaceNameType("workspace1_name", kNumberTypeFloat32)
  33. // .AddOutputNameType("output1_name", kNumberTypeUInt64)
  34. // This invocation describes a server kernel with parameters below:
  35. // An input with name "input1_name" and type float32.
  36. // An input with name "input1_name" and type uint_64.
  37. // A workspace with name "workspace1_name" and type float32.
  38. // An output with name "output1_name" and type float32.
  39. class ParamsInfo {
  40. public:
  41. ParamsInfo() = default;
  42. ~ParamsInfo() = default;
  43. ParamsInfo &AddInputNameType(const std::string &name, TypeId type);
  44. ParamsInfo &AddWorkspaceNameType(const std::string &name, TypeId type);
  45. ParamsInfo &AddOutputNameType(const std::string &name, TypeId type);
  46. size_t inputs_num() const;
  47. size_t outputs_num() const;
  48. const std::pair<std::string, TypeId> &inputs_name_type(size_t index) const;
  49. const std::pair<std::string, TypeId> &outputs_name_type(size_t index) const;
  50. const std::vector<std::string> &inputs_names() const;
  51. const std::vector<std::string> &workspace_names() const;
  52. const std::vector<std::string> &outputs_names() const;
  53. private:
  54. std::vector<std::pair<std::string, TypeId>> inputs_name_type_;
  55. std::vector<std::pair<std::string, TypeId>> workspaces_name_type_;
  56. std::vector<std::pair<std::string, TypeId>> outputs_name_type_;
  57. std::vector<std::string> inputs_names_;
  58. std::vector<std::string> workspace_names_;
  59. std::vector<std::string> outputs_names_;
  60. };
  61. } // namespace kernel
  62. } // namespace server
  63. } // namespace ps
  64. } // namespace mindspore
  65. #endif // MINDSPORE_CCSRC_PS_SERVER_KERNEL_PARAMS_INFO_H_