Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def ReadFwdFile(filepath):
# empty file loaded by yaml is None
contents = yaml.load(f, Loader=yaml.FullLoader)
f.close()
# not all fused ops supoort dygraph
# not all fused ops support dygraph
if filepath.endswith("fused_ops.yaml") is True:
new_apis = [
api
Expand All @@ -134,7 +134,7 @@ def ReadBwdFile(filepath, bw_ops=None):
f = open(filepath, 'r')
if bw_ops is None:
contents = yaml.load(f, Loader=yaml.FullLoader)
# not all fused ops supoort dygraph
# not all fused ops support dygraph
if filepath.endswith("fused_backward.yaml") is True:
new_apis = [
api
Expand Down
10 changes: 5 additions & 5 deletions paddle/fluid/eager/auto_code_generator/generator/eager_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ class {} : public egr::GradNodeBase {{
}}
"""

HIHGER_ORDER_DERIVATIVE_VALUE_TEMPLATE = """ if(trace_backward) {{
HIGHER_ORDER_DERIVATIVE_VALUE_TEMPLATE = """ if(trace_backward) {{
{}
// Node Construction
{}
Expand Down Expand Up @@ -1254,7 +1254,7 @@ def GenerateNodeCreationCodes(self, for_backward=False, is_inplaced=False):
)
else:
self.node_creation_str = (
HIHGER_ORDER_DERIVATIVE_VALUE_TEMPLATE.format(
HIGHER_ORDER_DERIVATIVE_VALUE_TEMPLATE.format(
node_creation_event_str,
node_construction_str,
set_attributes_str,
Expand Down Expand Up @@ -2266,7 +2266,7 @@ def GenerateNodeDefinition(
backward_attrs_list = self.backward_attrs_list
backward_inplace_map = self.backward_inplace_map
indent = GetIndent(1)
need_gen_trace_backard_for_inplace = False
need_gen_trace_backward_for_inplace = False

# Construct grad_api function args
# Order: TensorWrappers, GradTensors, Attributes
Expand Down Expand Up @@ -2519,7 +2519,7 @@ def GenerateNodeDefinition(
}} else {{
{inplace_str}
}}"""
need_gen_trace_backard_for_inplace = True
need_gen_trace_backward_for_inplace = True
else:
inplace_for_grad_outs_str += inplace_str

Expand Down Expand Up @@ -2623,7 +2623,7 @@ def GenerateNodeDefinition(
if (
len(next_grad_node_creation_str) > 0
or is_invoke_forward_api
or need_gen_trace_backard_for_inplace
or need_gen_trace_backward_for_inplace
):
compute_require_next_grad_str = f"{indent}bool trace_backward = egr::Controller::Instance().HasGrad() && create_graph;\n"

Expand Down
36 changes: 19 additions & 17 deletions paddle/fluid/eager/auto_code_generator/generator/python_c_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def __init__(self, forward_api_contents, namespace):
# Generated Results
self.python_c_function_str = ""
self.python_c_function_reg_str = ""
self.python_c_funcion_declare_str = ""
self.python_c_function_declare_str = ""

def CollectIsForwardOnly(self):
forward_api_contents = self.forward_api_contents
Expand Down Expand Up @@ -515,7 +515,7 @@ def GeneratePythonCFunction(self):
dygraph_function_call_str,
)

# Generate Python-C Function Definetion
# Generate Python-C Function Definition
self.python_c_function_str = PYTHON_C_FUNCTION_TEMPLATE.format(
forward_api_name,
pythonc_record_event_str,
Expand All @@ -526,7 +526,7 @@ def GeneratePythonCFunction(self):
noamp_dygraph_function_str,
return_str,
)
self.python_c_funcion_declare_str = (
self.python_c_function_declare_str = (
PYTHON_C_FUNCTION_DECLARE_TEMPLATE.format(name=forward_api_name)
)

Expand Down Expand Up @@ -572,7 +572,7 @@ def GeneratePythonCFunction(self):
" return ToPyObject(out, args, inplace_var_idx_map);"
)

# Generate Python-C Function Definetion
# Generate Python-C Function Definition
python_c_inplace_func_str = PYTHON_C_FUNCTION_TEMPLATE.format(
inplaced_forward_api_name,
pythonc_record_event_str,
Expand All @@ -584,7 +584,7 @@ def GeneratePythonCFunction(self):
return_str,
)

python_c_funcion_declare_str = (
python_c_function_declare_str = (
PYTHON_C_FUNCTION_DECLARE_TEMPLATE.format(
name=inplaced_forward_api_name
)
Expand All @@ -603,13 +603,15 @@ def GeneratePythonCFunction(self):
# self.forward_api_name ending with '_' means it only has inplace api
if self.forward_api_name[-1] == '_':
self.python_c_function_str = python_c_inplace_func_str
self.python_c_funcion_declare_str = python_c_funcion_declare_str
self.python_c_function_declare_str = (
python_c_function_declare_str
)
# Generate Python-C Function Registration
self.python_c_function_reg_str = python_c_inplace_func_reg_str
else:
self.python_c_function_str += python_c_inplace_func_str
self.python_c_funcion_declare_str += (
python_c_funcion_declare_str
self.python_c_function_declare_str += (
python_c_function_declare_str
)
# Generate Python-C Function Registration
self.python_c_function_reg_str += python_c_inplace_func_reg_str
Expand Down Expand Up @@ -652,7 +654,7 @@ def __init__(self, path):
# Generated Result
self.python_c_functions_str = ""
self.python_c_functions_reg_str = ""
self.python_c_funcion_declare_str = ""
self.python_c_function_declare_str = ""

def GeneratePythonCFunctions(self):
namespace = self.namespace
Expand All @@ -671,8 +673,8 @@ def GeneratePythonCFunctions(self):
self.python_c_functions_reg_str += (
f_generator.python_c_function_reg_str
)
self.python_c_funcion_declare_str += (
f_generator.python_c_funcion_declare_str
self.python_c_function_declare_str += (
f_generator.python_c_function_declare_str
)

def AttachNamespace(self):
Expand All @@ -685,9 +687,9 @@ def AttachNamespace(self):
self.python_c_functions_str = NAMESPACE_WRAPPER_TEMPLATE.format(
namespace, python_c_functions_str
)
self.python_c_funcion_declare_str = (
self.python_c_function_declare_str = (
NAMESPACE_WRAPPER_TEMPLATE.format(
namespace, self.python_c_funcion_declare_str
namespace, self.python_c_function_declare_str
)
)

Expand Down Expand Up @@ -766,20 +768,20 @@ def GeneratePythonCFile(filepath, python_c_str):
py_c_generator.python_c_functions_reg_str
)
generated_python_c_functions_header += (
py_c_generator.python_c_funcion_declare_str
py_c_generator.python_c_function_declare_str
)

python_c_str = GeneratePythonCWrappers(
generated_python_c_functions, generated_python_c_registration
)

soucre_path = args.source_path
source_path = args.source_path
header_path = args.header_path
for path in [soucre_path, header_path]:
for path in [source_path, header_path]:
if os.path.exists(path):
os.remove(path)

GeneratePythonCFile(soucre_path, python_c_str)
GeneratePythonCFile(source_path, python_c_str)
GeneratePythonCFile(
header_path,
PYTHON_C_H_TEMPLATE.format(body=generated_python_c_functions_header),
Expand Down
6 changes: 3 additions & 3 deletions paddle/fluid/eager/grad_node_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ namespace egr {
* TODO(yangzhanlue): GradNodeBase will also in charge of get the correct input
* from GradOpDescMaker to GradNodeBase.
*
* NOTE: GradNodeBase has a method named run, this method should be overrided by
* the specific derived class, it will prepare backward inputs and double
* NOTE: GradNodeBase has a method named run, this method should be overridden
*by the specific derived class, it will prepare backward inputs and double
* backward's depends. Then, it will call C++ API of backward kernel functions
* to finish backward computation.
*
Expand Down Expand Up @@ -203,7 +203,7 @@ class GradNodeBase {

/**
* operator() designed to contain the real backward execution logic, it should
* be overrided by derived class defined for each operator. It accepts a
* be overridden by derived class defined for each operator. It accepts a
* vector of Tensor which contains grads input of current operator
*
* Note: why we need backward inputs and outputs construct as vector of vector
Expand Down