From 104a518c0e3e54795fa7a18a7c7058258ee0cb73 Mon Sep 17 00:00:00 2001 From: winter-wang <78149749+winter-wang@users.noreply.github.com> Date: Thu, 29 Jun 2023 09:54:26 +0800 Subject: [PATCH] [IR] polish the concrete op api (#54928) --- paddle/fluid/ir/dialect/op_gen.py | 4 ++-- paddle/ir/core/op_base.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/ir/dialect/op_gen.py b/paddle/fluid/ir/dialect/op_gen.py index 71e124ba01b..8d1c446e686 100644 --- a/paddle/fluid/ir/dialect/op_gen.py +++ b/paddle/fluid/ir/dialect/op_gen.py @@ -78,9 +78,9 @@ op_n_attribute_declare_str = ( "static const char *attributes_name[{attribute_num}];" ) -OP_GET_INPUT_TEMPLATE = """ ir::OpOperand {input_name}() {{ return operation()->op_operand({input_index}); }} +OP_GET_INPUT_TEMPLATE = """ ir::Value {input_name}() {{ return operand({input_index}); }} """ -OP_GET_OUTPUT_TEMPLATE = """ ir::OpResult {output_name}() {{ return operation()->result({output_index}); }} +OP_GET_OUTPUT_TEMPLATE = """ ir::OpResult {output_name}() {{ return result({output_index}); }} """ # ===================================== diff --git a/paddle/ir/core/op_base.h b/paddle/ir/core/op_base.h index bed27d68d9b..5a3f62c60ad 100644 --- a/paddle/ir/core/op_base.h +++ b/paddle/ir/core/op_base.h @@ -84,6 +84,10 @@ class IR_API OpBase { const AttributeMap &attributes() const { return operation_->attributes(); } + Value operand(uint32_t index) const { return operation_->operand(index); } + + OpResult result(uint32_t index) const { return operation_->result(index); } + private: Operation *operation_; // Not owned }; -- GitLab