Created by: Aurelius84
PR types
New features
PR changes
Others
Describe
Add naming rule if not specific InputSpec.name.
Naming rule
1. Already specific name
If InputSpec.name is not None
, do nothing.
2. Single argument single InputSpec
If each argument x
corresponds to an InputSpec, using the argument name like x
def foo(x, y):
return x + y
foo = to_static(foo, input_spec=[InputSpec([None, 10]), InputSpec([None])])
print([in_var.name for in_var in foo.inputs]) # [x, y]
3. Argument with list
If the arguments inputs
corresponds to a list(InputSpec), using name like inputs_0
, inputs_1
def foo(inputs):
return inputs[0] + inputs[1]
foo = to_static(foo, input_spec=[[InputSpec([None, 10]), InputSpec([None])]])
print([in_var.name for in_var in foo.inputs]) # [inputs_0, inputs_1]
4. Argument with dict
If the arguments input_dic
corresponds to a dict(InputSpec), using key as name.
def foo(inputs):
return inputs['x'] + inputs['y']
foo = to_static(foo, input_spec=[{'x': InputSpec([None, 10]), 'y': InputSpec([None])}])
print([in_var.name for in_var in foo.inputs]) # [x, y]