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

Support for sequence/map types #30

Closed
snc1011 opened this issue Mar 28, 2023 · 9 comments
Closed

Support for sequence/map types #30

snc1011 opened this issue Mar 28, 2023 · 9 comments
Assignees
Labels
enhancement New feature or request p: low low priority

Comments

@snc1011
Copy link

snc1011 commented Mar 28, 2023

I'm trying to execute the code below

use ort::{
    tensor::{
        InputTensor,
        DynOrtTensor,
        FromArray,
        OrtOwnedTensor
    },
    Environment,
    LoggingLevel,
    SessionBuilder,
    OrtResult
};
use polars::{
    datatypes::Float32Type,
    prelude::*
};
use ndarray::IxDyn;


fn main () -> OrtResult<()> {

    //Lendo o dataframe usando Polars
    let dataframe = CsvReader::from_path("random_df.csv")
        .unwrap()
        .has_header(false)
        .finish()
        .unwrap()
        .to_ndarray::<Float32Type>()
        .unwrap();

    //Criando o ambiente
    let environment = Environment::builder()
	    .with_name("random_df_environment")
	    .with_log_level(LoggingLevel::Warning)
	    .build()?
	    .into_arc();

    //Criando a sessão
    let session = SessionBuilder::new(&environment)?
	    .with_model_from_file("random_df.onnx")?;

    let input = vec![
        InputTensor::from_array(dataframe.into_dyn())
    ];

    let outputs: Vec<DynOrtTensor<ndarray::Dim<ndarray::IxDynImpl>>> = session
        .run(input)
        .unwrap();
    let scores = &outputs[0];
    let scores: OrtOwnedTensor<'_, i64, IxDyn> = scores.try_extract()?;
    let scores = scores.view();
    let scores = scores.view();
    println!("{:}", scores);
    Ok(())
}

But i'm getting the Error: PointerShouldBeNull("CastTypeInfoToTensorInfo")
I googled it but didn't find a thing, could anyone help?

@decahedron1
Copy link
Member

Could you share your random_df.onnx model?

@snc1011
Copy link
Author

snc1011 commented Mar 28, 2023

@decahedron1
Copy link
Member

The error occurs because the graph contains an output with type sequence<map<int64,float32>>, which ort does not currently support.

@decahedron1 decahedron1 self-assigned this Mar 28, 2023
@decahedron1 decahedron1 added the enhancement New feature or request label Mar 28, 2023
@snc1011
Copy link
Author

snc1011 commented Mar 28, 2023

is there a workaround for this? This is a Logistic Regression model trained with random data for test purposes

@decahedron1
Copy link
Member

Not at the moment, no

@snc1011
Copy link
Author

snc1011 commented Apr 6, 2023

To anyone who might face a similar problem, there's a quick solution: when serializing the model to the onnx format, remember to "deactivate" the ZipMap, in python pass the {'zipmap': False} dict to the convert_sklearn or to_onnx's options parameter as shown:

initial_type = [('float_input', FloatTensorType([None, train_x.shape[1]]))]
onnx = convert_sklearn(clf, initial_types=initial_type, options={'zipmap': False})
with open("lr_iris.onnx", "wb") as f:
    f.write(onnx.SerializeToString())

@decahedron1 decahedron1 mentioned this issue Apr 6, 2023
@snc1011 snc1011 closed this as completed Apr 14, 2023
@snc1011 snc1011 reopened this Apr 14, 2023
@decahedron1 decahedron1 added the p: low low priority label Jun 3, 2023
@decahedron1 decahedron1 changed the title PointerShouldBeNull("CastTypeInfoToTensorInfo") Support for sequence/map types Jul 16, 2023
@decahedron1 decahedron1 mentioned this issue Aug 16, 2023
Merged
8 tasks
@ikrivosheev
Copy link
Contributor

@decahedron1 Did my PR(#102) close the issue? Or I forgot about something?

@decahedron1
Copy link
Member

@ikrivosheev All that's required after #102 is just the logic to convert between ORT Values and Rust HashMap/Vecs in src/value.rs.

@ikrivosheev
Copy link
Contributor

@decahedron1 sorry for the delay... I worked on other problem. Do you need help with release 2.0? I saw, that you already added convert logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request p: low low priority
Projects
No open projects
Status: In Progress
Development

No branches or pull requests

3 participants