mxnet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Skalicky <>
Subject Re: [apache/incubator-mxnet] [RFC] MXNet external operators (#18904)
Date Wed, 19 Aug 2020 08:41:15 GMT
Hey folks,

I was playing around and realized we can load anything we want following the example, not
just operators. For example, I wrote this little function to dump out the registered operators
and map the aliases:
#include "operator_common.h"

extern "C" int listOps() {
  // get op registry
  ::dmlc::Registry<::nnvm::Op>* reg = ::dmlc::Registry<::nnvm::Op>::Get();
  // get list of registered op names
  std::vector<std::string> ops = reg->ListAllNames();

  // create inverse map of Op to name (to find aliases)
  std::map<const ::nnvm::Op*,std::vector<std::string> > op_map;
  for(auto &name : ops) {
    const ::nnvm::Op* op = reg->Find(name);
    if(op_map.count(op) > 0) {
        if(>name) != 0)
    } else {
        if(>name) != 0)

  // print out the op mapping
  for(auto &kv : op_map) {
    std::cout << kv.first->name << ", ";
    for(auto &n : kv.second)
      std::cout << n << ", ";
    std::cout << std::endl;
  return 0;
I compiled this code with MXNet to get an object file, and then built that into a shared library:
g++ -shared -fPIC -std=c++11 ../external_ops/src/ -o
-I../external_ops/include -L../external_ops/build -lmxnet
Then, with this Python code I can load my library into MXNet and at the same time get a handle
to the library directly and call my function (now with access to the
import os
import ctypes
import mxnet as mx
libop_info = ctypes.CDLL('')
I was able to get this list of operators out:

So, should we consider making this proposal more than just "external operators"? Maybe "external
components" that could be anything: operators, subgraph properties, utilities, etc....Thoughts?


You are receiving this because your review was requested.
Reply to this email directly or view it on GitHub:
  • Unnamed multipart/alternative (inline, 7-Bit, 0 bytes)
View raw message