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
namespace
meta_schedule {
34
35
class
TuneContext;
36
38
class
FeatureExtractorObj
:
public
ffi::Object {
39
public
:
41
virtual
~FeatureExtractorObj
() =
default
;
42
43
static
void
RegisterReflection
() {
44
namespace
refl = tvm::ffi::reflection;
45
refl::ObjectDef<FeatureExtractorObj>();
46
}
47
54
virtual
ffi::Array<tvm::ffi::Tensor>
ExtractFrom
(
55
const
TuneContext
& context,
const
ffi::Array<MeasureCandidate>& candidates) = 0;
56
TVM_FFI_DECLARE_OBJECT_INFO
(
"s_tir.meta_schedule.FeatureExtractor"
,
FeatureExtractorObj
,
57
ffi::Object);
58
};
59
61
class
PyFeatureExtractorObj
:
public
FeatureExtractorObj
{
62
public
:
69
using
FExtractFrom
= ffi::TypedFunction<ffi::Array<tvm::ffi::Tensor>(
70
const
TuneContext
& context,
const
ffi::Array<MeasureCandidate>& candidates)>;
72
FExtractFrom
f_extract_from
;
73
74
static
void
RegisterReflection
() {
75
// `f_extract_from` is not registered
76
namespace
refl = tvm::ffi::reflection;
77
refl::ObjectDef<PyFeatureExtractorObj>();
78
}
79
80
ffi::Array<tvm::ffi::Tensor>
ExtractFrom
(
const
TuneContext
& context,
81
const
ffi::Array<MeasureCandidate>& candidates)
final
;
82
TVM_FFI_DECLARE_OBJECT_INFO_FINAL
(
"s_tir.meta_schedule.PyFeatureExtractor"
,
PyFeatureExtractorObj
,
83
FeatureExtractorObj
);
84
};
85
90
class
FeatureExtractor
:
public
ffi::ObjectRef {
91
public
:
92
explicit
FeatureExtractor
(ffi::UnsafeInit tag, ffi::ObjectPtr<FeatureExtractorObj> data)
93
: ffi::ObjectRef(tag) {
94
data_ = std::move(data);
95
}
96
107
TVM_DLL
static
FeatureExtractor
PerStoreFeature
(
int
tensors_per_store = 5,
108
int
arith_intensity_curve_num_samples = 10,
109
int
cache_line_bytes = 64,
110
bool
extract_workload =
false
);
116
TVM_DLL
static
FeatureExtractor
PyFeatureExtractor
(
117
PyFeatureExtractorObj::FExtractFrom
f_extract_from);
118
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE
(
FeatureExtractor
, ffi::ObjectRef,
119
FeatureExtractorObj
);
120
};
121
122
}
// namespace meta_schedule
123
}
// namespace s_tir
124
}
// namespace tvm
125
126
#endif
// TVM_S_TIR_META_SCHEDULE_FEATURE_EXTRACTOR_H_
tvm::s_tir::meta_schedule::FeatureExtractorObj
Extractor for features from measure candidates for use in cost model.
Definition
feature_extractor.h:38
tvm::s_tir::meta_schedule::FeatureExtractorObj::ExtractFrom
virtual ffi::Array< tvm::ffi::Tensor > ExtractFrom(const TuneContext &context, const ffi::Array< MeasureCandidate > &candidates)=0
Extract features from the given measure candidate.
tvm::s_tir::meta_schedule::FeatureExtractorObj::~FeatureExtractorObj
virtual ~FeatureExtractorObj()=default
Virtual destructor.
tvm::s_tir::meta_schedule::FeatureExtractorObj::TVM_FFI_DECLARE_OBJECT_INFO
TVM_FFI_DECLARE_OBJECT_INFO("s_tir.meta_schedule.FeatureExtractor", FeatureExtractorObj, ffi::Object)
tvm::s_tir::meta_schedule::FeatureExtractorObj::RegisterReflection
static void RegisterReflection()
Definition
feature_extractor.h:43
tvm::s_tir::meta_schedule::FeatureExtractor
Managed reference to FeatureExtractorObj.
Definition
feature_extractor.h:90
tvm::s_tir::meta_schedule::FeatureExtractor::FeatureExtractor
FeatureExtractor(ffi::UnsafeInit tag, ffi::ObjectPtr< FeatureExtractorObj > data)
Definition
feature_extractor.h:92
tvm::s_tir::meta_schedule::FeatureExtractor::TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(FeatureExtractor, ffi::ObjectRef, FeatureExtractorObj)
tvm::s_tir::meta_schedule::FeatureExtractor::PyFeatureExtractor
static FeatureExtractor PyFeatureExtractor(PyFeatureExtractorObj::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 tensors_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 TensorStore.
tvm::s_tir::meta_schedule::PyFeatureExtractorObj
The feature extractor with customized methods on the python-side.
Definition
feature_extractor.h:61
tvm::s_tir::meta_schedule::PyFeatureExtractorObj::f_extract_from
FExtractFrom f_extract_from
The packed function to the ExtractFrom function.
Definition
feature_extractor.h:72
tvm::s_tir::meta_schedule::PyFeatureExtractorObj::FExtractFrom
ffi::TypedFunction< ffi::Array< tvm::ffi::Tensor >(const TuneContext &context, const ffi::Array< MeasureCandidate > &candidates)> FExtractFrom
Extract features from the given measure candidate.
Definition
feature_extractor.h:70
tvm::s_tir::meta_schedule::PyFeatureExtractorObj::TVM_FFI_DECLARE_OBJECT_INFO_FINAL
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("s_tir.meta_schedule.PyFeatureExtractor", PyFeatureExtractorObj, FeatureExtractorObj)
tvm::s_tir::meta_schedule::PyFeatureExtractorObj::ExtractFrom
ffi::Array< tvm::ffi::Tensor > ExtractFrom(const TuneContext &context, const ffi::Array< MeasureCandidate > &candidates) final
Extract features from the given measure candidate.
tvm::s_tir::meta_schedule::PyFeatureExtractorObj::RegisterReflection
static void RegisterReflection()
Definition
feature_extractor.h:74
tvm::s_tir::meta_schedule::TuneContext
Managed reference to TuneContextObj.
Definition
tune_context.h:99
expr.h
TIR expressions.
measure_candidate.h
tvm
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition
attr.h:23
tensor.h
Device-independent tensor allocation, copies, views and serialization.
Generated by
1.9.8