MLIR
22.0.0git
lib
Dialect
Tosa
IR
TargetEnv.cpp
Go to the documentation of this file.
1
//===-------------- TosaTarget.cpp - TOSA Target utilities ----------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "
mlir/Dialect/Tosa/IR/TargetEnv.h
"
10
11
namespace
mlir
{
12
namespace
tosa {
13
14
TargetEnvAttr
lookupTargetEnv
(
Operation
*op) {
15
while
(op) {
16
op =
SymbolTable::getNearestSymbolTable
(op);
17
if
(!op)
18
break
;
19
20
if
(
auto
attr = op->
getAttrOfType
<TargetEnvAttr>(TargetEnvAttr::name))
21
return
attr;
22
23
op = op->
getParentOp
();
24
}
25
26
return
{};
27
}
28
29
TargetEnvAttr
getDefaultTargetEnv
(
MLIRContext
*context) {
30
return
TargetEnvAttr::get
(context, Level::eightK,
31
{Profile::pro_int, Profile::pro_fp}, {});
32
}
33
34
TargetEnvAttr
lookupTargetEnvOrDefault
(
Operation
*op) {
35
if
(
auto
attr =
lookupTargetEnv
(op))
36
return
attr;
37
38
return
getDefaultTargetEnv
(op->
getContext
());
39
}
40
41
}
// namespace tosa
42
}
// namespace mlir
TargetEnv.h
mlir::MLIRContext
MLIRContext is the top-level object for a collection of MLIR operations.
Definition:
MLIRContext.h:63
mlir::Operation
Operation is the basic unit of execution within MLIR.
Definition:
Operation.h:88
mlir::Operation::getAttrOfType
AttrClass getAttrOfType(StringAttr name)
Definition:
Operation.h:550
mlir::Operation::getContext
MLIRContext * getContext()
Return the context this operation is associated with.
Definition:
Operation.h:216
mlir::Operation::getParentOp
Operation * getParentOp()
Returns the closest surrounding operation that contains this operation or nullptr if this is a top-le...
Definition:
Operation.h:234
mlir::SymbolTable::getNearestSymbolTable
static Operation * getNearestSymbolTable(Operation *from)
Returns the nearest symbol table from a given operation from.
Definition:
SymbolTable.cpp:336
mlir::tosa::getDefaultTargetEnv
TargetEnvAttr getDefaultTargetEnv(MLIRContext *context)
Definition:
TargetEnv.cpp:29
mlir::tosa::lookupTargetEnv
TargetEnvAttr lookupTargetEnv(Operation *op)
Definition:
TargetEnv.cpp:14
mlir::tosa::lookupTargetEnvOrDefault
TargetEnvAttr lookupTargetEnvOrDefault(Operation *op)
Queries the target environment recursively from enclosing symbol table ops containing the given op or...
Definition:
TargetEnv.cpp:34
mlir
Include the generated interface declarations.
Definition:
LocalAliasAnalysis.h:20
mlir::get
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
Definition:
BytecodeImplementation.h:509
Generated on Sat Oct 11 2025 00:43:39 for MLIR by
1.9.1