Code Monkey home page Code Monkey logo

Comments (4)

wkcn avatar wkcn commented on June 2, 2024

Thank you:)
Do you want to load the parameters in C++?
I think you can try the function

  static void Load(const std::string &file_name,
                   std::vector<NDArray> *array_list = nullptr,
                   std::map<std::string, NDArray> *array_map = nullptr);

or

MXNET_DLL int MXNDArrayLoad(const char* fname,
                            mx_uint *out_size,
                            NDArrayHandle** out_arr,
                            mx_uint *out_name_size,
                            const char*** out_names);

in $MXNET_HOME/cpp-package/include/mxnet-cpp/ndarray.h and $MXNET_HOME/include/mxnet/c_api.h.

And there are some examples to use the functions.(https://github.com/apache/incubator-mxnet/blob/master/cpp-package/example/feature_extract/feature_extract.cpp

https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/ndarray/utils.py)

from mobulaop.

nuaawzl avatar nuaawzl commented on June 2, 2024

Thanks, I want to load the symbol and parameters in C++. But the model use a custom operator. MXNet C++ has no the operator, so I can't load the json file.

from mobulaop.

wkcn avatar wkcn commented on June 2, 2024

@nuaawzl
I found MXSymbolCreateFromFile is used to load all symbols, including Custom Operator.
And the custom operator is registered in python/mxnet/operator.py.

I think it may be a solution.

  1. get creator_func of the custom operator in Python. Cython may be useful.
  2. use MXCustomOpRegister to register the custom operator in C++
  3. use MXSymbolCreateFromFile to load all symbols in C++

from mobulaop.

nuaawzl avatar nuaawzl commented on June 2, 2024

Thank you very much. I coded the new operator and recompiled mxnet. I'll try your advice.

from mobulaop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.