1 /* 2 * Copyright 2022 Google LLC 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 #ifndef FCP_AGGREGATION_CORE_TENSOR_AGGREGATOR_FACTORY_H_ 18 #define FCP_AGGREGATION_CORE_TENSOR_AGGREGATOR_FACTORY_H_ 19 20 #include <memory> 21 22 #include "fcp/aggregation/core/datatype.h" 23 #include "fcp/aggregation/core/tensor_aggregator.h" 24 #include "fcp/aggregation/core/tensor_shape.h" 25 #include "fcp/base/monitoring.h" 26 27 namespace fcp { 28 namespace aggregation { 29 30 // This class is the interface for the abstract factory that creates an instance 31 // of a TensorAggregator derived class. 32 class TensorAggregatorFactory { 33 public: 34 virtual ~TensorAggregatorFactory() = default; 35 36 // Creates an instance of a specific aggregator for the specified type of the 37 // aggregation instrinsic and the tensor specifications. 38 // TODO(team): Generalize this to allow multiple inputs and outputs, 39 // and an arbitrary number of arguments. 40 virtual StatusOr<std::unique_ptr<TensorAggregator>> Create( 41 DataType dtype, TensorShape shape) const = 0; 42 }; 43 44 } // namespace aggregation 45 } // namespace fcp 46 47 #endif // FCP_AGGREGATION_CORE_TENSOR_AGGREGATOR_FACTORY_H_ 48