diff --git a/paddle/phi/api/lib/CMakeLists.txt b/paddle/phi/api/lib/CMakeLists.txt index bb99b6fc400edcb364a47f65414f82b9f0e75d0a..0bec8f44fe34706af67dbec8dfd49f1e1a83c499 100644 --- a/paddle/phi/api/lib/CMakeLists.txt +++ b/paddle/phi/api/lib/CMakeLists.txt @@ -100,7 +100,13 @@ if(NOT PYTHON_EXECUTABLE) endif() # install extra dependencies -execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -U pyyaml jinja2) +if(${PYTHON_VERSION_STRING} VERSION_LESS "3.6.2") + execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -U pyyaml + typing-extensions>=4.1.1 jinja2==2.11.3) +else() + execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -U pyyaml jinja2 + typing-extensions) +endif() # parse apis set(parsed_api_dir ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/parsed_apis) diff --git a/python/paddle/utils/code_gen/templates/operator_utils.c.j2 b/python/paddle/utils/code_gen/templates/operator_utils.c.j2 index 63a6fe82a443ed6c6ca422c27e71047ad677faa1..9a593a99c1df09ccc2a09700c5b35a57b90c4bc0 100644 --- a/python/paddle/utils/code_gen/templates/operator_utils.c.j2 +++ b/python/paddle/utils/code_gen/templates/operator_utils.c.j2 @@ -30,10 +30,12 @@ TODO: Documentation of {{api_name}} op. {% set name = input["name"] %} {% set typename = input["typename"] %} AddInput({{name| to_opmaker_name}}, "({{typename}}), input {{i}} of {{op_name}} op.") - {%- if typename is vec +%} + {%- if typename is vec %} + .AsDuplicable() {%- endif %} - {%- if input["optional"] +%} + {%- if input["optional"] %} + .AsDispensable() {%- endif %} {%- endmacro %} @@ -44,10 +46,12 @@ AddInput({{name| to_opmaker_name}}, "({{typename}}), input {{i}} of {{op_name}} {% set typename = output["typename"] %} {% set is_intermediate = output["intermediate"] %} AddOutput({{name | to_opmaker_name}}, "({{typename}}), output {{i}} of {{op_name}} op.") - {%- if typename is vec +%} + {%- if typename is vec %} + .AsDuplicable() {%- endif %} - {%- if is_intermediate +%} + {%- if is_intermediate %} + .AsIntermediate() {%- endif %} {%- endmacro %} @@ -67,7 +71,7 @@ AddInput("{{name | to_pascal_case}}TensorList", "attribute {{i}} for {{op_name}} .AsDispensable(); {% endif %} AddAttr<{{typename | to_op_attr_type}}>("{{name}}", "({{typename | to_op_attr_type}}), attribute {{i}} for {{op_name}} op.") - {%- if "default_value" in attr +%} + {% if "default_value" in attr %} .SetDefault({{process_default_value(attr)}}) {%- endif %} {%- endmacro %}