2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __ONERT_BACKEND_I_PORTABLE_TENSOR_H__
18 #define __ONERT_BACKEND_I_PORTABLE_TENSOR_H__
20 #include "backend/ITensor.h"
28 * @brief A tensor class that is portable for other backends
30 * Backends that use derivatives of this interface can reuse each other's tensors without copying.
31 * Here's criterion to be a portable tensor:
32 * - it must not have any paddings
33 * - No special operations on @c access method
34 * - e.g. CL memory must map/unmap to use it from CPU, the memory so it cannot be portable
36 class IPortableTensor : public ITensor
39 virtual ~IPortableTensor() = default;
40 virtual bool is_sparse() const { return false; }
41 virtual const uint16_t *w1_segments() const { return nullptr; }
42 virtual const uint16_t *w1_indices() const { return nullptr; }
45 bool has_padding() const final { return false; }
46 void access(const std::function<void(ITensor &tensor)> &fn) final { fn(*this); }
49 } // namespace backend
52 #endif // __ONERT_BACKEND_I_PORTABLE_TENSOR_H__