ONE - On-device Neural Engine
Loading...
Searching...
No Matches
TensorContext.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 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
19
22
23namespace nnkit
24{
25namespace support
26{
27namespace tflite
28{
29
31{
32 return tensor_shape(_tensors.at(n));
33}
34
37{
40
41 auto t = _tensors.at(n);
42
43 float *data = reinterpret_cast<float *>(t->data.f);
44 auto overlay = make_overlay<float, LexicalLayout>(shape(n), data);
45
46 f(*this, n, overlay);
47}
48
51{
54
55 auto t = _tensors.at(n);
56
57 float *data = reinterpret_cast<float *>(t->data.f);
58 auto overlay = make_overlay<float, LexicalLayout>(shape(n), data);
59
60 f(*this, n, overlay);
61}
62
63} // namespace tflite
64} // namespace support
65} // namespace nnkit
void getConstFloatTensor(uint32_t n, const TensorContext::TypedReader< float > &f) const override
nncc::core::ADT::tensor::Shape shape(uint32_t n) const override
void getMutableFloatTensor(uint32_t n, const TensorContext::TypedAccessor< float > &f) override
Overlay< T > make_overlay(const Shape &shape, T *base)
Definition Overlay.h:48
nncc::core::ADT::tensor::Shape tensor_shape(const TfLiteTensor *t)
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
virtual TfLiteTensor * at(uint32_t n) const =0