Пример #1
0
	def run(self, evals, feed_dict=None, breakpoints=None, break_immediately=False):
		"""
		starts the debug session
		"""
		if not isinstance(evals,list):
			evals=[evals]
		if feed_dict is None:
			feed_dict={}
		if breakpoints is None:
			breakpoints=[]

		self.state=RUNNING
		self._original_evals=evals
		self._original_feed_dict=feed_dict
		self._exe_order=op_store.compute_exe_order(evals)
		self._init_evals_bps(evals, breakpoints)

		# convert cache keys to strings
		for k,v in feed_dict.items():
			if not isinstance(k,str):
				k=k.name
			self._cache[k]=v

		op_store.register_dbsession(self)

		if break_immediately:
			return self._break()
		else:
			return self.c()
Пример #2
0
    def run(self, evals, feed_dict=None, breakpoints=None, break_immediately=False):
        """
		starts the debug session
		"""
        if not isinstance(evals, list):
            evals = [evals]
        if feed_dict is None:
            feed_dict = {}
        if breakpoints is None:
            breakpoints = []

        self.state = RUNNING
        self._original_evals = evals
        self._original_feed_dict = feed_dict
        self._exe_order = op_store.compute_exe_order(evals)
        self._init_evals_bps(evals, breakpoints)

        # convert cache keys to strings
        for k, v in feed_dict.items():
            if not isinstance(k, str):
                k = k.name
            self._cache[k] = v

        op_store.register_dbsession(self)

        if break_immediately:
            return self._break()
        else:
            return self.c()
Пример #3
0
	def _init_evals_bps(self, evals, breakpoints):
		# If an eval or bp is the tf.Placeholder output of a tdb.PythonOp, replace it with its respective PythonOp node
		evals2=[op_store.get_op(t) if op_store.is_htop_out(t) else t for t in evals]
		breakpoints2=[op_store.get_op(t) if op_store.is_htop_out(t) else t for t in breakpoints]
		# compute execution order
		self._exe_order=op_store.compute_exe_order(evals2) # list of nodes
		# compute evaluation set
		"""
		HTOps may depend on tf.Tensors that are not in eval. We need to have all inputs to HTOps ready
		upon evaluation. 

		1. all evals that were originally specified are added
		2. each HTOp in the execution closure needs to be in eval (they won't be eval'ed automatically by Session.run)
		3. if an input to an HTOp is a tf.Tensor (not a HT placeholder tensor), it needs to be in eval as well (it's not
			tensorflow so we'll have to manually evaluate it). Remember, we don't track Placeholders because we instead 
			run the HTOps that generate their values.
		"""
		self._evalset=set([e.name for e in evals2])
		for e in self._exe_order:
			if isinstance(e,HTOp):
				self._evalset.add(e.name)
				for t in e.inputs:
					if not op_store.is_htop_out(t):
						self._evalset.add(t.name)

		# compute breakpoint set
		self._bpset=set([bp.name for bp in breakpoints2])
Пример #4
0
    def _init_evals_bps(self, evals, breakpoints):
        # If an eval or bp is the tf.Placeholder output of a tdb.PythonOp, replace it with its respective PythonOp node
        evals2 = [op_store.get_op(t) if op_store.is_htop_out(t) else t for t in evals]
        breakpoints2 = [op_store.get_op(t) if op_store.is_htop_out(t) else t for t in breakpoints]
        # compute execution order
        self._exe_order = op_store.compute_exe_order(evals2)  # list of nodes
        # compute evaluation set
        """
		HTOps may depend on tf.Tensors that are not in eval. We need to have all inputs to HTOps ready
		upon evaluation. 

		1. all evals that were originally specified are added
		2. each HTOp in the execution closure needs to be in eval (they won't be eval'ed automatically by Session.run)
		3. if an input to an HTOp is a tf.Tensor (not a HT placeholder tensor), it needs to be in eval as well (it's not
			tensorflow so we'll have to manually evaluate it). Remember, we don't track Placeholders because we instead 
			run the HTOps that generate their values.
		"""
        self._evalset = set([e.name for e in evals2])
        for e in self._exe_order:
            if isinstance(e, HTOp):
                self._evalset.add(e.name)
                for t in e.inputs:
                    if not op_store.is_htop_out(t):
                        self._evalset.add(t.name)

                        # compute breakpoint set
        self._bpset = set([bp.name for bp in breakpoints2])