Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support nested collections of TensorFlow tensors with t flag #1

Open
danijar opened this issue Jun 13, 2018 · 2 comments
Open

Support nested collections of TensorFlow tensors with t flag #1

danijar opened this issue Jun 13, 2018 · 2 comments

Comments

@danijar
Copy link

danijar commented Jun 13, 2018

Minimal example:

from qj import qj
import tensorflow as tf
tensors = {'foo': tf.constant(0), 'bar': tf.constant(1)}
tensors = qj(tensors, t=True)
with tf.Session() as sess:
  sess.run(tensors)

Output:

IndexError                                Traceback (most recent call last)
<ipython-input-1-6067c4d3b276> in <module>()
      2 import tensorflow as tf
      3 tensors = {'foo': tf.constant(0), 'bar': tf.constant(1)}
----> 4 tensors = qj(tensors, t=True)
      5 with tf.Session() as sess:
      6   sess.run(tensors)

~/.local/lib/python3.5/site-packages/qj/qj.py in qj(x, s, l, d, p, t, n, r, z, b, pad, tfc, tic, toc, time, catch, log_all_calls, _depth)
    192           if f.f_lasti not in fn_calls:
    193             qj._DEBUG_QJ and qj._DISASSEMBLE_FN(f.f_code, f.f_lasti)
--> 194             fn_calls[f.f_lasti] = _find_current_fn_call(f.f_code, f.f_lasti)
    195             qj._FN_MAPS[f.f_code.co_code] = fn_calls
    196           s = fn_calls.setdefault(f.f_lasti, '').strip()

~/.local/lib/python3.5/site-packages/qj/qj.py in _find_current_fn_call(co, lasti)
   1698 
   1699   # Apply stack effects backwards until we arrive at the stack entries for a complete function call
-> 1700   fn_stack = _collect_pops(stack[:-1], stack[-1].stack_depth, [], 0)
   1701 
   1702   if not fn_stack and stack[-1].stack_depth == 0:

~/.local/lib/python3.5/site-packages/qj/qj.py in _collect_pops(stack, depth, pops, skip)
   1511     skip = set_skip_after_current_entry + max(0, skip)
   1512 
-> 1513   pops = _collect_pops(stack, depth + popped_depth, pops, skip)
   1514 
   1515   if len(tokens):  # pylint: disable=g-explicit-length-test

~/.local/lib/python3.5/site-packages/qj/qj.py in _collect_pops(stack, depth, pops, skip)
   1511     skip = set_skip_after_current_entry + max(0, skip)
   1512 
-> 1513   pops = _collect_pops(stack, depth + popped_depth, pops, skip)
   1514 
   1515   if len(tokens):  # pylint: disable=g-explicit-length-test

~/.local/lib/python3.5/site-packages/qj/qj.py in _collect_pops(stack, depth, pops, skip)
   1511     skip = set_skip_after_current_entry + max(0, skip)
   1512 
-> 1513   pops = _collect_pops(stack, depth + popped_depth, pops, skip)
   1514 
   1515   if len(tokens):  # pylint: disable=g-explicit-length-test

~/.local/lib/python3.5/site-packages/qj/qj.py in _collect_pops(stack, depth, pops, skip)
   1511     skip = set_skip_after_current_entry + max(0, skip)
   1512 
-> 1513   pops = _collect_pops(stack, depth + popped_depth, pops, skip)
   1514 
   1515   if len(tokens):  # pylint: disable=g-explicit-length-test

~/.local/lib/python3.5/site-packages/qj/qj.py in _collect_pops(stack, depth, pops, skip)
   1369   expect_extracted_tokens = []
   1370 
-> 1371   se = stack.pop()
   1372   pops_len = len(pops)
   1373   if (pops_len > 1

IndexError: pop from empty list
@iansf
Copy link
Owner

iansf commented Jun 13, 2018 via email

@danijar
Copy link
Author

danijar commented Jun 14, 2018

Thanks, sounds great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants