tvm
Loading...
Searching...
No Matches
include
tvm
s_tir
meta_schedule
feature_extractor.h
Go to the documentation of this file.
1
/*
2
* Licensed to the Apache Software Foundation (ASF) under one
3
* or more contributor license agreements. See the NOTICE file
4
* distributed with this work for additional information
5
* regarding copyright ownership. The ASF licenses this file
6
* to you under the Apache License, Version 2.0 (the
7
* "License"); you may not use this file except in compliance
8
* with the License. You may obtain a copy of the License at
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing,
13
* software distributed under the License is distributed on an
14
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
* KIND, either express or implied. See the License for the
16
* specific language governing permissions and limitations
17
* under the License.
18
*/
19
20
#ifndef TVM_S_TIR_META_SCHEDULE_FEATURE_EXTRACTOR_H_
21
#define TVM_S_TIR_META_SCHEDULE_FEATURE_EXTRACTOR_H_
22
23
#include <tvm/ffi/container/array.h>
24
#include <tvm/ffi/function.h>
25
#include <tvm/ffi/reflection/registry.h>
26
#include <tvm/ffi/string.h>
27
#include <
tvm/ir/prim/expr.h
>
28
#include <
tvm/runtime/tensor.h
>
29
#include <
tvm/s_tir/meta_schedule/measure_candidate.h
>
30
31
namespace
tvm
{
32
namespace
s_tir {
33
using namespace
tvm::prim
;
34
namespace
meta_schedule {
35
36
class
TuneContext;
37
39
class
FeatureExtractorNode
:
public
ffi::Object {
40
public
:
42
virtual
~FeatureExtractorNode
() =
default
;
43
44
static
void
RegisterReflection
() {
45
namespace
refl
= tvm::ffi::reflection;
46
refl::ObjectDef<FeatureExtractorNode>();
47
}
48
55
virtual
ffi::Array<tvm::runtime::Tensor>
ExtractFrom
(
56
const
TuneContext
&
context
,
const
ffi::Array<MeasureCandidate>&
candidates
) = 0;
57
TVM_FFI_DECLARE_OBJECT_INFO
(
"s_tir.meta_schedule.FeatureExtractor"
,
FeatureExtractorNode
,
58
ffi::Object);
59
};
60
62
class
PyFeatureExtractorNode
:
public
FeatureExtractorNode
{
63
public
:
70
using
FExtractFrom
= ffi::TypedFunction<ffi::Array<tvm::runtime::Tensor>(
71
const
TuneContext
&
context
,
const
ffi::Array<MeasureCandidate>&
candidates
)>;
73
FExtractFrom
f_extract_from
;
74
75
static
void
RegisterReflection
() {
76
// `f_extract_from` is not registered
77
namespace
refl
= tvm::ffi::reflection;
78
refl::ObjectDef<PyFeatureExtractorNode>();
79
}
80
81
ffi::Array<tvm::runtime::Tensor>
ExtractFrom
(
82
const
TuneContext
&
context
,
const
ffi::Array<MeasureCandidate>&
candidates
)
final
;
83
TVM_FFI_DECLARE_OBJECT_INFO_FINAL
(
"s_tir.meta_schedule.PyFeatureExtractor"
,
84
PyFeatureExtractorNode
,
FeatureExtractorNode
);
85
};
86
91
class
FeatureExtractor
:
public
ffi::ObjectRef {
92
public
:
103
TVM_DLL
static
FeatureExtractor
PerStoreFeature
(
int
buffers_per_store
= 5,
104
int
arith_intensity_curve_num_samples
= 10,
105
int
cache_line_bytes
= 64,
106
bool
extract_workload
=
false
);
112
TVM_DLL
static
FeatureExtractor
PyFeatureExtractor
(
113
PyFeatureExtractorNode::FExtractFrom
f_extract_from);
114
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE
(
FeatureExtractor
, ffi::ObjectRef,
115
FeatureExtractorNode
);
116
};
117
118
}
// namespace meta_schedule
119
}
// namespace s_tir
120
}
// namespace tvm
121
122
#endif
// TVM_S_TIR_META_SCHEDULE_FEATURE_EXTRACTOR_H_
tvm::With
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition
with_context.h:59
tvm::s_tir::meta_schedule::FeatureExtractorNode
Extractor for features from measure candidates for use in cost model.
Definition
feature_extractor.h:39
tvm::s_tir::meta_schedule::FeatureExtractorNode::ExtractFrom
virtual ffi::Array< tvm::runtime::Tensor > ExtractFrom(const TuneContext &context, const ffi::Array< MeasureCandidate > &candidates)=0
Extract features from the given measure candidate.
tvm::s_tir::meta_schedule::FeatureExtractorNode::TVM_FFI_DECLARE_OBJECT_INFO
TVM_FFI_DECLARE_OBJECT_INFO("s_tir.meta_schedule.FeatureExtractor", FeatureExtractorNode, ffi::Object)
tvm::s_tir::meta_schedule::FeatureExtractorNode::RegisterReflection
static void RegisterReflection()
Definition
feature_extractor.h:44
tvm::s_tir::meta_schedule::FeatureExtractorNode::~FeatureExtractorNode
virtual ~FeatureExtractorNode()=default
Virtual destructor.
tvm::s_tir::meta_schedule::FeatureExtractor
Managed reference to FeatureExtractorNode.
Definition
feature_extractor.h:91
tvm::s_tir::meta_schedule::FeatureExtractor::PyFeatureExtractor
static FeatureExtractor PyFeatureExtractor(PyFeatureExtractorNode::FExtractFrom f_extract_from)
Create a feature extractor with customized methods on the python-side.
tvm::s_tir::meta_schedule::FeatureExtractor::PerStoreFeature
static FeatureExtractor PerStoreFeature(int buffers_per_store=5, int arith_intensity_curve_num_samples=10, int cache_line_bytes=64, bool extract_workload=false)
Create a feature extractor that extracts features from each BufferStore.
tvm::s_tir::meta_schedule::FeatureExtractor::TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(FeatureExtractor, ffi::ObjectRef, FeatureExtractorNode)
tvm::s_tir::meta_schedule::PyFeatureExtractorNode
The feature extractor with customized methods on the python-side.
Definition
feature_extractor.h:62
tvm::s_tir::meta_schedule::PyFeatureExtractorNode::TVM_FFI_DECLARE_OBJECT_INFO_FINAL
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("s_tir.meta_schedule.PyFeatureExtractor", PyFeatureExtractorNode, FeatureExtractorNode)
tvm::s_tir::meta_schedule::PyFeatureExtractorNode::f_extract_from
FExtractFrom f_extract_from
The packed function to the ExtractFrom function.
Definition
feature_extractor.h:73
tvm::s_tir::meta_schedule::PyFeatureExtractorNode::FExtractFrom
ffi::TypedFunction< ffi::Array< tvm::runtime::Tensor >(const TuneContext &context, const ffi::Array< MeasureCandidate > &candidates)> FExtractFrom
Extract features from the given measure candidate.
Definition
feature_extractor.h:71
tvm::s_tir::meta_schedule::PyFeatureExtractorNode::RegisterReflection
static void RegisterReflection()
Definition
feature_extractor.h:75
tvm::s_tir::meta_schedule::PyFeatureExtractorNode::ExtractFrom
ffi::Array< tvm::runtime::Tensor > ExtractFrom(const TuneContext &context, const ffi::Array< MeasureCandidate > &candidates) final
Extract features from the given measure candidate.
tvm::s_tir::meta_schedule::TuneContext
Managed reference to TuneContextNode.
Definition
tune_context.h:101
expr.h
TIR expressions.
measure_candidate.h
tvm::prim
Definition
builtin.h:25
tvm
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition
analyzer.h:40
tensor.h
A device-independent managed Tensor abstraction.
Generated by
1.9.8