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

Go TensorFlow 1.4.0: DataType 21 is not supported #14806

Closed
is8ac opened this issue Nov 22, 2017 · 5 comments
Closed

Go TensorFlow 1.4.0: DataType 21 is not supported #14806

is8ac opened this issue Nov 22, 2017 · 5 comments
Assignees
Labels
stat:contribution welcome Status - Contributions welcome

Comments

@is8ac
Copy link

is8ac commented Nov 22, 2017


System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Arch linux
  • TensorFlow installed from (source or binary): Binary
  • TensorFlow version (use command below): 1.4.0
  • Python version: NA (using go)
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version: 9.0.176-4 / 7.0.3-1
  • GPU model and memory: GTX 1060 6GB
  • Exact command to reproduce:

Describe the problem

Calling the Value() method on the evaluated output tensor of dataset related operations from the go package fails with the error DataType 21 is not supported. It looks like op.TextLineDataset() produces a tensor of type tf.Half can't be converted to a go type?
I may be using the datasets wrong. If so, the error and/or documentation should be improved.

Source code / logs

package main

import (
	tf "github.com/tensorflow/tensorflow/tensorflow/go"
	"github.com/tensorflow/tensorflow/tensorflow/go/op"
)

func main() {
	s := op.NewScope()
	textLineHandle := op.TextLineDataset(s,
		op.Const(s.SubScope("filename"), "dataset.txt"),
		op.Const(s.SubScope("compression_type"), ""),
		op.Const(s.SubScope("buffer_size"), int64(1)),
	)
	graph, err := s.Finalize()
	if err != nil {
		panic(err)
	}
	sess, err := tf.NewSession(graph, nil)
	if err != nil {
		panic(err)
	}
	results, err := sess.Run(nil, []tf.Output{textLineHandle}, []*tf.Operation{})
	if err != nil {
		panic(err)
	}
	_ = results[0].Value()
}

Produces:

[isaac@d6-arch tfes]$ go run dataset_demo.go 
2017-11-22 11:06:36.945842: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2017-11-22 11:06:37.042484: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:892] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2017-11-22 11:06:37.042786: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties: 
name: GeForce GTX 1060 6GB major: 6 minor: 1 memoryClockRate(GHz): 1.7085
pciBusID: 0000:01:00.0
totalMemory: 5.93GiB freeMemory: 4.58GiB
2017-11-22 11:06:37.042801: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0, compute capability: 6.1)
panic: BUG: Please report at https://github.com/tensorflow/tensorflow/issues with the note: Go TensorFlow 1.4.0: DataType 21 is not supported

goroutine 1 [running]:
github.com/tensorflow/tensorflow/tensorflow/go.typeOf(0xc400000015, 0x0, 0x0, 0x0, 0x49d72d, 0x4c6e40)
	/home/isaac/go/src/github.com/tensorflow/tensorflow/tensorflow/go/tensor.go:273 +0x14d
github.com/tensorflow/tensorflow/tensorflow/go.(*Tensor).Value(0xc42000c0e0, 0x0, 0xc420057f60)
	/home/isaac/go/src/github.com/tensorflow/tensorflow/tensorflow/go/tensor.go:175 +0x8d
main.main()
	/home/isaac/go/src/github.com/is8ac/tfes/dataset_demo.go:27 +0x2b0
exit status 2
@shivaniag shivaniag added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Nov 27, 2017
@shivaniag
Copy link
Contributor

@mrry could you please take a look.

@mrry mrry assigned asimshankar and unassigned mrry Nov 27, 2017
@mrry
Copy link
Contributor

mrry commented Nov 27, 2017

I think DataType 21 is DT_VARIANT, which is indeed the expected dtype for a TextLineDataset:

DT_VARIANT = 21; // Arbitrary C++ data types

I'm not sure why it's not supported in the Go API, but there is a TODO here:

// TODO(keveman): support DT_VARIANT representation in go.

Since I believe @keveman is busy with other things ;), I'm reassigning this to @asimshankar who owns the Go API.

@asimshankar
Copy link
Contributor

asimshankar commented Nov 28, 2017

As @mrry mentioned, op.TextLineDataset produces a DT_VARIANT tensor.
I'm not quite sure what we'd want .Value() on it to return. Could you clarify what you were expecting it to?

Note that the dataset tensor is meant for consumption by iterators, and you can construct dataset tensors and create iterators over them in Go (though, you have to do it from the primitive ops as we don't have the convenience APIs as we do in the tf.data module in Python). For example:

package main

import (
        "fmt"
        tf "github.com/tensorflow/tensorflow/tensorflow/go"
        "github.com/tensorflow/tensorflow/tensorflow/go/op"
)

func main() {
        s := op.NewScope()
        dataset := op.TextLineDataset(s,
                op.Const(s.SubScope("filename"), "dataset.txt"),
                op.Const(s.SubScope("compression_type"), ""),
                op.Const(s.SubScope("buffer_size"), int64(1)),
        )

       
        outputTypes := []tf.DataType{tf.String}
        outputShapes := []tf.Shape{tf.ScalarShape()}
        iterator := op.Iterator(s, "", "", outputTypes, outputShapes)
        next := op.IteratorGetNext(s, iterator, outputTypes, outputShapes)
        initIterator := op.MakeIterator(s, dataset, iterator)
       
        graph, err := s.Finalize()
        if err != nil {
                panic(err)
        }
        sess, err := tf.NewSession(graph, nil)
        if err != nil {
                panic(err)
        }
        if _, err = sess.Run(nil, nil, []*tf.Operation{initIterator}); err != nil {
                panic(err)
        }
        results, err := sess.Run(nil, next, []*tf.Operation{})
        if err != nil {
                panic(err)
        }
        v := results[0].Value()
        fmt.Printf("%T: %v\n", v, v)
}

I agree the error message can be improved, will try to write up a change for that.
In the mean time, could you clarify what you may want dataset.Value() to return?

@asimshankar asimshankar added stat:awaiting response Status - Awaiting response from author and removed stat:awaiting tensorflower Status - Awaiting response from tensorflower labels Nov 28, 2017
@is8ac
Copy link
Author

is8ac commented Nov 28, 2017

I didn't have any expectations regarding what dataset.Value() returns, I was just playing with the OP to see what it did and was surprised by the error.

Now that you have shown me the usage of op.Iterator(), I know how to use datasets correctly, and don't need dataset.Value() to return anything in particular. Just a clearer error message would be nice.

Does there currently exist documentation / tutorials for the Go bindings beyond the GoDocs? I'm writing some Go TensorFlow tutorials and would be happy to contribute.

@asimshankar
Copy link
Contributor

Unfortunately, no, there isn't any additional documentation beyond the godoc. We look forward to your tutorials and more community support/contributions. Thanks!

@shivaniag shivaniag added stat:contribution welcome Status - Contributions welcome and removed stat:awaiting response Status - Awaiting response from author labels Nov 28, 2017
sb2nov pushed a commit to sb2nov/tensorflow that referenced this issue Dec 1, 2017
@sb2nov sb2nov closed this as completed in 2ab7e9d Dec 2, 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
Projects
None yet
Development

No branches or pull requests

4 participants