swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.49k stars 10.35k forks source link

[SR-8605] error send/recv Variants if you create a dataset in TLC #51120

Closed 83b09dda-53f5-4663-b44c-87fd2a9a8717 closed 5 years ago

83b09dda-53f5-4663-b44c-87fd2a9a8717 commented 6 years ago
Previous ID SR-8605
Radar None
Original Reporter @marcrasi
Type Bug
Status Closed
Resolution Done
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Swift for TensorFlow | |Labels | Bug, GPE | |Assignee | bgogul (JIRA) | |Priority | Medium | md5: 3b97896444b1806e6607cf894fd495e3

Issue Description:

Execute this in Jupyter or the REPL:

import TensorFlow
let scalars = Tensor<Float>(rangeFrom: 0, to: 5, stride: 1)
let dataset = SingleValueDataset(elements: scalars, elementShape: [])

You'll get:

error: <REPL>:3:15: error: value cannot be used by non-TensorFlow API
let dataset = SingleValueDataset(elements: scalars, elementShape: [])
              ^
<REPL>:3:15: note: value used here
let dataset = SingleValueDataset(elements: scalars, elementShape: [])
              ^

This seems pretty important to fix or circumvent for the tutorial, because we'll want to create the dataset in one cell and then use it later.

ed4ae5fb-5ade-43c3-bf64-26e47fc0876d commented 6 years ago

I don't think this is going to work in the near term.

The problem here is that the dataset op is producing a Variant result value, which is a non-tensor value. We currently cannot send/receive variants to swift code. This is something that can be implemented, but hongm (JIRA User) is the best person to work on this.

ed4ae5fb-5ade-43c3-bf64-26e47fc0876d commented 6 years ago

Variants are effectively C++ void*'s. We can support sending and receiving these in S4TF, but we need to wire up a few ops (or repurpose existing ones) to send/recv the pointer value, and enhance partitioning to generate these.

83b09dda-53f5-4663-b44c-87fd2a9a8717 commented 6 years ago

I realized that we can work around this in the tutorial by wrapping the dataset construction in a function that we don't call until we actually use the dataset.

83b09dda-53f5-4663-b44c-87fd2a9a8717 commented 6 years ago

The workaround I describe is pretty nice, so I'm removing the tutorial label.

swift-ci commented 6 years ago

Comment by Mingsheng Hong (JIRA)

We've landed the GPE infra needed.

bgogul (JIRA User), Gogul, with your recent work of completing send/recving resource tensor support, and turning on the feature flag, is this bug ready to be closed? The outstanding item as I can think of is to remove that feature flag.

swift-ci commented 5 years ago

Comment by Gogul Balakrishnan (JIRA)

The code snippet works correctly in REPL.