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

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