From c465a71c27177c5214192a2cb36f0936d94dea4e Mon Sep 17 00:00:00 2001 From: Yuan Shuai Date: Tue, 26 May 2020 19:44:24 +0800 Subject: [PATCH] [LITE][DOC] add profiler info in develop guide for add_operation.md. test=develop (#3711) --- docs/develop_guides/add_operation.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/develop_guides/add_operation.md b/docs/develop_guides/add_operation.md index 1aa955fa6a..d177775ff0 100644 --- a/docs/develop_guides/add_operation.md +++ b/docs/develop_guides/add_operation.md @@ -27,6 +27,28 @@ bool AttachImpl(const cpp::OpDesc &opdesc, lite::Scope *scope) override; void AttachKernel(KernelBase *kernel) override { kernel->SetParam(param_); } std::string DebugString() const override { return "argmax"; } + + #ifdef LITE_WITH_PROFILE + void GetOpRuntimeInfo(paddle::lite::profile::OpCharacter *ch) { + auto input_dims = param_.X->dims(); + auto output_dims = param_.Out->dims(); + ch->input_shape = ch->DimToStr(input_dims); + ch->output_shape = ch->DimToStr(output_dims); + ch->remark = "axis" + std::to_string(param_.Axis); + + auto axis = param_.Axis; + if (axis < 0) { + axis += input_dims.size(); + } + int max_num = 1; + for (int64_t i = axis + 1; i < input_dims.size(); i++) + max_num *= input_dims[i]; + float gops = 1.0f; + for (int i = 1; i <= max_num; i++) gops *= i; + ch->macs = gops * output_dims.production(); + } + #endif + private: mutable ArgmaxParam param_; }; -- GitLab