abrown opened Issue #2053:
While talking to @kubkon about an issue with #2050, we found that the lifetime of the
Tensor
struct was not being propagated downwards to the field correctly. On #2050's branch and usingcd crates/wasi-common && cargo expand wasi
:9014 │ pub type TensorData<'a> = wiggle::GuestPtr<'a, [u8]>; 9015 │ pub struct Tensor<'a> { 9016 │ pub dimensions: TensorDimensions, 9017 │ pub type_: TensorType, 9018 │ pub data: TensorData, 9019 │ }
It looks like it should generate instead
pub data: TensorData<'a>
andpub data: TensorDimensions<'a>
.
abrown labeled Issue #2053:
While talking to @kubkon about an issue with #2050, we found that the lifetime of the
Tensor
struct was not being propagated downwards to the field correctly. On #2050's branch and usingcd crates/wasi-common && cargo expand wasi
:9014 │ pub type TensorData<'a> = wiggle::GuestPtr<'a, [u8]>; 9015 │ pub struct Tensor<'a> { 9016 │ pub dimensions: TensorDimensions, 9017 │ pub type_: TensorType, 9018 │ pub data: TensorData, 9019 │ }
It looks like it should generate instead
pub data: TensorData<'a>
andpub data: TensorDimensions<'a>
.
abrown labeled Issue #2053:
While talking to @kubkon about an issue with #2050, we found that the lifetime of the
Tensor
struct was not being propagated downwards to the field correctly. On #2050's branch and usingcd crates/wasi-common && cargo expand wasi
:9014 │ pub type TensorData<'a> = wiggle::GuestPtr<'a, [u8]>; 9015 │ pub struct Tensor<'a> { 9016 │ pub dimensions: TensorDimensions, 9017 │ pub type_: TensorType, 9018 │ pub data: TensorData, 9019 │ }
It looks like it should generate instead
pub data: TensorData<'a>
andpub data: TensorDimensions<'a>
.
abrown labeled Issue #2053:
While talking to @kubkon about an issue with #2050, we found that the lifetime of the
Tensor
struct was not being propagated downwards to the field correctly. On #2050's branch and usingcd crates/wasi-common && cargo expand wasi
:9014 │ pub type TensorData<'a> = wiggle::GuestPtr<'a, [u8]>; 9015 │ pub struct Tensor<'a> { 9016 │ pub dimensions: TensorDimensions, 9017 │ pub type_: TensorType, 9018 │ pub data: TensorData, 9019 │ }
It looks like it should generate instead
pub data: TensorData<'a>
andpub data: TensorDimensions<'a>
.
github-actions[bot] commented on Issue #2053:
Subscribe to Label Action
cc @kubkon
<details>
This issue or pull request has been labeled: "wasi"Thus the following users have been cc'd because of the following labels:
- kubkon: wasi
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
abrown commented on Issue #2053:
cc: @kubkon, @pchickey, @sunfishcode
abrown commented on Issue #2053:
@kubkon, the workaround we talked about doesn't work: I replaced
(field $data $tensor_data)
with(field $data (struct (field $data (@witx pointer u8)) (field $len u32)))
(an anonymous struct) and get:3 │ --> crates/wasi-common/src/wasi.rs:6:1 4 │ | 5 │ 6 | / wiggle::from_witx!({ 6 │ 7 | | witx: ["WASI/phases/snapshot/witx/wasi_snapshot_preview1.witx", "WASI/phases/ephemeral/witx/wasi_ephemeral_nn.witx"], 7 │ 8 | | ctx: WasiCtx, 8 │ 9 | | }); 9 │ | |___^ 10 │ | 11 │ = help: message: loading witx: Validation(AnonymousStructure { location: Location { path: ".../crates/wasi-common/WASI/phases/ephemeral/witx/wasi_ephemeral_nn.witx", line: 43, column: 12 } })
Looking at
WASI/tools/witx/src/validate.rs:45
, it would appear that I can't use an anonymous struct there, but if I use a named struct then the lifetime issue happens. I guess we actually need #2054 to make this work.
kubkon commented on Issue #2053:
An update here. I've fixed the lifetime issue, but the problem remains with marshalling the memory in and out. Take this bit of
witx
for example:(typename $struct_of_array (struct (field $arr $some_bytes))) (module $something (@interface func (export "summm") (param $a_struct $struct_of_array) (result $error $errno))
The shims we generate for the interface function will look like:
fn summm(ctx: &WasiCtx, memory: &dym wiggle::GuestMemory, a_struct_ptr: i32) -> i32 { // ... }
The trick here is being able to extract the pointer and length of the array from the struct pointer which we currently don't support in
wiggle
. I'm wondering if we should though. @pchickey thoughts?
pchickey closed Issue #2053:
While talking to @kubkon about an issue with #2050, we found that the lifetime of the
Tensor
struct was not being propagated downwards to the field correctly. On #2050's branch and usingcd crates/wasi-common && cargo expand wasi
:9014 │ pub type TensorData<'a> = wiggle::GuestPtr<'a, [u8]>; 9015 │ pub struct Tensor<'a> { 9016 │ pub dimensions: TensorDimensions, 9017 │ pub type_: TensorType, 9018 │ pub data: TensorData, 9019 │ }
It looks like it should generate instead
pub data: TensorData<'a>
andpub data: TensorDimensions<'a>
.
Last updated: Nov 22 2024 at 16:03 UTC