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 complex numbers in Tensor Transformation Operations #2577

Closed
sjperkins opened this issue May 30, 2016 · 3 comments
Closed

Support complex numbers in Tensor Transformation Operations #2577

sjperkins opened this issue May 30, 2016 · 3 comments
Assignees
Labels
stat:contribution welcome Status - Contributions welcome type:feature Feature requests

Comments

@sjperkins
Copy link
Contributor

A number of changes have been made to support complex128, but the the tensor transformation op suite seems to be missing this support (At least in tf.pack and tf.concat). See the example script below which works for float32 and float64, but not complex64 and complex128.

Environment info

Operating System: Ubuntu 14.04.4

Installed version of CUDA and cuDNN:
(please attach the output of ls -l /path/to/cuda/lib/libcud*):

$ ls -l /usr/local/cuda-7.5/lib64/libcud*
-rw-r--r-- 1 root root    322936 Aug 15  2015 /usr/local/cuda-7.5/lib64/libcudadevrt.a
lrwxrwxrwx 1 root root        16 Aug 15  2015 /usr/local/cuda-7.5/lib64/libcudart.so -> libcudart.so.7.5
lrwxrwxrwx 1 root root        19 Aug 15  2015 /usr/local/cuda-7.5/lib64/libcudart.so.7.5 -> libcudart.so.7.5.18
-rwxr-xr-x 1 root root    383336 Aug 15  2015 /usr/local/cuda-7.5/lib64/libcudart.so.7.5.18
-rw-r--r-- 1 root root    720192 Aug 15  2015 /usr/local/cuda-7.5/lib64/libcudart_static.a
lrwxrwxrwx 1 3319 users       13 Feb  9 19:48 /usr/local/cuda-7.5/lib64/libcudnn.so -> libcudnn.so.4
lrwxrwxrwx 1 3319 users       17 Feb  9 19:48 /usr/local/cuda-7.5/lib64/libcudnn.so.4 -> libcudnn.so.4.0.7
-rwxrwxr-x 1 3319 users 61453024 Feb  9 00:12 /usr/local/cuda-7.5/lib64/libcudnn.so.4.0.7
-rw-rw-r-- 1 3319 users 62025862 Feb  9 00:12 /usr/local/cuda-7.5/lib64/libcudnn_static.a

If installed from binary pip package, provide:

  1. Which pip package you installed. Python 2 GPU nightly
  2. The output from python -c "import tensorflow; print(tensorflow.version)". 0.8.0

If installed from sources, provide the commit hash:

Steps to reproduce

  1. Vary dtype in the following test script between float32, float64, complex64, complex128

    import numpy as np
    import tensorflow as tf
    
    # Data type for this test case
    dtype=np.float64
    
    # Array shapes
    shape=(10,20,30,1)
    # Expected concatenated array shape
    cshape=(10,20,30,4)
    
    # Helpful lambda
    rn = lambda s, d: tf.random_normal(shape=s, dtype=d)
    
    # Produce random arrays of shape depending on the type
    def r(shape, dtype):
        if dtype in (np.float32, np.float64):
            return rn(shape, dtype)
        elif dtype == np.complex64:
            return tf.complex(rn(shape, np.float32), rn(shape, np.float32))
        elif dtype == np.complex128:
            return tf.complex(rn(shape, np.float64), rn(shape, np.float64))
        else:
            raise ValueError("Unhandled dtype '{dt}'".format(dt=dtype))
    
    XX = r(shape, dtype)
    XY = r(shape, dtype)
    YX = r(shape, dtype)
    YY = r(shape, dtype)
    
    with tf.device('/gpu:0'):
        concat = tf.concat(3, [XX, XY, YX, YY],)
    
    with tf.Session() as S:
        result = S.run(concat)
        assert result.shape == cshape
  2. If dtype is np.complex64 of np.complex128, the following is thrown:

    tensorflow.python.framework.errors.InvalidArgumentError: Cannot assign a device to node 'concat': Could not satisfy explicit device specification '/device:GPU:0' because no supported kernel for GPU devices is available.
         [[Node: concat = Concat[N=4, T=DT_COMPLEX64, _device="/device:GPU:0"](concat/concat_dim, Complex, Complex_1, Complex_2, Complex_3)]]
    Caused by op u'concat', defined at:
      File "tmp/concat_fail.py", line 32, in <module>
        concat = tf.concat(3, [XX, XY, YX, YY],)

What have you tried?

N/A

@ibab
Copy link
Contributor

ibab commented May 31, 2016

While complex64 and complex128 support is almost complete in terms of CPU ops, the majority of kernels hasn't been enabled for the GPU yet, unfortunately.
If the tensorflow devs are interested in bringing more complex64 and complex128 ops to the GPU, we should probably start by polishing the Eigen tensor library a bit (e.g. by writing efficient reduction code for these dtypes).

@martinwicke
Copy link
Member

related but distinct: #3624

@itsmeolivia itsmeolivia self-assigned this Sep 12, 2016
caisq pushed a commit to caisq/tensorflow that referenced this issue Sep 16, 2016
yifeif added a commit that referenced this issue Oct 5, 2016
* Adds a test tf.Assert inside a function.
Change: 134855633

* Remove non-batch methods from operator_pd_cholesky if they have been merged with batch.
Recent changes to tensorflow linear algebra Ops merged batch/non-batch Ops.
This makes their separation un-necessary in OperatorPDCholesky.  Note that OperatorPDBase will still "dispatch based on batch"
since [non]batch-specific implementations still exist for matmul, and will probably
exist for some subset of Ops/Operators.

OperatorPDBase calls the _batch* method if the non-batch method does not exist, so this change will leave the _batch* methods as-is.
Change: 134859101

* Allow tf.py_func to have no return values.
Change: 134873490

* Update ops-related pbtxt files.
Change: 134874339

* Allow graph to be passed in to write_graph.
Change: 134894910

* Update generated Python Op docs.
Change: 134896141

* Increase tolerance in resample_test to reduce flakes.
Change: 134906739

* Clean up of _inner_flatten.
Change: 134977904

* Update typings version, definitions for polymer and fix `gulp compile`
Change: 134979996

* Move inspector panel to its own component.

This reduces the complexity of `Projector` by delegating work to the `InspectorPanel`.

Also related:
 - Add an option to search by other metadata fields.
 - Introduce shared css styles used by every component.
 - Move data querying methods (findNeighbors, queryByField, etc) to data.ts. These methods are used by anyone that has access to the dataset (e.g. both the projector and the inspectorPanel use it).
Change: 134989405

* Created a tensorboard endpoint data/logdir for obtaining the logdir.
Change: 135001927

* numpy meshgrid parity
Change: 135002812

* tensor_bundle interface: accept StringPiece everywhere.

This facilitates the callers in that when passing "char*", "string", or
"StringPiece" no explicit conversions are needed.
Change: 135007288

* tfdbg: 1st check-in of curses UI and a demo

To run the demo, do:

./configure
bazel build tensorflow/python/debug:debug_fibonacci && bazel-bin/tensorflow/python/debug/debug_fibonacci

Barebone/backbone implementation of the curses-based command-line UI for tfdbg.

The fibonacci_network demo constucts a simple TF graph that computes the fibonacci sequence, wraps a tf.Session object with a CLI debugger wrapper session and calls its run() method. which leads to launching of the curses CLI.

The CLI debugger wrapper implements the BaseDebugWrapperSession.

The UI currently has only minimalist command set including
  ni: inspect node info
  lt: list all dumped tensors
  li: list node inputs
  lo: list node output recipients
  pt: print tensor.

Currently supported UI features:
  * command history navigation using Up/Down keys: with or without prefix
  * scroll large output with PgUp/PgDown/Home/End keys
  * terminal resize response

See CLI help output for more information.
Change: 135010660

* Add comment that argument can be either dense Tensor or SparseTensor.
Change: 135010699

* Move MonitoredSession and related utilities from tf.contrib.learn to tf.train
Change: 135010812

* Update generated Python Op docs.
Change: 135011886

* Documentation fixes for tf.contrib.rnn.
Change: 135017686

* Fix bug in pylint whitelist error check. Fix the pylint errors it missed
before.
Change: 135020083

* Update generated Python Op docs.
Change: 135021476

* Fix bug when changing distance metric in the inspector panel.
Change: 135023065

* Expose MetricSpec.
Change: 135032476

* Fixing tf.gfile's file writing in append mode. Earlier, append was the same as write mode. Now we distinguish between the two.
Change: 135033928

* * Supports defining overloaded functions. I.e., defers the
  instantiation of the function definition until all input types are known.
* for convenience, adds more convert_to_tensor calls.
* adds None checking for better error reporting.
* cleanup function_test a bit so that it uses tf.logging.info consistently.
* changes the convention for coming up a function's name:
  * if func_name is explicitly given, stick with it.
  * otherwise, come up a name based on the python function info and a hash of the
    function definition.
* uses __doc__ to fill in func's op def description in the proto.
Change: 135036941

* Adding a ConditionalAccumulator class, which allows us to accumulate non-stale
gradients. Also adds SparseConditionalAccumulator, which supports IndexedSlices.
Change: 135037419

* Implement gradients for ndtr, log_ndtr. This avoids automatic differentiation going through several tf.select code-paths.
Change: 135038724

* Update ops-related pbtxt files.
Change: 135039308

* Update generated Python Op docs.
Change: 135039979

* Add regression signature to half_plus_two model.
Change: 135041920

* Made _Transformer logging less verbose
Change: 135048006

* Add warning to os_setup for dev setup. Fixes #2844 (well, documents the failure at least).
Change: 135050562

* Use BlockingCounter to do some minor cleanups.
Change: 135051470

* Documented the `data/logdir` endpoint in http_api.md.
Change: 135052793

* Added a const version of the functors specialized to process complex numbers on CUDA devices.
Change: 135053757

* Parallelize AvgPool on CPU.

Benchmark                          Base (ns)  New (ns) Improvement
------------------------------------------------------------------
BM_AvgPool_32_112_112_64_3_3_2_VALID_4 30417641  10925222    +64.1%
BM_AvgPool_32_56_56_192_3_3_2_VALID_4 16509939   7054348    +57.3%
BM_AvgPool_32_28_28_352_3_3_2_VALID_4  6494974   2527951    +61.1%
BM_AvgPool_32_14_14_576_3_3_2_VALID_4  2050825    853309    +58.4%
BM_AvgPool_32_112_112_64_3_3_2_SAME_4 31002019   9790387    +68.4%
BM_AvgPool_32_56_56_192_3_3_2_SAME_4 17234631   6463952    +62.5%
BM_AvgPool_32_28_28_352_3_3_2_SAME_4  7171668   3067244    +57.2%
BM_AvgPool_32_14_14_576_3_3_2_SAME_4  2685654   1175420    +56.2%
Change: 135053961

* minor changes in tf.learn.
Allow specifying saving checkpointing every N steps instead of every N secs, which is already supported by basic_session_run_hooks.CheckpointSaverHook but not supported by learn.RunConfig and estimator.
Change: 135055051

* Update generated Python Op docs.
Change: 135057486

* Cleanups to distributions tests.
  - Remove hack for sampling in beta test. Gamma sampler does not emit 0s any more.
  - Change tests to camel case..
Change: 135065764

* Show search results in the inspector panel.
Change: 135104864

* Get rid of vz-projector.ts's concept of 'highlighted points' and 'color accessors', moving slowly towards a model where we don't call accessors in inner loops. Visualizers have direct access to the selected points and neighbors, and can decide their own semantics for display. Projector now prepares a color array of unselected points, which the visualizers use to render. 3D labels are rendered with unselected point colors. Add the HoverContext for observing and reporting hover events.
Change: 135109425

* Migrating skflow examples to the tensorflow/examples/learn directory. Fixes #3364.
Change: 135109832

* tfdbg: CLI demo: debug_mnist

To run the demo, do:
bazel build -c opt tensorflow/python/debug:debug_mnist && bazel-bin/tensorflow/python/debug/debug_mnist --debug

See the doc file at: tensorflow/python/debug/examples/README.md for more details.

Other related and supporting changes:
  * Move function "parse_node_or_tensor_name" from analyzer_cli.py to debug_data.py. Also moved related unit tests.
  * Add title bar to CursesUI
  * Add the predicate (filter) function has_inf_or_nan to module debug_data. Also added unit tests.
  * analyzer_cli.py: Add methods "add_tensor_filter" and "get_tensor_filter" to support filtering of dumped intermediate tensors.
  * local_cli.py: Add flag to on-run-start command "run", e.g., "run -f has_inf_or_nan", along with supporting logic for the run-till-a-tensor-filter-is passed mode.
  * local_cli.py: Improved on-run-start summary lines for feed and fetch.
Change: 135115989

* Update left navigation for Python API.
Change: 135121210

* Fix ZeroInitializerOp for GPUs

Also changed it to use the C++ shape inference function.
Change: 135123217

* Use softplus in bernoulli.
Change: 135125153

* Automated rollback of change 135036941
Change: 135125564

* Get dnn_sampled_softmax_classifier_test to start running open source tests again. This change simply relaxes the testing criteria for a couple of tests so that everything can run in opensource tests regularly.
Change: 135126062

* Made the h2 in the graph panel only appear if there is a title. This removes a little white space at the top that is not draggable. Updated screen diff integration tests.
Change: 135126088

* Improved documentation of session_creator of MonitoredSession.
Change: 135127073

* Fix compilation error on some non-standard toolchains
Change: 135127376

* Add an internal-only C++ wrapper around function_ops.
Change: 135130656

* Move the left hand side projections panel to its own polymer component, vz-projector-projections-panel, and wire scatter plot updates through the vz-projector.
Change: 135130797

* Update generated Python Op docs.
Change: 135131860

* enable tile for complex inputs in gpu, github issue #2577
Change: 135135194

* Taking //tensorflow/examples/learn:examples_test out as it is too long for
'larget' test and breaking OSS builds.
Change: 135138752

* Disable dnn_test.
Change: 135139116

* Fix missing close-quote in markdown for tf.contrib.distributions.Distribution
Change: 135140486

* Update generated Python Op docs.
Change: 135142722

* Convert sample_rate attribute for AudioSummary into an input.

This is helpful for graphs that consume or generate audio with variable sample rates. Adds an AudioSummaryV2 op and marks AudioSummary as deprecated. The same AudioSummaryOp kernel handles both AudioSummary and AudioSummaryV2.
Change: 135148773

* Update ops-related pbtxt files.
Change: 135152974

* Update generated Python Op docs.
Change: 135153503

* * Supports defining overloaded functions. I.e., defers the
  instantiation of the function definition until all input types are known.
* for convenience, adds more convert_to_tensor calls.
* adds None checking for better error reporting.
* cleanup function_test a bit so that it uses tf.logging.info consistently.
* changes the convention for coming up a function's name:
  * if func_name is explicitly given, stick with it.
  * otherwise, come up a name based on the python function info and a hash of the
    function definition.
* uses __doc__ to fill in func's op def description in the proto.
Change: 135156837

* Improve UI of inspector panel (neighbors + search results).

- React when hovering over results
- Improve layout for long text by overflowing text with '...'
- On mouse hover, show the full text (title attribute on anchor).
- Remove dead code in vz-projector-data-panel.html
Change: 135165962

* go: Add a README.md with installation instructions.

The Go API is still decidedly an "alpha version" and the
installation process would ideally be much smoother. But
the instructions included here are at least functional.

Another step towards #10
Change: 135166392

* Add tf.contrib.distributions to API leftnav
Change: 135167978

* Change to use existing macros.
Change: 135176011
@itsmeolivia itsmeolivia assigned rryan and unassigned itsmeolivia Oct 12, 2016
@aselle aselle added type:feature Feature requests and removed enhancement labels Feb 9, 2017
@girving
Copy link
Contributor

girving commented Jun 16, 2017

Looks like pack and concat support complex128 now.

@girving girving closed this as completed Jun 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:contribution welcome Status - Contributions welcome type:feature Feature requests
Projects
None yet
Development

No branches or pull requests

7 participants