Created by: liym27
PR types:
New features
PR changes:
dygraph to static graph
Describe:
1. New feature 1
Use function convert_while_loop
to run the transformed for loop
code dynamically:
-
for
stmts are transformed whether it depends onTensor
or not 1). for x in range(var[]|var.numpy()[]) 2). for x in var|var.numpy() 3). for i, x enumerate(var|var.numpy())Note: Here var is VarBase(Tensor) or python variable
-
But in run-time, the code will be run in different ways (1) run paddle op like
while_loop
; (2) run python while. How it runs depends on whether it depends onTensor
.
2. New feature:
support that case : variable is used and created in loop, but used before created.
For example, var_a
should be in loop_var and we should create it out loop.
res = 0
for i, x in enumerate(x_array):
if i > 2:
x = func1(var_a)
var_a = func2(x)
3. Fix bug:
Fix bug: raise None -> return None.
4. Code optimization:
Move convert_len
to file convert_operators.py