+++ /dev/null
-/*
- * Copyright (c) 2018 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 _MIR_SCALAR_H_
-#define _MIR_SCALAR_H_
-
-#include <memory>
-#include <cassert>
-#include <cstring>
-
-#include "mir/DataType.h"
-
-namespace mir
-{
-/**
- * @brief Scalar class
- */
-class Scalar
-{
-public:
- /**
- * @brief Class for Scalar values in modelIR
- * @param data Data pointer
- * @param data_type Data type
- * @param data_size Data size
- */
- explicit Scalar(const char *data, DataType data_type, unsigned data_size)
- { // NOLINT(cppcoreguidelines-pro-type-member-init, hicpp-member-init)
- assert(data_size <= _max_scalar_length);
- _data_type = data_type;
- memcpy(_data, data, data_size);
- }
-
- /**
- * @return Pointer on data
- */
- char *getRawData() { return _data; }
-
- /**
- * @return Data type
- */
- DataType getDataType() { return _data_type; }
-
- /**
- * @return Data size
- */
- int getDataSize() const
- {
- switch (_data_type)
- {
- case DataType::UNKNOWN:
- return -1;
- case DataType::FLOAT32:
- case DataType::INT32:
- return 4;
- case DataType::INT64:
- return 8;
- default:
- assert(false);
- }
- }
- /**
- * @tparam T Class of returned object
- * @return Object of T type
- */
- template <typename T> T get() const
- {
- assert(static_cast<int>(sizeof(T)) <= getDataSize());
- T result;
- memcpy(&result, _data, sizeof(T));
- return result;
- }
-
-private:
- static const unsigned int _max_scalar_length = 8;
- DataType _data_type;
- char _data[_max_scalar_length];
-};
-
-} // namespace mir
-
-#endif //_MIR_SCALAR_H_