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

Class Operator

python/paddle/base/framework.py:3221–4116  ·  view source on GitHub ↗

In Fluid, all the operation are represented by Operator, and Operator is regarded as a build in an instruction of a Block. Users can use the build in instructions to describe their neural network. Args: block(Block): The block has the current operator. desc(core.OpD

Source from the content-addressed store, hash-verified

3219
3220
3221class Operator:
3222 """
3223 In Fluid, all the operation are represented by Operator, and Operator
3224 is regarded as a build in an instruction of a Block. Users can use the
3225 build in instructions to describe their neural network.
3226
3227 Args:
3228 block(Block): The block has the current operator.
3229 desc(core.OpDesc): The protobuf description of Operator.
3230 type(str): The type of operator. Default None.
3231 inputs(dict): The input of this Operator. it is a dictionary, for every
3232 element, key is the input parameter name, and value is a list of
3233 variables. Default None.
3234 outputs(dict): The output of this Operator. it is a dictionary, for
3235 every element, key is the input parameter name, and value is a list
3236 of variables. Default None.
3237 attrs(dict): The attributes of this Operator. it is a dictionary, for
3238 every element, key is attribute name, and value is the attribute value.
3239 The attribute type should be as same as the type registered in C++ side.
3240 Default None.
3241
3242 Returns:
3243 Operator: The initialized Operator.
3244
3245 Raises:
3246 ValueError: If the passed input, output and attrs doesn't match the
3247 initializing Operator's that registered in C++ side.
3248
3249 Notes:
3250 The constructor of operator should not be invoked directly. Use
3251 Block.append_op or Block._prepend_op instead.
3252
3253 Examples:
3254 .. code-block:: pycon
3255
3256 >>> import paddle
3257
3258 >>> paddle.enable_static()
3259 >>> cur_program = paddle.static.Program()
3260 >>> cur_block = cur_program.current_block()
3261 >>> var1 = cur_block.create_var(name="var1", shape=[-1, 23, 48], dtype='float32')
3262 >>> var2 = cur_block.create_var(name="var2", shape=[-1, 23, 48], dtype='float32')
3263 >>> var3 = cur_block.create_var(name="var3", shape=[-1, 23, 48], dtype='float32')
3264 >>> var1 += var2 + var3
3265 >>> cur_block.append_op(
3266 ... type="sum",
3267 ... inputs={"X": [var1, var2, var3]},
3268 ... outputs={"Out": [var1]},
3269 ... )
3270 """
3271
3272 OP_WITHOUT_KERNEL_SET = {
3273 "feed",
3274 "fetch",
3275 "go",
3276 "conditional_block",
3277 "pylayer",
3278 "while",

Callers 10

_lowerFunction · 0.90
append_opMethod · 0.70
_prepend_opMethod · 0.70
_sync_with_cppMethod · 0.70
_rebuild_from_descMethod · 0.70
_prepare_readerMethod · 0.50
create_dataloaderFunction · 0.50
forwardMethod · 0.50
backwardMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected