1 #include "caffe2/operators/create_scope_op.h" 4 caffe2_workspace_stack_debug,
6 "Enable debug checks for CreateScope's workspace stack");
9 CAFFE_KNOWN_TYPE(detail::WorkspaceStack);
12 bool CreateScopeOp<CPUContext>::RunOnDevice() {
13 auto* ws_stack = OperatorBase::Output<detail::WorkspaceStack>(0);
18 REGISTER_CPU_OPERATOR(CreateScope, CreateScopeOp<CPUContext>);
20 SHOULD_NOT_DO_GRADIENT(CreateScope);
22 OPERATOR_SCHEMA(CreateScope).NumInputs(0).NumOutputs(1).SetDoc(R
"DOC( 23 'CreateScope' operator initializes and outputs empty scope that is used 24 by Do operator to store local blobs 28 bool HasScopeOp<CPUContext>::RunOnDevice() {
29 const auto& ws_stack = OperatorBase::Input<detail::WorkspaceStack>(0);
31 auto* output = Output(0, {1}, at::dtype<bool>());
32 bool* output_value = output->template mutable_data<bool>();
33 *output_value = !ws_stack.empty();
37 REGISTER_CPU_OPERATOR(HasScope, HasScopeOp<CPUContext>);
39 SHOULD_NOT_DO_GRADIENT(HasScope);
41 OPERATOR_SCHEMA(HasScope).NumInputs(1).NumOutputs(1).SetDoc(R
"DOC( 42 Checks whether scope blob has any saved scopes left A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...