Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dygraph Prim code gen (node.cc) #33

Merged
merged 24 commits into from
Jan 6, 2023

Conversation

xiaoguoguo626807
Copy link
Collaborator

@xiaoguoguo626807 xiaoguoguo626807 commented Jan 3, 2023

PR types

@xiaoguoguo626807 xiaoguoguo626807 changed the title Prim code gen digraph Prim code gen (node.cc) Jan 3, 2023
Copy link
Owner

@JiabinYang JiabinYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments

@@ -2328,6 +2354,9 @@ def GenerateNodeDefinition(
var_str += f"\n{indent} output_str += output_{new_name}_str; "

log_str = AFTER_LOG_PRINT_TEMPLATE.format(var_str)
# TODO Ruting modify in the future
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO with wrong format

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modified

@@ -1826,16 +1833,19 @@ def GenerateHigherOrderNodeCreationCode(self):
is_invoke_forward_api = IsInvokeForwardApi(
self.grad_api_contents, self.forward_apis_dict
)
is_composite_forward_api = False if self.composite_func_info == [] else True
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why composite forward api?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace by composite grad api

next_grad_node_creation_str,
next_grad_node_out_list,
next_node_generator.backward_forward_inputs_map,
)
elif not is_invoke_forward_api:
elif not is_invoke_forward_api and not is_composite_forward_api:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if it hits else branch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if is_invoke_farward_api or is_composite_grad_api next_grad_node_creation_str should be none, we will add this when delete Flags_prim_enabled
add TODO here

@@ -2225,6 +2241,16 @@ def GenerateNodeDefinition(
{out_assign_str}}} else {{
{indent}{autograd_api_out} api_output = paddle::experimental::{self.namespace}{self.grad_api_contents['invoke']};
{out_assign_str}{indent}}}
"""
elif is_composite_grad_api:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave TODO here to indicate strategy which will be used later, such as using composite only when we don't have backward kernel

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be statically generated here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@xiaoguoguo626807 xiaoguoguo626807 changed the title digraph Prim code gen (node.cc) dygraph Prim code gen (node.cc) Jan 3, 2023
Copy link
Owner

@JiabinYang JiabinYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one comment

@@ -2,3 +2,8 @@ cc_library(
static_utils
SRCS static_utils.cc
DEPS proto_desc operator static_global_utils)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid this ON INFER and NO PYTHON

Copy link
Owner

@JiabinYang JiabinYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments

dygraph_function dygraph_node)

cc_test_old(
set(prim_generated_deps final_dygraph_function final_dygraph_node dygraph_function
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change this?

# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe no need to push these code in this pr?

@@ -47,8 +47,8 @@ add_custom_target(
${forwards_cc_path}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_forwards_h_path}
${forwards_h_path}
# COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_nodes_cc_path}
# ${nodes_cc_path}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_nodes_cc_path}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove additional generated files

Copy link
Owner

@JiabinYang JiabinYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JiabinYang JiabinYang merged commit aec6a94 into JiabinYang:prim_paddle Jan 6, 2023
@xiaoguoguo626807 xiaoguoguo626807 deleted the prim_code_gen branch January 9, 2023 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants