Browse Source

refactor(opdef): overwrite shared_from_this to avoid const_cast

GitOrigin-RevId: 5322dbbb3f
tags/v1.8.0
Megvii Engine Team 3 years ago
parent
commit
d8d5edb31f
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      imperative/src/include/megbrain/imperative/op_def.h

+ 5
- 0
imperative/src/include/megbrain/imperative/op_def.h View File

@@ -102,6 +102,11 @@ public:


static void set_allocator(allocator_t allocator); static void set_allocator(allocator_t allocator);
DeviceTensorStorage::RawStorage allocate(CompNode, size_t) const; DeviceTensorStorage::RawStorage allocate(CompNode, size_t) const;

std::shared_ptr<OpDef> shared_from_this() const {
return const_cast<OpDef&>(*this)
.std::enable_shared_from_this<OpDef>::shared_from_this();
}
}; };


template <typename T> template <typename T>


Loading…
Cancel
Save