1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 #ifndef TENSORFLOW_LITE_EXPERIMENTAL_DELEGATES_COREML_BUILDERS_PAD_OP_BUILDER_H_ 16 #define TENSORFLOW_LITE_EXPERIMENTAL_DELEGATES_COREML_BUILDERS_PAD_OP_BUILDER_H_ 17 18 #include "tensorflow/lite/builtin_ops.h" 19 #include "tensorflow/lite/delegates/coreml/builders/op_builder.h" 20 21 namespace tflite { 22 namespace delegates { 23 namespace coreml { 24 25 enum class PadType { kPad, kMirrorPad }; 26 27 // Supports PAD, PADV2, MIRROR_PAD 28 class PadOpBuilder : public OpBuilder { 29 public: PadOpBuilder(GraphBuilder * graph_builder,PadType padding_type)30 explicit PadOpBuilder(GraphBuilder* graph_builder, PadType padding_type) 31 : OpBuilder(graph_builder), padding_type_(padding_type) {} 32 33 const std::string& DebugName() override; 34 35 CoreML::Specification::NeuralNetworkLayer* Build() override; 36 37 TfLiteStatus RegisterInputs(const TfLiteIntArray* inputs, 38 TfLiteContext* context) override; 39 40 TfLiteStatus RegisterOutputs(const TfLiteIntArray* outputs, 41 TfLiteContext* context) override; 42 43 void SetPadding(const TfLiteTensor* padding); 44 45 void SetConstantValue(const TfLiteTensor* constant_value); 46 47 private: 48 PadType padding_type_; 49 }; 50 51 } // namespace coreml 52 } // namespace delegates 53 } // namespace tflite 54 55 #endif // TENSORFLOW_LITE_EXPERIMENTAL_DELEGATES_COREML_BUILDERS_PAD_OP_BUILDER_H_ 56