# Custom SameDiff ops missing from graph after upgrade to M2

**URL:** <https://community.konduit.ai/t/custom-samediff-ops-missing-from-graph-after-upgrade-to-m2/1822>\
**Category:** SameDiff\
**Created:** [April 13, 2022, 3:19pm UTC](https://community.konduit.ai/t/custom-samediff-ops-missing-from-graph-after-upgrade-to-m2/1822 "2022-04-13T15:19:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![partarstu](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/partarstu/32/276_2.png) [@partarstu](https://community.konduit.ai/u/partarstu)\
**Post date:** [April 13, 2022, 3:19pm UTC](https://community.konduit.ai/t/custom-samediff-ops-missing-from-graph-after-upgrade-to-m2/1822/1 "2022-04-13T15:19:21Z")

</div>

Hi. I’m using a custom `SameDiff` `Gather Op` which extends a standard (native) one by overriding the `doDiff()` method. The rest remains the same, including the Op’s name. It worked all the time with different `DL4J` versions but after upgrading to **M2** this Op is being ignored and automatically replaced by the standard one. After debugging the code I noticed that it happens because of always cloning the Ops (not sure why it happens all the time, even when there’s no importing etc.) in `org.nd4j.autodiff.samediff.serde.FlatBuffersMapper#cloneViaSerialize()`. Manipulations with `ImportClassMapping.getOpNameMapping()` by replacing the standard op with the custom one do the trick, but only when I train the model from scratch. If I load an existing same model (as usually) in order to copy the weights from it (the graph itself is not changed during this copying), somehow my custom Op, still remaining in `ImportClassMapping.getOpNameMapping()` map, is again being ignored.

Would appreciate any tips on how to correctly configure my custom Op so that it doesn’t get kicked off and replaced by the standard one.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [April 13, 2022, 9:27pm UTC](https://community.konduit.ai/t/custom-samediff-ops-missing-from-graph-after-upgrade-to-m2/1822/2 "2022-04-13T21:27:37Z")

</div>

@partarstu could you file an issue with more info? We’re going to do a follow up release in the next week or so to address some issues with M2. Anything you can tell me would be great. I’d appreciate a stack trace.  
IMportClassMapping isn’t relevant anymore. It was relevant only for the old import.

The serialization I’d be curious to see a reproducer for though.

---

<div class="post-metadata">

**Author:** ![partarstu](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/partarstu/32/276_2.png) [@partarstu](https://community.konduit.ai/u/partarstu)\
**Post date:** [April 14, 2022, 9:38am UTC](https://community.konduit.ai/t/custom-samediff-ops-missing-from-graph-after-upgrade-to-m2/1822/3 "2022-04-14T09:38:51Z")

</div>

@agibsonccc I’ve filed the issue here: [Custom SameDiff ops missing from graph after upgrade to M2 · Issue #9670 · eclipse/deeplearning4j · GitHub](https://github.com/eclipse/deeplearning4j/issues/9670) .

I couldn’t add much more interesting info though than it was before. There’s no stack trace or error. The core idea is that my custom Op which used to work for a couple of different releases is now being replaced by the native one and the new cloning mechanism is the root cause. There’s no import of any Op in my case. If current logic is correct then there’s some Op registration mechanism missing for any custom implementation which doesn’t require libnd4j changes and is thus not part of the native Ops.
