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.

parameter_resolver.cc 1.6 kB

123456789101112131415161718192021222324252627282930313233
  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 "mindquantum/parameter_resolver.h"
  17. namespace mindspore {
  18. namespace mindquantum {
  19. ParameterResolver::ParameterResolver() {}
  20. ParameterResolver::ParameterResolver(const ParaType &data, const ParaSetType &no_grad_parameters,
  21. const ParaSetType &requires_grad_parameters)
  22. : data_(data), no_grad_parameters_(no_grad_parameters), requires_grad_parameters_(requires_grad_parameters) {}
  23. const ParaType &ParameterResolver::GetData() const { return data_; }
  24. const ParaSetType &ParameterResolver::GetRequiresGradParameters() const { return requires_grad_parameters_; }
  25. void ParameterResolver::SetData(const std::string &name, const CalcType &value) { data_[name] = value; }
  26. void ParameterResolver::InsertNoGrad(const std::string &name) { no_grad_parameters_.insert(name); }
  27. void ParameterResolver::InsertRequiresGrad(const std::string &name) { requires_grad_parameters_.insert(name); }
  28. } // namespace mindquantum
  29. } // namespace mindspore