Skip to content
Merged
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
12 changes: 9 additions & 3 deletions python/paddle/fluid/distribute_transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import distributed_splitter as splitter
import framework
from framework import Program, default_main_program, Variable
from framework import Program, default_main_program, Variable, Parameter
from . import core

LOOKUP_TABLE_TYPE = "lookup_table"
Expand Down Expand Up @@ -222,8 +222,14 @@ def transpile(self,

# step1: For large parameters and gradients, split them into smaller
# blocks.
param_list = [pg[0] for pg in params_grads]
grad_list = [pg[1] for pg in params_grads]
param_list = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can use filter for the shorter code:

param_list = filter(lambda x[0] : type(x[0]) == parameter and x[0].trainable == True , params_grads)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, this way actually run 2 for loops and current implementation just run 1for loop

grad_list = []
for p, g in params_grads:
# skip parameter marked not trainable
if type(p) == Parameter and p.trainable == False:
continue
param_list.append(p)
grad_list.append(g)

if self.has_distributed_lookup_table:
param_list = [
Expand Down