Skip to content

Commit

Permalink
Fix compiler warnings in new FFI (apache#17718)
Browse files Browse the repository at this point in the history
Introduced in apache#17510
  • Loading branch information
hzfan authored and sxjscience committed Jul 1, 2020
1 parent 2a3dbda commit 8750350
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 44 deletions.
4 changes: 2 additions & 2 deletions include/mxnet/ir/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class IntImmNode : public PrimExprNode {
int64_t value;

static constexpr const char* _type_key = "IntImm";
MXNET_DECLARE_FINAL_OBJECT_INFO(IntImmNode, PrimExprNode);
MXNET_DECLARE_FINAL_OBJECT_INFO(IntImmNode, PrimExprNode)
};

/*!
Expand Down Expand Up @@ -186,7 +186,7 @@ class FloatImmNode : public PrimExprNode {
double value;

static constexpr const char* _type_key = "FloatImm";
MXNET_DECLARE_FINAL_OBJECT_INFO(FloatImmNode, PrimExprNode);
MXNET_DECLARE_FINAL_OBJECT_INFO(FloatImmNode, PrimExprNode)
};

/*!
Expand Down
2 changes: 1 addition & 1 deletion include/mxnet/node/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ArrayNode : public Object {
std::vector<ObjectRef> data;

static constexpr const char* _type_key = "Array";
MXNET_DECLARE_FINAL_OBJECT_INFO(ArrayNode, Object);
MXNET_DECLARE_FINAL_OBJECT_INFO(ArrayNode, Object)
};

/*!
Expand Down
4 changes: 2 additions & 2 deletions include/mxnet/runtime/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class ADTObj : public Object, public InplaceArrayBase<ADTObj, ObjectRef> {

static constexpr const uint32_t _type_index = TypeIndex::kMXNetADT;
static constexpr const char* _type_key = "MXNet.ADT";
MXNET_DECLARE_FINAL_OBJECT_INFO(ADTObj, Object);
MXNET_DECLARE_FINAL_OBJECT_INFO(ADTObj, Object)

private:
/*!
Expand Down Expand Up @@ -273,7 +273,7 @@ class ADT : public ObjectRef {
return ADT(0, std::forward<Args>(args)...);
}

MXNET_DEFINE_OBJECT_REF_METHODS(ADT, ObjectRef, ADTObj);
MXNET_DEFINE_OBJECT_REF_METHODS(ADT, ObjectRef, ADTObj)
};

} // namespace runtime
Expand Down
10 changes: 5 additions & 5 deletions include/mxnet/runtime/ffi_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class EllipsisObj : public Object {
public:
static constexpr const uint32_t _type_index = TypeIndex::kEllipsis;
static constexpr const char* _type_key = "MXNet.Ellipsis";
MXNET_DECLARE_FINAL_OBJECT_INFO(EllipsisObj, Object);
MXNET_DECLARE_FINAL_OBJECT_INFO(EllipsisObj, Object)
};

inline ObjectRef CreateEllipsis() {
Expand All @@ -54,7 +54,7 @@ class SliceObj : public Object {

static constexpr const uint32_t _type_index = TypeIndex::kSlice;
static constexpr const char* _type_key = "MXNet.Slice";
MXNET_DECLARE_FINAL_OBJECT_INFO(SliceObj, Object);
MXNET_DECLARE_FINAL_OBJECT_INFO(SliceObj, Object)
};

class Slice : public ObjectRef {
Expand All @@ -74,7 +74,7 @@ class Slice : public ObjectRef {
// constant to represent None.
static constexpr int64_t kNoneValue = std::numeric_limits<int64_t>::min();

MXNET_DEFINE_OBJECT_REF_METHODS(Slice, ObjectRef, SliceObj);
MXNET_DEFINE_OBJECT_REF_METHODS(Slice, ObjectRef, SliceObj)
};

int64_t inline SliceNoneValue() {
Expand All @@ -86,7 +86,7 @@ class IntegerObj: public Object {
int64_t value;
static constexpr const uint32_t _type_index = TypeIndex::kInteger;
static constexpr const char* _type_key = "MXNet.Integer";
MXNET_DECLARE_FINAL_OBJECT_INFO(IntegerObj, Object);
MXNET_DECLARE_FINAL_OBJECT_INFO(IntegerObj, Object)
};

class Integer: public ObjectRef {
Expand All @@ -96,7 +96,7 @@ class Integer: public ObjectRef {
data->value = value;
data_ = std::move(data);
}
MXNET_DEFINE_OBJECT_REF_METHODS(Integer, ObjectRef, IntegerObj);
MXNET_DEFINE_OBJECT_REF_METHODS(Integer, ObjectRef, IntegerObj)
};

// Helper functions for fast FFI implementations
Expand Down
66 changes: 32 additions & 34 deletions include/mxnet/runtime/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -644,31 +644,29 @@ struct ObjectEqual {
* \param TypeName The name of the current type.
* \param ParentType The name of the ParentType
*/
#define MXNET_DECLARE_BASE_OBJECT_INFO(TypeName, ParentType) \
static const uint32_t RuntimeTypeIndex() { \
if (TypeName::_type_index != ::mxnet::runtime::TypeIndex::kDynamic) { \
return TypeName::_type_index; \
} \
return _GetOrAllocRuntimeTypeIndex(); \
} \
static const uint32_t _GetOrAllocRuntimeTypeIndex() { \
static uint32_t tidx = GetOrAllocRuntimeTypeIndex( \
TypeName::_type_key, \
TypeName::_type_index, \
ParentType::_GetOrAllocRuntimeTypeIndex(), \
TypeName::_type_child_slots, \
TypeName::_type_child_slots_can_overflow); \
return tidx; \
} \
#define MXNET_DECLARE_BASE_OBJECT_INFO(TypeName, ParentType) \
static uint32_t RuntimeTypeIndex() { \
return TypeName::_type_index != ::mxnet::runtime::TypeIndex::kDynamic ? \
TypeName::_type_index : _GetOrAllocRuntimeTypeIndex(); \
} \
static uint32_t _GetOrAllocRuntimeTypeIndex() { \
static uint32_t tidx = GetOrAllocRuntimeTypeIndex( \
TypeName::_type_key, \
TypeName::_type_index, \
ParentType::_GetOrAllocRuntimeTypeIndex(), \
TypeName::_type_child_slots, \
TypeName::_type_child_slots_can_overflow); \
return tidx; \
}

/*!
* \brief helper macro to declare type information in a final class.
* \param TypeName The name of the current type.
* \param ParentType The name of the ParentType
*/
#define MXNET_DECLARE_FINAL_OBJECT_INFO(TypeName, ParentType) \
static const constexpr bool _type_final = true; \
static const constexpr int _type_child_slots = 0; \
static const constexpr bool _type_final = true; \
static const constexpr int _type_child_slots = 0; \
MXNET_DECLARE_BASE_OBJECT_INFO(TypeName, ParentType) \


Expand All @@ -684,25 +682,25 @@ struct ObjectEqual {


#define MXNET_DEFINE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName) \
TypeName() {} \
explicit TypeName( \
::mxnet::runtime::ObjectPtr<::mxnet::runtime::Object> n) \
: ParentType(n) {} \
const ObjectName* operator->() const { \
return static_cast<const ObjectName*>(data_.get()); \
} \
operator bool() const { return data_ != nullptr; } \
TypeName() {} \
explicit TypeName( \
::mxnet::runtime::ObjectPtr<::mxnet::runtime::Object> n) \
: ParentType(n) {} \
const ObjectName* operator->() const { \
return static_cast<const ObjectName*>(data_.get()); \
} \
operator bool() const { return data_ != nullptr; } \
using ContainerType = ObjectName;

#define MXNET_DEFINE_OBJECT_REF_METHODS_MUT(TypeName, ParentType, ObjectName) \
TypeName() {} \
explicit TypeName( \
::mxnet::runtime::ObjectPtr<::mxnet::runtime::Object> n) \
: ParentType(n) {} \
ObjectName* operator->() { \
return static_cast<ObjectName*>(data_.get()); \
} \
operator bool() const { return data_ != nullptr; } \
TypeName() {} \
explicit TypeName( \
::mxnet::runtime::ObjectPtr<::mxnet::runtime::Object> n) \
: ParentType(n) {} \
ObjectName* operator->() { \
return static_cast<ObjectName*>(data_.get()); \
} \
operator bool() const { return data_ != nullptr; } \
using ContainerType = ObjectName;

// Implementations details below
Expand Down

0 comments on commit 8750350

Please sign in to comment.