This change to reflect MLIR's recent addition to LLVM's monorepo. Instead of stripping llvm from the http archive, use build file map to refer to both MLIR and LLVM within llvm-project and remove read-only copy that was temporarily there. Also bump the commit version until after the integration of MLIR into LLVM monorepo. PiperOrigin-RevId: 287547194 Change-Id: I4459b96702dc5eb19b58c7ceaa6cabb16f530a43
59 lines
2.3 KiB
C++
59 lines
2.3 KiB
C++
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
==============================================================================*/
|
|
|
|
#ifndef TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_OPERATOR_H_
|
|
#define TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_OPERATOR_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
#include "absl/container/flat_hash_map.h"
|
|
#include "flatbuffers/flatbuffers.h" // TF:flatbuffers
|
|
#include "llvm/ADT/Optional.h"
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include "mlir/IR/Attributes.h" // TF:llvm-project
|
|
#include "mlir/IR/Builders.h" // TF:llvm-project
|
|
#include "mlir/IR/Operation.h" // TF:llvm-project
|
|
#include "tensorflow/lite/schema/schema_generated.h"
|
|
|
|
namespace mlir {
|
|
|
|
// Returns the builtin op code for the given MLIR operation on success; emits
|
|
// error and returns llvm::None on failure.
|
|
llvm::Optional<tflite::BuiltinOperator> GetBuiltinOpCode(Operation *mlir_op);
|
|
|
|
// Packs the given MLIR operation into a TFLite FlatBuffer operator object.
|
|
// Returns the FlatBuffer offset for the operator on success; emits error and
|
|
// returns llvm::None on failure.
|
|
llvm::Optional<flatbuffers::Offset<tflite::Operator>> CreateFlatBufferOperator(
|
|
Operation *mlir_op, uint32_t opcode_index,
|
|
const std::vector<int32_t> &operands, const std::vector<int32_t> &results,
|
|
flatbuffers::FlatBufferBuilder *fbb);
|
|
|
|
// Populate the array of mlir::NamedAttributes corresponding to the given
|
|
// tflite::FlatbufferOptionsUnion.
|
|
// We use an out parameter per LLVM convention
|
|
void BuiltinOptionsToAttributes(
|
|
tflite::BuiltinOptionsUnion op_union, mlir::Builder builder,
|
|
// NOLINTNEXTLINE
|
|
llvm::SmallVectorImpl<mlir::NamedAttribute> &attributes);
|
|
|
|
} // namespace mlir
|
|
|
|
#endif // TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_OPERATOR_H_
|