Example #1
0
        public void __enter__()
        {
            if (_new_stack)
            {
                // Clear the control_dependencies graph.
                _old_stack = _graph._control_dependencies_stack;
                _graph._control_dependencies_stack = new Queue <_ControlDependenciesController>();

                // Clear the control_flow_context too.
                _old_control_flow_context = _graph._get_control_flow_context();
                _graph._set_control_flow_context(null);
            }

            _graph._push_control_dependencies_controller(this);
        }
Example #2
0
        public Operation(IntPtr handle, Graph g = null)
        {
            if (handle == IntPtr.Zero)
            {
                return;
            }

            _handle  = handle;
            _graph   = g ?? ops.get_default_graph();
            _outputs = new Tensor[NumOutputs];
            for (int i = 0; i < NumOutputs; i++)
            {
                _outputs[i] = new Tensor(this, i, OutputType(i));
            }

            // Dict mapping op name to file and line information for op colocation
            // context managers.
            _control_flow_context = _graph._get_control_flow_context();

            // Note: _control_flow_post_processing() must not be called here, the caller is responsible for calling it when using this constructor.
        }