Skip to content

Conversation

@zaleslaw
Copy link
Contributor

No description provided.

@zaleslaw
Copy link
Contributor Author

Dear @karllessard could you have a look to this small PR? Could it be merged?

Copy link
Collaborator

@karllessard karllessard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @zaleslaw , thanks for the PR! I like it overall, we need more of those. Just added a few comments and we are good to merge

System.out.println("---- Scalar tensor ---------");
System.out.println("DataType: " + rank0Tensor.dataType().name());
System.out.println("Rank: " + rank0Tensor.data().rank());
System.out.println("NumElements: " + rank0Tensor.data().size());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a user should access data() only when he's interested in doing some read/write operations to the tensor memory, as it might move the tensor from some remote location or from GPU memory to the local CPU for this purpose.

Therefore, if the user intent is only to display some metadata about the shape of the tensor, the tensor.shape() method is probably better. (rank0Tensor.shape().numDimensions() and rank0Tensor.shape().size() respectively in this case).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, but better to have rank() method in tensor interface for next different logic handling for tensors with the different rank

Agree, that maybe I should call methods on data() only for read/write purposes

@zaleslaw
Copy link
Contributor Author

@karllessard I'll fix and return.

@zaleslaw
Copy link
Contributor Author

@karllessard fixed the review, please have a look

Copy link
Collaborator

@karllessard karllessard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right, I will probably add a bunch of more examples on how to create tensors because there is many other ways to do it

@karllessard karllessard merged commit c30c550 into tensorflow:master May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants