tvm
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_META_SCHEDULE_FEATURE_EXTRACTOR_H_
21 #define TVM_META_SCHEDULE_FEATURE_EXTRACTOR_H_
22 
24 #include <tvm/node/reflection.h>
27 #include <tvm/runtime/ndarray.h>
28 #include <tvm/runtime/object.h>
30 
31 namespace tvm {
32 namespace meta_schedule {
33 
34 class TuneContext;
35 
38  public:
40  virtual ~FeatureExtractorNode() = default;
41 
43 
51  const Array<MeasureCandidate>& candidates) = 0;
52 
53  static constexpr const char* _type_key = "meta_schedule.FeatureExtractor";
55 };
56 
59  public:
67  const TuneContext& context, const Array<MeasureCandidate>& candidates)>;
73 
78 
80  // `f_extract_from` is not visited
81  // `f_as_string` is not visited
82  }
83 
85  const Array<MeasureCandidate>& candidates) final;
86 
87  static constexpr const char* _type_key = "meta_schedule.PyFeatureExtractor";
89 };
90 
96  public:
107  TVM_DLL static FeatureExtractor PerStoreFeature(int buffers_per_store = 5,
108  int arith_intensity_curve_num_samples = 10,
109  int cache_line_bytes = 64,
110  bool extract_workload = false);
121 };
122 
123 } // namespace meta_schedule
124 } // namespace tvm
125 
126 #endif // TVM_META_SCHEDULE_FEATURE_EXTRACTOR_H_
Runtime Array container types.
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
Extractor for features from measure candidates for use in cost model.
Definition: feature_extractor.h:37
void VisitAttrs(tvm::AttrVisitor *v)
Definition: feature_extractor.h:42
TVM_DECLARE_BASE_OBJECT_INFO(FeatureExtractorNode, Object)
virtual ~FeatureExtractorNode()=default
Virtual destructor.
static constexpr const char * _type_key
Definition: feature_extractor.h:53
virtual Array< tvm::runtime::NDArray > ExtractFrom(const TuneContext &context, const Array< MeasureCandidate > &candidates)=0
Extract features from the given measure candidate.
Managed reference to FeatureExtractorNode.
Definition: feature_extractor.h:95
TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(FeatureExtractor, ObjectRef, FeatureExtractorNode)
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.
static FeatureExtractor PyFeatureExtractor(PyFeatureExtractorNode::FExtractFrom f_extract_from, PyFeatureExtractorNode::FAsString f_as_string)
Create a feature extractor with customized methods on the python-side.
The feature extractor with customized methods on the python-side.
Definition: feature_extractor.h:58
Array< tvm::runtime::NDArray > ExtractFrom(const TuneContext &context, const Array< MeasureCandidate > &candidates) final
Extract features from the given measure candidate.
FAsString f_as_string
The packed function to the AsString function.
Definition: feature_extractor.h:77
TVM_DECLARE_FINAL_OBJECT_INFO(PyFeatureExtractorNode, FeatureExtractorNode)
static constexpr const char * _type_key
Definition: feature_extractor.h:87
void VisitAttrs(tvm::AttrVisitor *v)
Definition: feature_extractor.h:79
FExtractFrom f_extract_from
The packed function to the ExtractFrom function.
Definition: feature_extractor.h:75
Managed reference to TuneContextNode.
Definition: tune_context.h:95
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Base class of all object reference.
Definition: object.h:519
base class of all object containers.
Definition: object.h:171
Reference to string objects.
Definition: string.h:98
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
A device-independent managed NDArray abstraction.
A managed object in the TVM runtime.
Type-erased function used across TVM API.
Reflection and serialization of compiler IR/AST nodes.
Runtime String container types.