24.02.1
TensorPack.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2021 Arm Limited.
3
*
4
* SPDX-License-Identifier: MIT
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to
8
* deal in the Software without restriction, including without limitation the
9
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
* sell copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in all
14
* copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
* SOFTWARE.
23
*/
24
#include "
src/common/TensorPack.h
"
25
26
#include "
src/common/ITensorV2.h
"
27
#include "
src/common/utils/Validate.h
"
28
29
namespace
arm_compute
30
{
31
TensorPack::TensorPack
(
IContext
*ctx) :
AclTensorPack_
(), _pack()
32
{
33
ARM_COMPUTE_ASSERT_NOT_NULLPTR
(ctx);
34
this->
header
.
ctx
= ctx;
35
this->
header
.
ctx
->
inc_ref
();
36
}
37
38
TensorPack::~TensorPack
()
39
{
40
this->
header
.
ctx
->
dec_ref
();
41
this->
header
.
type
=
detail::ObjectType::Invalid
;
42
}
43
44
AclStatus
TensorPack::add_tensor
(
ITensorV2
*
tensor
, int32_t slot_id)
45
{
46
_pack.
add_tensor
(slot_id,
tensor
->tensor());
47
return
AclStatus::AclSuccess
;
48
}
49
50
size_t
TensorPack::size
()
const
51
{
52
return
_pack.
size
();
53
}
54
55
bool
TensorPack::empty
()
const
56
{
57
return
_pack.
empty
();
58
}
59
60
bool
TensorPack::is_valid
()
const
61
{
62
return
this->
header
.
type
==
detail::ObjectType::TensorPack
;
63
}
64
65
arm_compute::ITensor
*
TensorPack::get_tensor
(int32_t slot_id)
66
{
67
return
_pack.
get_tensor
(slot_id);
68
}
69
70
arm_compute::ITensorPack
&
TensorPack::get_tensor_pack
()
71
{
72
return
_pack;
73
}
74
}
// namespace arm_compute
arm_compute::ITensorV2
Base class specifying the tensor interface.
Definition:
ITensorV2.h:45
arm_compute::TensorPack::TensorPack
TensorPack(IContext *ctx)
Constructor.
Definition:
TensorPack.cpp:31
AclStatus
AclStatus
Definition:
AclTypes.h:50
arm_compute::TensorPack::add_tensor
AclStatus add_tensor(ITensorV2 *tensor, int32_t slot_id)
Add tensor to the pack.
Definition:
TensorPack.cpp:44
arm_compute::detail::ObjectType::TensorPack
@ TensorPack
AclSuccess
@ AclSuccess
Call succeeded, leading to valid state for all involved objects/data.
Definition:
AclTypes.h:52
arm_compute::TensorPack::is_valid
bool is_valid() const
Checks if an object is valid.
Definition:
TensorPack.cpp:60
arm_compute::TensorPack::get_tensor
arm_compute::ITensor * get_tensor(int32_t slot_id)
Get tensor of a given id from the pac.
Definition:
TensorPack.cpp:65
arm_compute::ITensor
Interface for CPU tensor.
Definition:
ITensor.h:36
arm_compute::ITensorPack::add_tensor
void add_tensor(int id, ITensor *tensor)
Add tensor to the pack.
Definition:
ITensorPack.cpp:38
arm_compute::ITensorPack::get_tensor
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
Definition:
ITensorPack.cpp:63
arm_compute::TensorPack::empty
bool empty() const
Checks if pack is empty.
Definition:
TensorPack.cpp:55
arm_compute::IContext
Context interface.
Definition:
IContext.h:51
arm_compute::IContext::inc_ref
void inc_ref() const
Increment context refcount.
Definition:
IContext.h:71
arm_compute::ITensorPack::empty
bool empty() const
Checks if pack is empty.
Definition:
ITensorPack.cpp:79
arm_compute::detail::ObjectType::Invalid
@ Invalid
arm_compute::ITensorPack
Tensor packing service.
Definition:
ITensorPack.h:39
Validate.h
ARM_COMPUTE_ASSERT_NOT_NULLPTR
#define ARM_COMPUTE_ASSERT_NOT_NULLPTR(ptr)
Definition:
Validate.h:38
arm_compute::ITensorPack::size
size_t size() const
Pack size accessor.
Definition:
ITensorPack.cpp:74
arm_compute::detail::Header::ctx
IContext * ctx
Definition:
Object.h:60
tensor
CLTensor * tensor
Pointer to the auxiliary tensor.
Definition:
ClWorkloadRuntime.cpp:67
arm_compute::TensorPack::~TensorPack
~TensorPack()
Destructor.
Definition:
TensorPack.cpp:38
ITensorV2.h
TensorPack.h
AclTensorPack_::header
arm_compute::detail::Header header
Definition:
TensorPack.h:33
arm_compute::detail::Header::type
ObjectType type
Definition:
Object.h:59
arm_compute
Copyright (c) 2017-2024 Arm Limited.
Definition:
introduction.dox:24
arm_compute::TensorPack::get_tensor_pack
arm_compute::ITensorPack & get_tensor_pack()
Get legacy tensor pack.
Definition:
TensorPack.cpp:70
arm_compute::IContext::dec_ref
void dec_ref() const
Decrement context refcount.
Definition:
IContext.h:76
AclTensorPack_
Definition:
TensorPack.h:31
arm_compute::TensorPack::size
size_t size() const
Pack size accessor.
Definition:
TensorPack.cpp:50
src
common
TensorPack.cpp
Generated on Mon Mar 18 2024 11:31:56 for Compute Library by
1.8.17