From c6499f1dd5480dee7a125d589237b81343dc1b85 Mon Sep 17 00:00:00 2001 From: "liyefeng803@huawei.com" Date: Sat, 2 Sep 2023 17:53:00 +0800 Subject: [PATCH] add debug op --- .../kernels/aicore/npu_mixed_precesion_ops.cc | 25 +++++++++++++++++++ .../ops/aicore/npu_mixed_precesion_ops.cc | 16 ++++++++++++ 2 files changed, 41 insertions(+) diff --git a/tf_adapter/kernels/aicore/npu_mixed_precesion_ops.cc b/tf_adapter/kernels/aicore/npu_mixed_precesion_ops.cc index 753d608a6..c86b4d816 100644 --- a/tf_adapter/kernels/aicore/npu_mixed_precesion_ops.cc +++ b/tf_adapter/kernels/aicore/npu_mixed_precesion_ops.cc @@ -99,4 +99,29 @@ class NpuClearFloatStatusV2Op : public OpKernel { }; REGISTER_KERNEL_BUILDER(Name("NpuClearFloatStatusV2").Device(DEVICE_CPU), NpuClearFloatStatusV2Op); + +class NpuClearFloatDebugStatusOp : public OpKernel { + public: + explicit NpuClearFloatDebugStatusOp(OpKernelConstruction *context) : OpKernel(context) {} + ~NpuClearFloatDebugStatusOp() override = default; + void Compute(OpKernelContext *context) override { + (void) context; + LOG(INFO) << "NpuClearFloatDebugStatus Compute"; + } +}; + +REGISTER_KERNEL_BUILDER(Name("NpuClearFloatDebugStatus").Device(DEVICE_CPU), NpuClearFloatDebugStatusOp); + +class NpuGetFloatDebugStatusOp : public OpKernel { + public: + explicit NpuGetFloatDebugStatusOp(OpKernelConstruction *context) : OpKernel(context) {} + ~NpuGetFloatDebugStatusOp() override = default; + void Compute(OpKernelContext *context) override { + (void) context; + LOG(INFO) << "NpuGetFloatDebugStatus Compute"; + } +}; + +REGISTER_KERNEL_BUILDER(Name("NpuGetFloatDebugStatus").Device(DEVICE_CPU), NpuGetFloatDebugStatusOp); + } // namespace tensorflow diff --git a/tf_adapter/ops/aicore/npu_mixed_precesion_ops.cc b/tf_adapter/ops/aicore/npu_mixed_precesion_ops.cc index 8a1af5d50..16133576e 100644 --- a/tf_adapter/ops/aicore/npu_mixed_precesion_ops.cc +++ b/tf_adapter/ops/aicore/npu_mixed_precesion_ops.cc @@ -65,6 +65,16 @@ REGISTER_OP("NpuGetFloatStatusV2") return Status::OK(); }); +REGISTER_OP("NpuGetFloatDebugStatus") + .Output("data: int32") + .SetIsStateful() + .SetShapeFn([](InferenceContext *c) { + std::vector output_dims; + output_dims.emplace_back(c->MakeDim(8)); + auto output_shape = c->MakeShape(output_dims); + c->set_output(0, output_shape); + return Status::OK(); + }); REGISTER_OP("NpuClearFloatStatus") .Input("float_status: float") @@ -86,4 +96,10 @@ REGISTER_OP("NpuClearFloatStatusV2") Set the value of global workspace to 0. )doc") .SetIsStateful(); + +REGISTER_OP("NpuClearFloatDebugStatus") + .Doc(R"doc( + Set the value of global workspace to 0. + )doc") + .SetIsStateful(); } // namespace tensorflow -- Gitee