You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/06/04 02:41:03 UTC

[GitHub] [incubator-mxnet] Vigilans commented on issue #14116: Failure in generated op.h in version 1.3.1

Vigilans commented on issue #14116: Failure in generated op.h in version 1.3.1
URL: https://github.com/apache/incubator-mxnet/issues/14116#issuecomment-498497289
 
 
   Problem found. Here is my procedures to trace the bug:
   
   * Debug [`OpWrapperGenerator.py#L364`](https://github.com/apache/incubator-mxnet/blob/master/cpp-package/scripts/OpWrapperGenerator.py#L364), and view `(name, description, argNames, argTypes, argDescs)` of `multi_sgd_update`.
   * From `argNames` and `argTypes`, we could see that `lrs` and `wds`'s type is `", required"`. 
   * From `name`, `description` and `argDescs`, we could locate the definition of op:
   * Definition of MultiSGDParam: [src/operator/optimizer_op-inl.h#L85](https://github.com/apache/incubator-mxnet/blob/master/src/operator/optimizer_op-inl.h#L85):
   * Generic Param Declaration Method: [3rdparty\...\dmlc\parameter.h#L231](https://github.com/dmlc/dmlc-core/blob/3943914eed66470bd010df581e29e4dca4f7df6f/include/dmlc/parameter.h#L228)
   * `lrs` and `wds`'s type `mxnet::Tuple<float>` falls back to [FieldsEntryBase<DT=mxnet::Tuple<Float>>](https://github.com/dmlc/dmlc-core/blob/3943914eed66470bd010df581e29e4dca4f7df6f/include/dmlc/parameter.h#L551)
   * In `GetFieldInfo`, here is where the evil [**", required"**](https://github.com/dmlc/dmlc-core/blob/3943914eed66470bd010df581e29e4dca4f7df6f/include/dmlc/parameter.h#L593) comes from.
   * We could see that `FieldsEntryBase` uses [`os << type_`](https://github.com/dmlc/dmlc-core/blob/3943914eed66470bd010df581e29e4dca4f7df6f/include/dmlc/parameter.h#L588) to fill the content before ", required".
   * Then we could see that `type_` is inited by [`dmlc::type_name<DT>()`](https://github.com/dmlc/dmlc-core/blob/3943914eed66470bd010df581e29e4dca4f7df6f/include/dmlc/parameter.h#L632).
   * Finally we could see that the type name is specified by custom specialization of [`type_name_helper<T>`](https://github.com/dmlc/dmlc-core/blob/3943914eed66470bd010df581e29e4dca4f7df6f/include/dmlc/type_traits.h#L101).
   
   Then, what happened to our `mxnet::Tuple<float>`?
   Here: https://github.com/apache/incubator-mxnet/blob/master/include/mxnet/tuple.h#L744
   ```cpp
   namespace dmlc {
   /*! \brief description for optional TShape */
   DMLC_DECLARE_TYPE_NAME(optional<mxnet::TShape>, "Shape or None");
   DMLC_DECLARE_TYPE_NAME(optional<mxnet::Tuple<int>>, "Shape or None");
   // avoid low version of MSVC
   #if !defined(_MSC_VER) // <----------- Here !
   template<typename T>
   struct type_name_helper<mxnet::Tuple<T> > {
     static inline std::string value() {
       return "tuple of <" + type_name<T>() + ">";
     }
   };
   #endif
   }  // namespace dmlc
   ```
   So the specialization of `mxnet::tuple<T>` was disabled for Visual Studio at the first place!!!
   
   I removed the `#if` block, recompile, then everything works fine.
   @junrushao1994 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services