diff --git a/paddle/fluid/operators/generator/parse_utils.py b/paddle/fluid/operators/generator/parse_utils.py index 419f6bc3c921b679a35ccadbced2d885df2903d6..8e80cdecf3ae5debf477510843e63eaf32bc5fd3 100644 --- a/paddle/fluid/operators/generator/parse_utils.py +++ b/paddle/fluid/operators/generator/parse_utils.py @@ -276,11 +276,51 @@ def parse_forward(op_name: str, forward_config: str) -> Dict[str, Any]: return forward_cfg +def check_op_config(op_entry, op_name): + base_key_set = ( + 'op', + 'backward_op', + 'forward', + 'args', + 'output', + 'infer_meta', + 'kernel', + 'backward', + 'invoke', + 'inplace', + 'view', + 'optional', + 'intermediate', + 'no_need_buffer', + 'data_transform', + ) + infer_meta_key_set = ('func', 'param') + kernel_key_set = ('func', 'param', 'data_type', 'layout', 'backend') + for key in op_entry.keys(): + assert ( + key in base_key_set + ), f"Op ({op_name}) : invalid key ({key}) in Yaml." + + if 'infer_meta' in op_entry: + for infer_meta_key in op_entry['infer_meta'].keys(): + assert ( + infer_meta_key in infer_meta_key_set + ), f"Op ({op_name}) : invalid key (infer_meta.{infer_meta_key}) in Yaml." + + if 'kernel' in op_entry: + for kernel_key in op_entry['kernel'].keys(): + assert ( + kernel_key in kernel_key_set + ), f"Op ({op_name}) : invalid key (kernel.{kernel_key}) in Yaml." + + def parse_op_entry(op_entry: Dict[str, Any], name_field="op"): op_name = op_entry[name_field] inputs, attrs = parse_input_and_attr(op_name, op_entry["args"]) outputs = parse_outputs(op_name, op_entry["output"]) + check_op_config(op_entry, op_name) + # validate default value of DataType and DataLayout for attr in attrs: if "default_value" in attr: diff --git a/paddle/phi/api/yaml/legacy_ops.yaml b/paddle/phi/api/yaml/legacy_ops.yaml index ba446289f7e391dc10f8dea545f0368afef8f8b5..53e272d1c35067d958034d78b9904bbc0dad2653 100755 --- a/paddle/phi/api/yaml/legacy_ops.yaml +++ b/paddle/phi/api/yaml/legacy_ops.yaml @@ -17,7 +17,7 @@ func : AccuracyInferMeta kernel : func : accuracy - dtype : x + data_type : x - op : adadelta_ args : (Tensor param, Tensor grad, Tensor avg_squared_grad, Tensor avg_squared_update, float rho, float epsilon) @@ -1132,9 +1132,9 @@ output : Tensor(solution), Tensor(residuals), Tensor(rank), Tensor(singular_values) infer_meta : func : LstsqInferMeta - dtype : x kernel : func : lstsq + data_type : x - op : lu args : (Tensor x, bool pivot)