diff options
Diffstat (limited to 'compiler/moco/lang/src/IR/Nodes')
33 files changed, 1214 insertions, 0 deletions
diff --git a/compiler/moco/lang/src/IR/Nodes/TFAdd.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFAdd.test.cpp new file mode 100644 index 000000000..d2cfb6ac4 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFAdd.test.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFAdd.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFAddTest, constructor) +{ + moco::TFAdd add_node; + + ASSERT_EQ(add_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(add_node.opcode(), moco::TFOpcode::Add); + + ASSERT_EQ(add_node.x(), nullptr); + ASSERT_EQ(add_node.y(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFAvgPool.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFAvgPool.test.cpp new file mode 100644 index 000000000..32a27ffa0 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFAvgPool.test.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFAvgPool.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFAvgPoolTest, constructor) +{ + moco::TFAvgPool avgpool; + + ASSERT_EQ(avgpool.dialect(), moco::TFDialect::get()); + ASSERT_EQ(avgpool.opcode(), moco::TFOpcode::AvgPool); + + ASSERT_EQ(avgpool.value(), nullptr); + ASSERT_EQ(avgpool.data_layout(), ""); + ASSERT_EQ(avgpool.padding(), ""); + ASSERT_EQ(avgpool.ksize(), std::vector<int64_t>({})); + ASSERT_EQ(avgpool.strides(), std::vector<int64_t>({})); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFBiasAdd.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFBiasAdd.test.cpp new file mode 100644 index 000000000..4a15a4981 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFBiasAdd.test.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFBiasAdd.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFBiasAddTest, constructor) +{ + moco::TFBiasAdd bias_add; + + ASSERT_EQ(bias_add.dialect(), moco::TFDialect::get()); + ASSERT_EQ(bias_add.opcode(), moco::TFOpcode::BiasAdd); + + ASSERT_EQ(bias_add.value(), nullptr); + ASSERT_EQ(bias_add.bias(), nullptr); + ASSERT_EQ(bias_add.data_layout(), ""); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFConcatV2.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFConcatV2.test.cpp new file mode 100644 index 000000000..8f7df92d0 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFConcatV2.test.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFConcatV2.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFConcatV2Test, constructor) +{ + moco::TFConcatV2 concatv2_node(3); // num of values + + ASSERT_EQ(concatv2_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(concatv2_node.opcode(), moco::TFOpcode::ConcatV2); + + ASSERT_EQ(concatv2_node.num_values(), 3); + ASSERT_EQ(concatv2_node.values(0), nullptr); + ASSERT_EQ(concatv2_node.values(1), nullptr); + ASSERT_EQ(concatv2_node.values(2), nullptr); + ASSERT_EQ(concatv2_node.axis(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFConst.cpp b/compiler/moco/lang/src/IR/Nodes/TFConst.cpp new file mode 100644 index 000000000..5c8c08ec0 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFConst.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFConst.h" + +#include <cassert> + +namespace moco +{ + +template <loco::DataType DT> uint32_t TFConst::size(void) const +{ + assert(dtype() == DT); + assert(_data.size() % sizeof(typename loco::DataTypeImpl<DT>::Type) == 0); + return _data.size() / sizeof(typename loco::DataTypeImpl<DT>::Type); +} + +template <loco::DataType DT> void TFConst::size(uint32_t l) +{ + assert(dtype() == DT); + _data.resize(l * sizeof(typename loco::DataTypeImpl<DT>::Type)); +} + +template <loco::DataType DT> +const typename loco::DataTypeImpl<DT>::Type &TFConst::at(uint32_t n) const +{ + assert(dtype() == DT); + assert(n < size<DT>()); + return *(reinterpret_cast<const typename loco::DataTypeImpl<DT>::Type *>(_data.data()) + n); +} + +template <loco::DataType DT> typename loco::DataTypeImpl<DT>::Type &TFConst::at(uint32_t n) +{ + assert(dtype() == DT); + assert(n < size<DT>()); + return *(reinterpret_cast<typename loco::DataTypeImpl<DT>::Type *>(_data.data()) + n); +} + +#define INSTANTIATE(DT) \ + template uint32_t TFConst::size<DT>(void) const; \ + template void TFConst::size<DT>(uint32_t); \ + template const typename loco::DataTypeImpl<DT>::Type &TFConst::at<DT>(uint32_t) const; \ + template typename loco::DataTypeImpl<DT>::Type &TFConst::at<DT>(uint32_t); + +INSTANTIATE(loco::DataType::S8); +INSTANTIATE(loco::DataType::S32); +INSTANTIATE(loco::DataType::FLOAT32); + +#undef INSTANTIATE + +loco::TensorShape tensor_shape(const TFConst *node) +{ + assert(node != nullptr); + + loco::TensorShape shape; + + uint32_t rank = node->rank(); + shape.rank(rank); + for (uint32_t index = 0; index < rank; ++index) + { + assert(node->dim(index).known()); + shape.dim(index) = node->dim(index).value(); + } + + return shape; +} + +uint32_t num_elements(const TFConst *tfconst) +{ + assert(tfconst != nullptr); + + uint32_t num_elements = 1; + for (uint32_t index = 0; index < tfconst->rank(); ++index) + { + assert(tfconst->dim(index).known()); + uint32_t dim = tfconst->dim(index).value(); + num_elements = num_elements * dim; + } + return num_elements; +} + +bool same_shape(const TFConst *lhs, const TFConst *rhs) +{ + assert(lhs != nullptr); + assert(rhs != nullptr); + + if (lhs->rank() != rhs->rank()) + return false; + + for (uint32_t index = 0; index < lhs->rank(); ++index) + { + assert(lhs->dim(index).known()); + assert(rhs->dim(index).known()); + if (lhs->dim(index).value() != rhs->dim(index).value()) + return false; + } + return true; +} + +} // namespace moco diff --git a/compiler/moco/lang/src/IR/Nodes/TFConst.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFConst.test.cpp new file mode 100644 index 000000000..259966e33 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFConst.test.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFConst.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFConstantTest, constructor) +{ + moco::TFConst constant; + + ASSERT_EQ(constant.dialect(), moco::TFDialect::get()); + ASSERT_EQ(constant.opcode(), moco::TFOpcode::Const); + + ASSERT_EQ(constant.dtype(), loco::DataType::Unknown); + ASSERT_EQ(constant.rank(), 0); + + constant.dtype(loco::DataType::FLOAT32); + ASSERT_EQ(constant.dtype(), loco::DataType::FLOAT32); + + constant.rank(2); + ASSERT_EQ(constant.rank(), 2); + + constant.dim(0) = 2; + constant.dim(1) = 3; + + ASSERT_TRUE(constant.dim(0).known()); + ASSERT_TRUE(constant.dim(1).known()); + + ASSERT_EQ(constant.dim(0), 2); + ASSERT_EQ(constant.dim(1), 3); + + constant.size<loco::DataType::FLOAT32>(6); + + ASSERT_EQ(constant.size<loco::DataType::FLOAT32>(), 6); + + constant.at<loco::DataType::FLOAT32>(0) = 0.0f; // Set 0,0 + constant.at<loco::DataType::FLOAT32>(1) = 1.0f; // Set 0,1 + constant.at<loco::DataType::FLOAT32>(2) = 2.0f; // Set 0,2 + constant.at<loco::DataType::FLOAT32>(3) = 3.0f; // Set 1,0 + constant.at<loco::DataType::FLOAT32>(4) = 4.0f; // Set 1,1 + constant.at<loco::DataType::FLOAT32>(5) = 5.0f; // Set 1,2 + + ASSERT_EQ(constant.at<loco::DataType::FLOAT32>(0), 0.0f); + ASSERT_EQ(constant.at<loco::DataType::FLOAT32>(1), 1.0f); + ASSERT_EQ(constant.at<loco::DataType::FLOAT32>(2), 2.0f); + ASSERT_EQ(constant.at<loco::DataType::FLOAT32>(3), 3.0f); + ASSERT_EQ(constant.at<loco::DataType::FLOAT32>(4), 4.0f); + ASSERT_EQ(constant.at<loco::DataType::FLOAT32>(5), 5.0f); +} + +TEST(TFConstantTest, datatype_s8) +{ + moco::TFConst constant; + + ASSERT_EQ(constant.dialect(), moco::TFDialect::get()); + ASSERT_EQ(constant.opcode(), moco::TFOpcode::Const); + + ASSERT_EQ(constant.dtype(), loco::DataType::Unknown); + ASSERT_EQ(constant.rank(), 0); + + constant.dtype(loco::DataType::S8); + ASSERT_EQ(constant.dtype(), loco::DataType::S8); + + constant.rank(1); + ASSERT_EQ(constant.rank(), 1); + + constant.dim(0) = 3; + ASSERT_TRUE(constant.dim(0).known()); + ASSERT_EQ(constant.dim(0), 3); + constant.size<loco::DataType::S8>(3); + ASSERT_EQ(constant.size<loco::DataType::S8>(), 3); + + constant.at<loco::DataType::S8>(0) = -1; + constant.at<loco::DataType::S8>(1) = 1; + constant.at<loco::DataType::S8>(2) = 0; + + ASSERT_EQ(constant.at<loco::DataType::S8>(0), -1); + ASSERT_EQ(constant.at<loco::DataType::S8>(1), 1); + ASSERT_EQ(constant.at<loco::DataType::S8>(2), 0); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFConv2D.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFConv2D.test.cpp new file mode 100644 index 000000000..3e3453db0 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFConv2D.test.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFConv2D.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFConv2DTest, constructor) +{ + moco::TFConv2D conv2d_node; + + ASSERT_EQ(conv2d_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(conv2d_node.opcode(), moco::TFOpcode::Conv2D); + + ASSERT_EQ(conv2d_node.input(), nullptr); + ASSERT_EQ(conv2d_node.filter(), nullptr); + ASSERT_EQ(conv2d_node.padding(), ""); + ASSERT_EQ(conv2d_node.data_layout(), ""); + ASSERT_EQ(conv2d_node.strides().size(), 0); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFConv2DBackpropInput.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFConv2DBackpropInput.test.cpp new file mode 100644 index 000000000..f7ad4ce67 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFConv2DBackpropInput.test.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFConv2DBackpropInput.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFConv2DBackpropInputTest, constructor) +{ + moco::TFConv2DBackpropInput conv2dbi_node; + + ASSERT_EQ(conv2dbi_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(conv2dbi_node.opcode(), moco::TFOpcode::Conv2DBackpropInput); + + ASSERT_EQ(conv2dbi_node.input_sizes(), nullptr); + ASSERT_EQ(conv2dbi_node.filter(), nullptr); + ASSERT_EQ(conv2dbi_node.out_backprop(), nullptr); + ASSERT_EQ(conv2dbi_node.padding(), ""); + ASSERT_EQ(conv2dbi_node.data_layout(), ""); + ASSERT_EQ(conv2dbi_node.strides().size(), 0); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFDepthwiseConv2dNative.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFDepthwiseConv2dNative.test.cpp new file mode 100644 index 000000000..2562997c2 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFDepthwiseConv2dNative.test.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFDepthwiseConv2dNative.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFDepthwiseConv2dNativeTest, constructor) +{ + moco::TFDepthwiseConv2dNative depthwiseConv2dnative_node; + + ASSERT_EQ(depthwiseConv2dnative_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(depthwiseConv2dnative_node.opcode(), moco::TFOpcode::DepthwiseConv2dNative); + + ASSERT_EQ(depthwiseConv2dnative_node.input(), nullptr); + ASSERT_EQ(depthwiseConv2dnative_node.filter(), nullptr); + ASSERT_EQ(depthwiseConv2dnative_node.padding(), ""); + ASSERT_EQ(depthwiseConv2dnative_node.data_layout(), ""); + ASSERT_EQ(depthwiseConv2dnative_node.strides().size(), 0); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFFakeQuantWithMinMaxVars.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFFakeQuantWithMinMaxVars.test.cpp new file mode 100644 index 000000000..be8fc3a70 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFFakeQuantWithMinMaxVars.test.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFFakeQuantWithMinMaxVars.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFFakeQuantWithMinMaxVarsTest, constructor) +{ + moco::TFFakeQuantWithMinMaxVars fakequant_node; + + ASSERT_EQ(fakequant_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(fakequant_node.opcode(), moco::TFOpcode::FakeQuantWithMinMaxVars); + + ASSERT_EQ(fakequant_node.inputs(), nullptr); + ASSERT_EQ(fakequant_node.min(), nullptr); + ASSERT_EQ(fakequant_node.max(), nullptr); + ASSERT_EQ(fakequant_node.num_bits(), 8); + ASSERT_EQ(fakequant_node.narrow_range(), false); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFFusedBatchNorm.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFFusedBatchNorm.test.cpp new file mode 100644 index 000000000..265f8f9a4 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFFusedBatchNorm.test.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFFusedBatchNorm.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFFusedBatchNormTest, constructor) +{ + moco::TFFusedBatchNorm fbn_node; + + ASSERT_EQ(fbn_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(fbn_node.opcode(), moco::TFOpcode::FusedBatchNorm); + + ASSERT_EQ(fbn_node.x(), nullptr); + ASSERT_EQ(fbn_node.scale(), nullptr); + ASSERT_EQ(fbn_node.offset(), nullptr); + ASSERT_EQ(fbn_node.mean(), nullptr); + ASSERT_EQ(fbn_node.variance(), nullptr); + ASSERT_NE(fbn_node.epsilon(), 0.0f); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFIdentity.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFIdentity.test.cpp new file mode 100644 index 000000000..deb17d502 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFIdentity.test.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFIdentity.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFIdentituTest, constructor) +{ + moco::TFIdentity identity_node; + + ASSERT_EQ(identity_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(identity_node.opcode(), moco::TFOpcode::Identity); + + ASSERT_EQ(identity_node.input(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFMaxPool.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFMaxPool.test.cpp new file mode 100644 index 000000000..482ad889d --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFMaxPool.test.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFMaxPool.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFMaxPoolTest, constructor) +{ + moco::TFMaxPool maxpool; + + ASSERT_EQ(maxpool.dialect(), moco::TFDialect::get()); + ASSERT_EQ(maxpool.opcode(), moco::TFOpcode::MaxPool); + + ASSERT_EQ(maxpool.input(), nullptr); + ASSERT_EQ(maxpool.data_layout(), ""); + ASSERT_EQ(maxpool.padding(), ""); + ASSERT_EQ(maxpool.ksize(), std::vector<int64_t>({})); + ASSERT_EQ(maxpool.strides(), std::vector<int64_t>({})); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFMaximum.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFMaximum.test.cpp new file mode 100644 index 000000000..568bd7038 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFMaximum.test.cpp @@ -0,0 +1,31 @@ +/* + * 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 "moco/IR/Nodes/TFMaximum.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFMaximumTest, constructor) +{ + moco::TFMaximum max_node; + + ASSERT_EQ(max_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(max_node.opcode(), moco::TFOpcode::Maximum); + + ASSERT_EQ(max_node.x(), nullptr); + ASSERT_EQ(max_node.y(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFMean.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFMean.test.cpp new file mode 100644 index 000000000..126b31783 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFMean.test.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFMean.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFMeanTest, constructor) +{ + moco::TFMean mean_node; + + ASSERT_EQ(mean_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(mean_node.opcode(), moco::TFOpcode::Mean); + + ASSERT_EQ(mean_node.input(), nullptr); + ASSERT_EQ(mean_node.reduction_indices(), nullptr); + ASSERT_EQ(mean_node.keep_dims(), false); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFMul.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFMul.test.cpp new file mode 100644 index 000000000..a4a1ecfd7 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFMul.test.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFMul.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFMulTest, constructor) +{ + moco::TFMul mul_node; + + ASSERT_EQ(mul_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(mul_node.opcode(), moco::TFOpcode::Mul); + + ASSERT_EQ(mul_node.x(), nullptr); + ASSERT_EQ(mul_node.y(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFPack.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFPack.test.cpp new file mode 100644 index 000000000..a62b39f3d --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFPack.test.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFPack.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFPackTest, constructor) +{ + moco::TFPack pack_node(3); // num of values + + ASSERT_EQ(pack_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(pack_node.opcode(), moco::TFOpcode::Pack); + + ASSERT_EQ(pack_node.N(), 3); + ASSERT_EQ(pack_node.values(0), nullptr); + ASSERT_EQ(pack_node.values(1), nullptr); + ASSERT_EQ(pack_node.values(2), nullptr); + ASSERT_EQ(pack_node.axis(), 0); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFPad.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFPad.test.cpp new file mode 100644 index 000000000..f3f3dcc8c --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFPad.test.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFPad.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFPadTest, constructor) +{ + moco::TFPad pad; + + ASSERT_EQ(pad.dialect(), moco::TFDialect::get()); + ASSERT_EQ(pad.opcode(), moco::TFOpcode::Pad); + + ASSERT_EQ(pad.input(), nullptr); + ASSERT_EQ(pad.paddings(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFPlaceholder.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFPlaceholder.test.cpp new file mode 100644 index 000000000..e082f0c3e --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFPlaceholder.test.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFPlaceholder.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFPlaceholderTest, constructor) +{ + moco::TFPlaceholder placeholder; + + ASSERT_EQ(placeholder.dialect(), moco::TFDialect::get()); + ASSERT_EQ(placeholder.opcode(), moco::TFOpcode::Placeholder); + + ASSERT_EQ(placeholder.dtype(), loco::DataType::Unknown); + ASSERT_EQ(placeholder.rank(), 0); + + placeholder.dtype(loco::DataType::FLOAT32); + ASSERT_EQ(placeholder.dtype(), loco::DataType::FLOAT32); + + placeholder.rank(2); + ASSERT_EQ(placeholder.rank(), 2); + + placeholder.dim(0) = 2; + placeholder.dim(1) = 3; + + ASSERT_TRUE(placeholder.dim(0).known()); + ASSERT_TRUE(placeholder.dim(1).known()); + + ASSERT_EQ(placeholder.dim(0), 2); + ASSERT_EQ(placeholder.dim(1), 3); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFRealDiv.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFRealDiv.test.cpp new file mode 100644 index 000000000..bfb8154a6 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFRealDiv.test.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFRealDiv.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFRealDivTest, constructor) +{ + moco::TFRealDiv div_node; + + ASSERT_EQ(div_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(div_node.opcode(), moco::TFOpcode::RealDiv); + + ASSERT_EQ(div_node.x(), nullptr); + ASSERT_EQ(div_node.y(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFRelu.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFRelu.test.cpp new file mode 100644 index 000000000..650e2550d --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFRelu.test.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFRelu.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFReluTest, constructor) +{ + moco::TFRelu relu_node; + + ASSERT_EQ(relu_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(relu_node.opcode(), moco::TFOpcode::Relu); + + ASSERT_EQ(relu_node.features(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFRelu6.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFRelu6.test.cpp new file mode 100644 index 000000000..9cce83df3 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFRelu6.test.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFRelu6.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFRelu6Test, constructor) +{ + moco::TFRelu6 relu6_node; + + ASSERT_EQ(relu6_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(relu6_node.opcode(), moco::TFOpcode::Relu6); + + ASSERT_EQ(relu6_node.features(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFReshape.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFReshape.test.cpp new file mode 100644 index 000000000..514c691e9 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFReshape.test.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFReshape.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFReshapeTest, constructor) +{ + moco::TFReshape reshape_node; + + ASSERT_EQ(reshape_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(reshape_node.opcode(), moco::TFOpcode::Reshape); + + ASSERT_EQ(reshape_node.tensor(), nullptr); + ASSERT_EQ(reshape_node.shape(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFRsqrt.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFRsqrt.test.cpp new file mode 100644 index 000000000..e94336dfe --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFRsqrt.test.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes//TFRsqrt.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFRsqrtTest, constructor) +{ + moco::TFRsqrt rsqrt_node; + + ASSERT_EQ(rsqrt_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(rsqrt_node.opcode(), moco::TFOpcode::Rsqrt); + + ASSERT_EQ(rsqrt_node.x(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFShape.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFShape.test.cpp new file mode 100644 index 000000000..28110d790 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFShape.test.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes//TFShape.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFShapeTest, constructor) +{ + moco::TFShape shape_node; + + ASSERT_EQ(shape_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(shape_node.opcode(), moco::TFOpcode::Shape); + + ASSERT_EQ(shape_node.input(), nullptr); + ASSERT_EQ(shape_node.dtype(), loco::DataType::Unknown); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFSoftmax.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFSoftmax.test.cpp new file mode 100644 index 000000000..67449feac --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFSoftmax.test.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFSoftmax.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFSoftmaxTest, constructor) +{ + moco::TFSoftmax softmax_node; + + ASSERT_EQ(softmax_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(softmax_node.opcode(), moco::TFOpcode::Softmax); + + ASSERT_EQ(softmax_node.logits(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFSqrt.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFSqrt.test.cpp new file mode 100644 index 000000000..942769f6c --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFSqrt.test.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFSqrt.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFSqrtTest, constructor) +{ + moco::TFSqrt sqrt_node; + + ASSERT_EQ(sqrt_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(sqrt_node.opcode(), moco::TFOpcode::Sqrt); + + ASSERT_EQ(sqrt_node.x(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFSquaredDifference.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFSquaredDifference.test.cpp new file mode 100644 index 000000000..c3ece9b70 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFSquaredDifference.test.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFSquaredDifference.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFSquaredDifferenceTest, constructor) +{ + moco::TFSquaredDifference sd_node; + + ASSERT_EQ(sd_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(sd_node.opcode(), moco::TFOpcode::SquaredDifference); + + ASSERT_EQ(sd_node.x(), nullptr); + ASSERT_EQ(sd_node.y(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFSqueeze.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFSqueeze.test.cpp new file mode 100644 index 000000000..034ca70b2 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFSqueeze.test.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFSqueeze.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFSqueezeTest, constructor) +{ + moco::TFSqueeze squeeze_node; + + ASSERT_EQ(squeeze_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(squeeze_node.opcode(), moco::TFOpcode::Squeeze); + + ASSERT_EQ(squeeze_node.input(), nullptr); + ASSERT_EQ(squeeze_node.squeeze_dims().size(), 0); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFStopGradient.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFStopGradient.test.cpp new file mode 100644 index 000000000..054ccda41 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFStopGradient.test.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFStopGradient.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFStopGradientTest, constructor) +{ + moco::TFStopGradient node; + + ASSERT_EQ(node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(node.opcode(), moco::TFOpcode::StopGradient); + + ASSERT_EQ(node.input(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFStridedSlice.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFStridedSlice.test.cpp new file mode 100644 index 000000000..9e7e45543 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFStridedSlice.test.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFStridedSlice.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFStridedSliceTest, constructor) +{ + moco::TFStridedSlice node; + + ASSERT_EQ(node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(node.opcode(), moco::TFOpcode::StridedSlice); + + ASSERT_EQ(node.input(), nullptr); + ASSERT_EQ(node.begin(), nullptr); + ASSERT_EQ(node.end(), nullptr); + ASSERT_EQ(node.strides(), nullptr); + ASSERT_EQ(node.begin_mask(), 0); + ASSERT_EQ(node.end_mask(), 0); + ASSERT_EQ(node.ellipsis_mask(), 0); + ASSERT_EQ(node.new_axis_mask(), 0); + ASSERT_EQ(node.shrink_axis_mask(), 0); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFSub.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFSub.test.cpp new file mode 100644 index 000000000..4b80713bd --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFSub.test.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFSub.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFSubTest, constructor) +{ + moco::TFSub sub_node; + + ASSERT_EQ(sub_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(sub_node.opcode(), moco::TFOpcode::Sub); + + ASSERT_EQ(sub_node.x(), nullptr); + ASSERT_EQ(sub_node.y(), nullptr); +} diff --git a/compiler/moco/lang/src/IR/Nodes/TFTanh.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFTanh.test.cpp new file mode 100644 index 000000000..38458a694 --- /dev/null +++ b/compiler/moco/lang/src/IR/Nodes/TFTanh.test.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 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 "moco/IR/Nodes/TFTanh.h" +#include "moco/IR/TFDialect.h" + +#include <gtest/gtest.h> + +TEST(TFTanhTest, constructor) +{ + moco::TFTanh tanh_node; + + ASSERT_EQ(tanh_node.dialect(), moco::TFDialect::get()); + ASSERT_EQ(tanh_node.opcode(), moco::TFOpcode::Tanh); + + ASSERT_EQ(tanh_node.x(), nullptr); +} |