1 /* 2 * Copyright (C) 2019 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 "BurstBuilder" 18 19 #include "BurstBuilder.h" 20 21 #include "CompilationBuilder.h" 22 #include "ExecutionBurstController.h" 23 24 namespace android { 25 namespace nn { 26 BurstBuilder(const CompilationBuilder * compilation,std::vector<std::shared_ptr<ExecutionBurstController>> burstControllers)27BurstBuilder::BurstBuilder(const CompilationBuilder* compilation, 28 std::vector<std::shared_ptr<ExecutionBurstController>> burstControllers) 29 : mCompilation(compilation), mBurstControllers(std::move(burstControllers)) {} 30 tryLock()31bool BurstBuilder::tryLock() { 32 const bool alreadyRunning = mCurrentlyRunning.test_and_set(); 33 return !alreadyRunning; 34 } 35 unlock()36void BurstBuilder::unlock() { 37 mCurrentlyRunning.clear(); 38 } 39 getCompilation() const40const CompilationBuilder* BurstBuilder::getCompilation() const { 41 return mCompilation; 42 } 43 getControllerAt(size_t index) const44std::shared_ptr<ExecutionBurstController> BurstBuilder::getControllerAt(size_t index) const { 45 return index < mBurstControllers.size() ? mBurstControllers[index] : nullptr; 46 } 47 48 } // namespace nn 49 } // namespace android 50