• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
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 #define LOG_TAG "Operations"
18 
19 #include "LogicalNot.h"
20 
21 #include "OperationResolver.h"
22 #include "OperationsExecutionUtils.h"
23 
24 namespace android {
25 namespace nn {
26 namespace logical_not {
27 namespace {
28 
compute(const bool8 * input,const Shape & shape,bool8 * output)29 bool compute(const bool8* input, const Shape& shape, bool8* output) {
30     const auto size = getNumberOfElements(shape);
31     for (uint32_t i = 0; i < size; ++i) {
32         output[i] = input[i] == 0;
33     }
34     return true;
35 }
36 
37 }  // namespace
38 
prepare(IOperationExecutionContext * context)39 bool prepare(IOperationExecutionContext* context) {
40     Shape input = context->getInputShape(kInputTensor);
41     Shape output = context->getOutputShape(kOutputTensor);
42     NN_RET_CHECK(SetShape(input, &output));
43     return context->setOutputShape(kOutputTensor, output);
44 }
45 
execute(IOperationExecutionContext * context)46 bool execute(IOperationExecutionContext* context) {
47     return compute(context->getInputBuffer<bool8>(kInputTensor),
48                    context->getInputShape(kInputTensor),
49                    context->getOutputBuffer<bool8>(kOutputTensor));
50 }
51 
52 }  // namespace logical_not
53 
54 NN_REGISTER_OPERATION_DEFAULT_VALIDATION(LOGICAL_NOT, logical_not::prepare, logical_not::execute);
55 
56 }  // namespace nn
57 }  // namespace android
58