2 * Copyright (c) 2018 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 #include "ir/Operand.h"
24 size_t Operand::operandSize(void) const
26 const uint32_t ranks = shape().rank();
29 for (uint32_t rank = 0; rank < ranks; rank++)
31 elements *= shape().dim(rank);
34 DataType type = typeInfo().type();
35 size_t element_size = sizeOfDataType(type);
37 // Value of type is matched with OperandCode enum in NeuralNetworks.h
38 return element_size * elements;
41 void Operand::insertUse(const OperationIndex &idx) { _uses.insert(idx); }
43 void Operand::removeUse(const OperationIndex &idx) { _uses.remove(idx); }
45 void Operand::insertDef(const OperationIndex &idx)
47 assert(!isConstant());
48 assert(_def.size() == 0);
53 void Operand::removeDef(const OperationIndex &idx)
55 assert(_def.contains(idx));