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.

cpu_session.h 1.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Copyright 2019 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_SESSION_CPU_SESSION_H
  17. #define MINDSPORE_CCSRC_SESSION_CPU_SESSION_H
  18. #include <string>
  19. #include <memory>
  20. #include <vector>
  21. #include "session/session_basic.h"
  22. #include "session/kernel_graph.h"
  23. #include "device/cpu/cpu_kernel_runtime.h"
  24. #include "session/session_factory.h"
  25. namespace mindspore {
  26. namespace session {
  27. class CPUSession : public SessionBasic {
  28. public:
  29. CPUSession() = default;
  30. ~CPUSession() override = default;
  31. void Init(uint32_t device_id) override {
  32. SessionBasic::Init(device_id);
  33. context_ = std::make_shared<Context>(kCPUDevice, device_id);
  34. }
  35. GraphId CompileGraph(const AnfNodePtrList &lst, const AnfNodePtrList &outputs) override;
  36. void RunGraph(const GraphId &graph_id, const std::vector<tensor::TensorPtr> &inputs, VectorRef *outputs) override;
  37. protected:
  38. ParameterPtr CreateNewParameterFromParameter(const AnfNodePtr &anf, bool valid_input, KernelGraph *graph) override;
  39. private:
  40. void SetKernelInfo(const KernelGraph *kernel_graph);
  41. void BuildKernel(const KernelGraph *kernel_graph);
  42. device::cpu::CPUKernelRuntime runtime_;
  43. };
  44. MS_REG_SESSION(kCPUDevice, CPUSession);
  45. } // namespace session
  46. } // namespace mindspore
  47. #endif // MINDSPORE_CCSRC_SESSION_CPU_SESSION_H