MCPcopy Create free account
hub / github.com/pytorch/pytorch / add_operators

Method add_operators

caffe2/python/layers/layers.py:424–453  ·  view source on GitHub ↗

Adds layer trainig or initialization operators to the passed in net. init_net can be None and can be called independently from add_init_params

(self, net, init_net=None, context=InstantiationContext.TRAINING)

Source from the content-addressed store, hash-verified

422 return self.model.net.NextScopedBlob(name)
423
424 def add_operators(self, net, init_net=None, context=InstantiationContext.TRAINING):
425 """
426 Adds layer trainig or initialization operators to the passed in net.
427 init_net can be None and can be called independently from add_init_params
428 """
429 # Namescope below should warranty that all intermediate blobs will be
430 # assiciated with the layer that produces them
431 with scope.NameScope(self.name):
432 if context not in {
433 InstantiationContext.PREDICTION,
434 InstantiationContext.EVAL,
435 InstantiationContext.ACCUMULATE_PRED,
436 }:
437 assert init_net, "Only prediction and eval context don't need init_net"
438 if init_net:
439 self.add_init_params(init_net)
440 if context == InstantiationContext.TRAINING:
441 self.add_train_ops(net)
442 elif context == InstantiationContext.EVAL:
443 self.add_eval_ops(net)
444 elif context == InstantiationContext.ACCUMULATE_PRED:
445 self.add_ops_to_accumulate_pred(net)
446 else:
447 self.add_ops(net)
448
449 if (
450 context in {InstantiationContext.TRAINING, InstantiationContext.EVAL}
451 and self._export_params_for_metrics
452 ):
453 self.add_param_copy_operators(net)
454
455 def add_ops(self, net):
456 # Predict layer implementation.

Callers 6

add_layerMethod · 0.80
generate_predict_netFunction · 0.80
generate_eval_netFunction · 0.80
get_training_netsMethod · 0.80

Calls 6

add_init_paramsMethod · 0.95
add_train_opsMethod · 0.95
add_eval_opsMethod · 0.95
add_opsMethod · 0.95

Tested by 2

get_training_netsMethod · 0.64