Skip to content

Commit

Permalink
[luci] ReduceProd IR (Samsung#638)
Browse files Browse the repository at this point in the history
* [luci] ReduceProd IR

This will introduce IR for ReduceProd Op

ONE-DCO-1.0-Signed-off-by: SaeHie Park <[email protected]>

* remove unused header

ONE-DCO-1.0-Signed-off-by: SaeHie Park <[email protected]>
  • Loading branch information
seanshpark authored May 11, 2020
1 parent 90c92db commit f971386
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/luci/lang/include/luci/IR/CircleNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "Nodes/CircleMul.h"
#include "Nodes/CirclePack.h"
#include "Nodes/CirclePad.h"
#include "Nodes/CircleReduceProd.h"
#include "Nodes/CircleRelu6.h"
#include "Nodes/CircleRelu.h"
#include "Nodes/CircleReshape.h"
Expand Down
1 change: 1 addition & 0 deletions compiler/luci/lang/include/luci/IR/CircleNodes.lst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ CIRCLE_NODE(MEAN, luci::CircleMean)
CIRCLE_NODE(MUL, luci::CircleMul)
CIRCLE_NODE(PACK, luci::CirclePack)
CIRCLE_NODE(PAD, luci::CirclePad)
CIRCLE_NODE(REDUCE_PROD, luci::CircleReduceProd)
CIRCLE_NODE(RELU, luci::CircleRelu)
CIRCLE_NODE(RELU6, luci::CircleRelu6)
CIRCLE_NODE(RESHAPE, luci::CircleReshape)
Expand Down
50 changes: 50 additions & 0 deletions compiler/luci/lang/include/luci/IR/Nodes/CircleReduceProd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef __LUCI_IR_CIRCLE_REDUCE_PROD_H__
#define __LUCI_IR_CIRCLE_REDUCE_PROD_H__

#include "luci/IR/CircleNodeDecl.h"
#include "luci/IR/CircleOpcode.h"

#include "luci/IR/LuciNodeMixins.h"

namespace luci
{

/**
* @brief REDUCE_PROD in Circle
*/
class CircleReduceProd final : public FixedArityNode<2, CircleNodeImpl<CircleOpcode::REDUCE_PROD>>
{
public:
loco::Node *input(void) const { return at(0)->node(); }
void input(loco::Node *node) { at(0)->node(node); }

loco::Node *reduction_indices(void) const { return at(1)->node(); }
void reduction_indices(loco::Node *node) { at(1)->node(node); }

public:
bool keep_dims(void) const { return _keep_dims; }
void keep_dims(bool keep_dims) { _keep_dims = keep_dims; }

private:
bool _keep_dims = false;
};

} // namespace luci

#endif // __LUCI_IR_CIRCLE_REDUCE_PROD_H__
34 changes: 34 additions & 0 deletions compiler/luci/lang/src/Nodes/CircleReduceProd.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "luci/IR/Nodes/CircleReduceProd.h"

#include "luci/IR/CircleDialect.h"

#include <gtest/gtest.h>

TEST(CircleReduceProdTest, constructor)
{
luci::CircleReduceProd reduce_prod_node;

ASSERT_EQ(luci::CircleDialect::get(), reduce_prod_node.dialect());
ASSERT_EQ(luci::CircleOpcode::REDUCE_PROD, reduce_prod_node.opcode());

ASSERT_EQ(nullptr, reduce_prod_node.input());
ASSERT_EQ(nullptr, reduce_prod_node.reduction_indices());

ASSERT_FALSE(reduce_prod_node.keep_dims());
}

0 comments on commit f971386

Please sign in to comment.