From c537c7c524eb11636f4b1c90809722c622370329 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=84=B8=ED=9D=AC/On-Device=20Lab=28SR=29/Princip?= =?utf8?q?al=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 1 Jul 2019 14:13:10 +0900 Subject: [PATCH] [moco_tf] Introduce TFDialect (#4020) * [moco_tf] Introduce TFDialect This will introduce TFDialect inherited from loco::Dialect to provide IRs for TensorFlow dialect. Signed-off-by: SaeHie Park * rename to TFDialect * fix typo * fix rename --- contrib/moco-tf/src/Dialect/TFDialect.cpp | 31 +++++++++++++++++ contrib/moco-tf/src/Dialect/TFDialect.h | 46 ++++++++++++++++++++++++++ contrib/moco-tf/src/Dialect/TFDialect.test.cpp | 29 ++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 contrib/moco-tf/src/Dialect/TFDialect.cpp create mode 100644 contrib/moco-tf/src/Dialect/TFDialect.h create mode 100644 contrib/moco-tf/src/Dialect/TFDialect.test.cpp diff --git a/contrib/moco-tf/src/Dialect/TFDialect.cpp b/contrib/moco-tf/src/Dialect/TFDialect.cpp new file mode 100644 index 0000000..7302247 --- /dev/null +++ b/contrib/moco-tf/src/Dialect/TFDialect.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 "TFDialect.h" + +namespace moco +{ +namespace tf +{ + +loco::Dialect *TFDialect::get(void) +{ + static TFDialect d; + return &d; +} + +} // namespace tf +} // namespace moco diff --git a/contrib/moco-tf/src/Dialect/TFDialect.h b/contrib/moco-tf/src/Dialect/TFDialect.h new file mode 100644 index 0000000..9074e18 --- /dev/null +++ b/contrib/moco-tf/src/Dialect/TFDialect.h @@ -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. + */ + +#ifndef __MOCO_TF_DIALECT_TFDIALECT_H__ +#define __MOCO_TF_DIALECT_TFDIALECT_H__ + +#include + +namespace moco +{ +namespace tf +{ + +/** + * @brief A singleton for TensorFlow Dialect + */ +class TFDialect final : public loco::Dialect +{ +private: + TFDialect() = default; + +public: + TFDialect(const TFDialect &) = delete; + TFDialect(TFDialect &&) = delete; + +public: + static loco::Dialect *get(void); +}; + +} // namespace tf +} // namespace moco + +#endif // __MOCO_TF_DIALECT_TFDIALECT_H__ diff --git a/contrib/moco-tf/src/Dialect/TFDialect.test.cpp b/contrib/moco-tf/src/Dialect/TFDialect.test.cpp new file mode 100644 index 0000000..f89eaaf --- /dev/null +++ b/contrib/moco-tf/src/Dialect/TFDialect.test.cpp @@ -0,0 +1,29 @@ +/* + * 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 "TFDialect.h" + +#include + +TEST(TFDialectTest, get) +{ + auto d = moco::tf::TFDialect::get(); + + // get() SHOULD return a valid(non-null) pointer + ASSERT_NE(d, nullptr); + // The return value SHOULD be stable across multiple invocations + ASSERT_EQ(d, moco::tf::TFDialect::get()); +} -- 2.7.4