@@ -667,79 +667,6 @@ std::vector<ir::LoweredFunc> OpLowererImpl::DoOpLower(
667
667
return funcs;
668
668
}
669
669
670
- /* *
671
- * This function converts pir::Value::defining_op for ir::Tensor::operation
672
- * Normally, ir::Tensor::operation will only be used to record the name
673
- * of the compiler-generated var name, which is useless. However, operation
674
- * has Attributes field, so can be used to record the op info.
675
- */
676
- ir::PlaceholderOp* TensorOperationRecording (const ::pir::Value& value) {
677
- // TODO(heqianyue): I think this is kinda ugly, since we should manually
678
- // specify the rules to convert all the op (and their attribute), yet current
679
- // implementation works and can be quickly written.
680
- const ::pir::Operation* define_op = value.defining_op ();
681
- ir::PlaceholderOp* res = nullptr ;
682
- if (!define_op) return res;
683
- res = cinn::common::make_shared<ir::PlaceholderOp>();
684
- res->name = define_op->name ();
685
- // we filter some of the ops, and only record the **needed** attributes
686
- if (define_op->name () == " pd_op.full" ) {
687
- auto dtype = define_op->attribute (" dtype" )
688
- .dyn_cast <paddle::dialect::DataTypeAttribute>()
689
- .data ();
690
- phi::Scalar data = define_op->attribute (" value" )
691
- .dyn_cast <paddle::dialect::ScalarAttribute>()
692
- .data ();
693
- ir::Expr value;
694
- #define DEFINE_CASE (TypeFlag, Type ) \
695
- case phi::DataType::TypeFlag: \
696
- value = ir::Expr (data.to <Type>()); \
697
- break ;
698
- switch (dtype) {
699
- DEFINE_CASE (FLOAT32, float )
700
- DEFINE_CASE (FLOAT64, double )
701
- DEFINE_CASE (INT32, int )
702
- DEFINE_CASE (BFLOAT16, float )
703
- value->set_type (cinn::common::BFloat16 ());
704
- break ;
705
- DEFINE_CASE (FLOAT16, float )
706
- value->set_type (cinn::common::Float16 ());
707
- break ;
708
- default :
709
- value = ir::Expr (data.to <int64_t >());
710
- }
711
- #undef DEFINE_CASE
712
- res->attrs .emplace (" value" , value);
713
- } else if (define_op->name () == " cinn_op.generate_shape" ) {
714
- // pir::Attribute --> symbol::DimExpr --> ir::Expr
715
-
716
- auto ir_dim_expr = [&]() {
717
- auto dim_expr_attr = define_op->attribute (" output_dim_exprs" );
718
- auto dim_exprs = dialect::ConvertAttributeToDimExprs (dim_expr_attr);
719
-
720
- PADDLE_ENFORCE_EQ (
721
- dim_exprs.has_value (),
722
- true ,
723
- ::common::errors::PreconditionNotMet (
724
- " Required success to execute convert attribute to dim exprs." ));
725
-
726
- auto expr_vec = dim_exprs.value ();
727
- PADDLE_ENFORCE_EQ (
728
- expr_vec.empty (),
729
- false ,
730
- ::common::errors::PreconditionNotMet (
731
- " Generate shape op can not yield empty symbolic shape." ));
732
- // only the first dim_expr matters for ArangeOp
733
- return common::DimExprConverter ().ConvertToIrExpr (expr_vec[0 ]);
734
- }();
735
- res->attrs .emplace (" value" , ir_dim_expr);
736
- } else {
737
- VLOG (6 ) << " Tensor defining op recording: not currently supported op." ;
738
- return nullptr ;
739
- }
740
- return res;
741
- }
742
-
743
670
ir::Tensor OpLowererImpl::GetTensor (const OpLoweringGroupPtr& group,
744
671
const ::pir::Value& value) {
745
672
auto type_info = value.type ().dyn_cast <paddle::dialect::DenseTensorType>();
@@ -778,9 +705,6 @@ ir::Tensor OpLowererImpl::GetTensor(const OpLoweringGroupPtr& group,
778
705
tensor->set_value (*tensor_value);
779
706
}
780
707
}
781
- if (auto op_ptr = TensorOperationRecording (value)) {
782
- tensor->operation = ir::FunctionRef (op_ptr);
783
- }
784
708
return tensor;
785
709
}
786
710
0 commit comments