MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / func

Function func

python/paddle/tensor/layer_function_generator.py:132–162  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

130 return dtype
131
132 def func(*args, **kwargs) -> Tensor:
133 helper = LayerHelper(op_type, **kwargs)
134
135 dtype = infer_and_check_dtype(op_proto, *args, **kwargs)
136
137 inputs = {}
138 for ipt in op_proto.inputs:
139 name = _convert_(ipt.name)
140 val = kwargs.pop(name, [])
141 if not isinstance(val, list) and not isinstance(val, tuple):
142 val = [val]
143 if len(val) == 0 and len(args) != 0:
144 val = args[0]
145 args = args[1:]
146 inputs[ipt.name] = val
147
148 outputs = {}
149 out = kwargs.pop(_convert_(o_name), [])
150 if out:
151 out_var = out[0] if isinstance(out, (list, tuple)) else out
152 else:
153 out_var = helper.create_variable_for_type_inference(dtype=dtype)
154 outputs[o_name] = [out_var]
155 for name in intermediate_output_names:
156 outputs[name] = [
157 helper.create_variable_for_type_inference(dtype=dtype)
158 ]
159 helper.append_op(
160 type=op_type, inputs=inputs, outputs=outputs, attrs=kwargs
161 )
162 return helper.append_activation(out_var)
163
164 func.__name__ = op_type
165 return func

Callers 15

wrapperFunction · 0.50
flopsFunction · 0.50
map_structureFunction · 0.50
__impl__Function · 0.50
wrapperMethod · 0.50
wrapperFunction · 0.50
wrapped_funcFunction · 0.50
_insert_funcMethod · 0.50
_callMethod · 0.50
wrapperFunction · 0.50
_func_wrapperFunction · 0.50
wrappedFunction · 0.50

Calls 9

append_opMethod · 0.95
append_activationMethod · 0.95
LayerHelperClass · 0.85
infer_and_check_dtypeFunction · 0.85
in_dynamic_or_pir_modeFunction · 0.85
check_variable_and_dtypeFunction · 0.85
_convert_Function · 0.70
popMethod · 0.45

Tested by

no test coverage detected