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.

ascend_kernel_mod.cc 1.5 kB

4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 "kernel/ascend_kernel_mod.h"
  17. #include "runtime/device/kernel_runtime.h"
  18. #include "runtime/rt.h"
  19. #include "include/common/utils/anfalgo.h"
  20. namespace mindspore {
  21. namespace kernel {
  22. void AscendKernelMod::UpdateOp() {
  23. MS_EXCEPTION_IF_NULL(stream_);
  24. // cppcheck-suppress unreadVariable
  25. auto lock = device::KernelRuntime::LockRuntime();
  26. if (RT_ERROR_NONE != rtStreamSynchronize(stream_)) {
  27. MS_LOG(EXCEPTION) << "Call runtime rtStreamSynchronize failed.";
  28. }
  29. }
  30. bool AscendKernelMod::IsNeedUpdateOp() {
  31. auto node = anf_node_.lock();
  32. MS_EXCEPTION_IF_NULL(node);
  33. auto cnode = node->cast<CNodePtr>();
  34. MS_EXCEPTION_IF_NULL(cnode);
  35. auto op_name = common::AnfAlgo::GetCNodeName(cnode);
  36. if (kComputeDepend.find(op_name) != kComputeDepend.end()) {
  37. is_need_updateop_ = true;
  38. }
  39. return is_need_updateop_;
  40. }
  41. } // namespace kernel
  42. } // namespace mindspore