ONE - On-device Neural Engine
Loading...
Searching...
No Matches
TensorContext.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#ifndef __NNKIT_SUPPORT_MOCO_TF_TENSOR_CONTEXT_H__
18#define __NNKIT_SUPPORT_MOCO_TF_TENSOR_CONTEXT_H__
19
20#include "nnkit/TensorContext.h"
22
24
25#include <vector>
26#include <memory>
27
28namespace nnkit
29{
30namespace support
31{
32namespace moco
33{
34namespace tf
35{
37using ParsedTensors = std::vector<std::unique_ptr<ParsedTensor>>;
38
43{
44public:
45 TensorContext(const ParsedTensors &tensors) : _tensors(tensors)
46 {
47 // empty
48 }
49
50 TensorContext(const TensorContext &) = delete;
52
53public:
54 uint32_t size(void) const override { return _tensors.size(); }
55
56public:
57 std::string name(uint32_t n) const override // name with ":0", ":1", etc
58 {
59 return _tensors.at(n)->name();
60 }
61
62public:
63 nncc::core::ADT::tensor::Shape shape(uint32_t n) const override
64 {
65 return _tensors.at(n)->shape();
66 }
67
68public:
69 // Float (fp32) tensor support
70 bool isFloatTensor(uint32_t n) const override { return _tensors.at(n)->isFloatTensor(); }
71
72 virtual void getMutableFloatTensor(uint32_t n,
74 virtual void getConstFloatTensor(uint32_t n,
76
77private:
78 const ParsedTensors &_tensors;
79};
80
81} // namespace tf
82} // namespace moco
83} // namespace support
84} // namespace nnkit
85
86#endif // __NNKIT_SUPPORT_MOCO_TF_TENSOR_CONTEXT_H__
Parent class of InputTensorContext and OutputTensorContext.
virtual void getMutableFloatTensor(uint32_t n, const nnkit::TensorContext::TypedAccessor< float > &f)=0
TensorContext(const ParsedTensors &tensors)
nncc::core::ADT::tensor::Shape shape(uint32_t n) const override
TensorContext(TensorContext &&)=delete
bool isFloatTensor(uint32_t n) const override
uint32_t size(void) const override
virtual void getConstFloatTensor(uint32_t n, const nnkit::TensorContext::TypedReader< float > &f) const =0
TensorContext(const TensorContext &)=delete
std::string name(uint32_t n) const override
Class to store tensor information parsed from test.info file under moco/test/tf.
Definition Log.h:23
std::vector< std::unique_ptr< ParsedTensor > > ParsedTensors
std::function< void(const TensorContext &, uint32_t n, const nncc::core::ADT::tensor::Reader< T > &)> TypedReader
std::function< void(const TensorContext &, uint32_t n, nncc::core::ADT::tensor::Accessor< T > &)> TypedAccessor