blob: affa51e857263dfbff6c2dc70307ffcb77228994 [file] [log] [blame]
// Copyright 2020 Google LLC
//
// 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
//
// https://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 IREE_COMPILER_TRANSLATION_CODEGENUTILS_CODEGENUTILS_H_
#define IREE_COMPILER_TRANSLATION_CODEGENUTILS_CODEGENUTILS_H_
#include "mlir/IR/Function.h"
#include "mlir/Support/LogicalResult.h"
namespace mlir {
namespace iree_compiler {
/// Drop trailing ones.
ArrayRef<int64_t> dropTrailingOnes(ArrayRef<int64_t> vector);
/// Get the name of the attr used to propogate the dispatch function name.
StringRef getDispatchFuncAttrName();
/// Get the name to use for the dispatch function by looking at the attribute on
/// the surrounding FuncOp.
Optional<StringRef> getDispatchFuncName(Operation *op);
/// Checks that a given function is a dispatch function implementaiton.
bool isDispatchFuncImpl(FuncOp funcOp);
/// The launch size is the size of the outputs of the kernel. For now all
/// outputs have to be the same shape and static shaped.
// TODO(ravishankarm) : Modify this to return the Values to support dynamic
// shapes.
LogicalResult getLaunchSize(FuncOp funcOp,
SmallVectorImpl<int64_t> &launchSize);
/// Gets the workgroup size. Has to be a static constant.
template <typename intType>
LogicalResult getWorkGroupSize(FuncOp funcOp,
SmallVectorImpl<intType> &workGroupSize);
/// Updates the workgroup size used for the dispatch region.
LogicalResult updateWorkGroupSize(Operation *op,
ArrayRef<int64_t> workGroupSize);
} // namespace iree_compiler
} // namespace mlir
#endif // IREE_COMPILER_TRANSLATION_CODEGENUTILS_CODEGENUTILS_H_