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.

debug_cpu_kernel.cc 1.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Copyright 2020 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/cpu/debug_cpu_kernel.h"
  17. #include "device/cpu/cpu_device_address.h"
  18. #include "common/utils.h"
  19. #ifdef ENABLE_DEBUGGER
  20. #include "debug/debugger/debugger.h"
  21. #endif
  22. namespace mindspore {
  23. namespace kernel {
  24. void DebugCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); }
  25. bool DebugCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs,
  26. const std::vector<kernel::AddressPtr> & /*workspace*/,
  27. const std::vector<kernel::AddressPtr> &outputs) {
  28. if (inputs.size() < 1 || outputs.empty()) {
  29. MS_LOG(EXCEPTION) << " input or output empty!";
  30. }
  31. auto val = reinterpret_cast<float *>(inputs[0]->addr);
  32. MS_LOG(DEBUG) << " launch DebugCountCPUKernel val " << *val;
  33. auto output = reinterpret_cast<int *>(outputs[0]->addr);
  34. size_t elem_num = inputs[0]->size / sizeof(int);
  35. for (size_t i = 0; i < elem_num; i++) {
  36. output[i] = val[i];
  37. }
  38. #ifdef ENABLE_DEBUGGER
  39. // debugger will suspend execution is neccessary
  40. Debugger::GetInstance()->PostDebugOp();
  41. #endif
  42. return true;
  43. }
  44. } // namespace kernel
  45. } // namespace mindspore