virtual ~KernelObject() = default;
public:
+ KernelObject *asKernel(void) override { return this; }
+ const KernelObject *asKernel(void) const override { return this; }
+
+public:
const nncc::core::ADT::kernel::Shape &shape(void) const { return _shape; }
private:
#include "coco/IR/Bag.h"
#include "coco/IR/FeatureObject.forward.h"
+#include "coco/IR/KernelObject.forward.h"
namespace coco
{
public:
virtual FeatureObject *asFeature(void) { return nullptr; }
virtual const FeatureObject *asFeature(void) const { return nullptr; }
+
+ virtual KernelObject *asKernel(void) { return nullptr; }
+ virtual const KernelObject *asKernel(void) const { return nullptr; }
};
} // namespace coco
ASSERT_EQ(o.shape().width(), shape.width());
}
+TEST(IR_KERNEL_OBJECT, asKernel)
+{
+ const nncc::core::ADT::kernel::Shape shape{1, 1, 3, 3};
+ coco::KernelObject o{shape};
+
+ coco::Object *mutable_object = &o;
+ const coco::Object *immutable_object = &o;
+
+ ASSERT_NE(mutable_object->asKernel(), nullptr);
+ ASSERT_EQ(mutable_object->asKernel(), immutable_object->asKernel());
+}
+
TEST(IR_KERNEL_OBJECT, at)
{
const uint32_t N = 1;