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

No appropriate factory for type v #463

Closed
mofeing opened this issue Dec 17, 2024 · 3 comments
Closed

No appropriate factory for type v #463

mofeing opened this issue Dec 17, 2024 · 3 comments

Comments

@mofeing
Copy link

mofeing commented Dec 17, 2024

I'm trying to use CxxWrap to wrap some C++ code from XLA, and i'm getting the following error:

C++ exception while wrapping module IFRT: No appropriate factory for type v
ERROR: LoadError: No appropriate factory for type v
Stacktrace:
  [1] register_julia_module
    @ ~/.julia/packages/CxxWrap/eWADG/src/CxxWrap.jl:424 [inlined]
  [2] readmodule(so_path_cb::Reactant.IFRT.var"#1#2", funcname::Symbol, m::Module, flags::Nothing)
    @ CxxWrap.CxxWrapCore ~/.julia/packages/CxxWrap/eWADG/src/CxxWrap.jl:815
  [3] wrapmodule(so_path_cb::Function, funcname::Symbol, m::Module, flags::Nothing)
    @ CxxWrap.CxxWrapCore ~/.julia/packages/CxxWrap/eWADG/src/CxxWrap.jl:825
  [4] top-level scope
    @ ~/Developer/Reactant.jl/src/IFRT.jl:6
  [5] include(mod::Module, _path::String)
    @ Base ./Base.jl:557
  [6] include(x::String)
    @ Reactant ~/Developer/Reactant.jl/src/Reactant.jl:1
  [7] top-level scope
    @ ~/Developer/Reactant.jl/src/Reactant.jl:149
  [8] include
    @ ./Base.jl:557 [inlined]
  [9] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2881
 [10] top-level scope
    @ stdin:6
in expression starting at /Users/mofeing/Developer/Reactant.jl/src/IFRT.jl:1
in expression starting at /Users/mofeing/Developer/Reactant.jl/src/Reactant.jl:1

The code I'm trying to wrap is the class DType in here https://github.com/openxla/xla/blob/main/xla/python/ifrt/dtype.h
The class is actually quite simple. No parents, no virtual methods, ...

I have no problem wrapping the DType::Kind enum, but when I register DType like this

    mod.add_type<ifrt::DType>("DType");

I start getting the error.

I'm using CxxWrap v0.16.0 and libcxxwrap_julia v0.13.3

@mofeing
Copy link
Author

mofeing commented Dec 17, 2024

I'm getting the same error with the example in README

struct World
{
  World(const std::string& message = "default hello") : msg(message){}
  World(jlcxx::cxxint_t) : msg("NumberedWorld") {}
  void set(const std::string& msg) { this->msg = msg; }
  const std::string& greet() const { return msg; }
  std::string msg;
  ~World() { std::cout << "Destroying World with message " << msg << std::endl; }
};

JLCXX_MODULE reactant_module_ifrt(jlcxx::Module& mod) {
  mod.add_type<World>("World");
}

some context: due to some symbol conflicts between XLA's LLVM and Julia's LLVM, we only export a list of symbols. i think that CxxWrap just needs access to the declared JLCXX_MODULE (i.e. reactant_module_ifrt) function, but in case there is sth more we need to export, i can add it to the greelist.

@mofeing

This comment was marked as outdated.

@mofeing
Copy link
Author

mofeing commented Dec 17, 2024

So after a lot of tries, i can reproduce the error with only this line of code:

jlcxx::julia_return_type<void>();

jlcxx::create_if_not_exists<void>();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant