-
Notifications
You must be signed in to change notification settings - Fork 21
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
Help to fix issues in JlrsReflect generated code #76
Comments
If you're using the dev branch, you need to use the Reflect module from
Jlrs.jl.
Op di 14 mrt. 2023 01:59 schreef Yanqing Jing ***@***.***>:
… Hi, I have some types defined in Julia, then I used JlrsReflect generated
rust wrappers, there's some names spaces changes in the most recent version
(dev branch) of of jlrs, which I have fixed, but there's still some other
issues, cau you help to fix? Thank you in advance!
Julia Code
struct JbTensor
name::String
dtype::UInt32
dims::Vector{Int64}
memory_ptr::Union{Array{Real, 1}, Array{Real, 2}, Array{Real, 3}, Array{Real, 4}}
memory_type_id::Int64
memory_type::UInt32
byte_size::UInt64
end
struct JbError
message::String
end
struct InferResponse
output_tensors::Vector{JbTensor}
error::JbError
end
struct InferRequest
request_id::String
correlation_id::Int32
model_name::String
model_version::Int32
flags::Int32
inputs::Vector{JbTensor}
requested_output_names::Vector{String}
end
generated rust code with Fixing
use jlrs::{
convert::unbox::Unbox,
data::{layout::valid_layout::{ValidLayout, ValidField}, types::typecheck::Typecheck},
prelude::*,
};
#[repr(C)]
#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck)]
#[jlrs(julia_type = "Main.InferRequest")]
pub struct InferRequest<'frame, 'data> {
pub request_id: ::std::option::Option<::jlrs::data::managed::string::StringRef<'frame>>,
pub correlation_id: i32,
pub model_name: ::std::option::Option<::jlrs::data::managed::string::StringRef<'frame>>,
pub model_version: i32,
pub flags: i32,
pub inputs: ::std::option::Option<::jlrs::data::managed::array::ArrayRef<'frame, 'data>>,
pub requested_output_names:
::std::option::Option<::jlrs::data::managed::array::ArrayRef<'frame, 'data>>,
}
#[repr(C)]
#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck)]
#[jlrs(julia_type = "Main.InferResponse")]
pub struct InferResponse<'frame, 'data> {
pub output_tensors:
::std::option::Option<::jlrs::data::managed::array::ArrayRef<'frame, 'data>>,
pub error: JbError<'frame>,
}
#[repr(C)]
#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck)]
#[jlrs(julia_type = "Main.JbError")]
pub struct JbError<'frame> {
pub message: ::std::option::Option<::jlrs::data::managed::string::StringRef<'frame>>,
}
#[repr(C)]
#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck)]
#[jlrs(julia_type = "Main.JbTensor")]
pub struct JbTensor<'frame, 'data> {
pub name: ::std::option::Option<::jlrs::data::managed::string::StringRef<'frame>>,
pub dtype: u32,
pub dims: ::std::option::Option<::jlrs::data::managed::array::ArrayRef<'frame, 'data>>,
pub memory_ptr: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'frame, 'data>>,
pub memory_type_id: i64,
pub memory_type: u32,
pub byte_size: u64,
}
—
Reply to this email directly, view it on GitHub
<#76>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOQBHH4VOG62PQKFQFF4MZDW367FRANCNFSM6AAAAAAVZZCTNQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Hi, it seems that I still can not get this code working, The current issue is that when I try to create an array of JuliaString or some other structs like the JbTensor here using the Array::from_slice method, The compiler complains that ForeignType is not satisfied. |
That method requires that the element type implements This area definitely deserves some more attention, I admit it's hard to use with non- |
Thank you very much for the comment, I'm sure your time is spent on more import issues and the project is being actively developed. When I tried the following code
I got complains that trait bound 'Target' is not satisfied. |
|
Hi, the above comment helped me to pass a array of JuliaString from Rust to Julia.
Thanks in advance! |
There are two cases:
The second approach only makes sense imo when writing a library that should be exposed to Julia (see RustFFT.jl for example). |
Hi, I have some types defined in Julia, then I used JlrsReflect generated rust wrappers, there's some names spaces changes in the most recent version (dev branch) of of jlrs, which I have fixed, but there's still some other issues, cau you help to fix? Thank you in advance!
Julia Code
generated rust code with Fixing
The text was updated successfully, but these errors were encountered: