1 #include "PyEnums.h"
2 
3 namespace Halide {
4 namespace PythonBindings {
5 
define_enums(py::module & m)6 void define_enums(py::module &m) {
7     py::enum_<Argument::Kind>(m, "ArgumentKind")
8         .value("InputScalar", Argument::Kind::InputScalar)
9         .value("InputBuffer", Argument::Kind::InputBuffer)
10         .value("OutputBuffer", Argument::Kind::OutputBuffer);
11 
12     py::enum_<DeviceAPI>(m, "DeviceAPI")
13         .value("None", DeviceAPI::None)
14         .value("Host", DeviceAPI::Host)
15         .value("Default_GPU", DeviceAPI::Default_GPU)
16         .value("CUDA", DeviceAPI::CUDA)
17         .value("OpenCL", DeviceAPI::OpenCL)
18         .value("GLSL", DeviceAPI::GLSL)
19         .value("OpenGLCompute", DeviceAPI::OpenGLCompute)
20         .value("Metal", DeviceAPI::Metal)
21         .value("Hexagon", DeviceAPI::Hexagon);
22 
23     py::enum_<LinkageType>(m, "LinkageType")
24         .value("External", LinkageType::External)
25         .value("ExternalPlusMetadata", LinkageType::ExternalPlusMetadata)
26         .value("Internal", LinkageType::Internal);
27 
28     py::enum_<LoopAlignStrategy>(m, "LoopAlignStrategy")
29         .value("AlignStart", LoopAlignStrategy::AlignStart)
30         .value("AlignEnd", LoopAlignStrategy::AlignEnd)
31         .value("NoAlign", LoopAlignStrategy::NoAlign)
32         .value("Auto", LoopAlignStrategy::Auto);
33 
34     py::enum_<MemoryType>(m, "MemoryType")
35         .value("Auto", MemoryType::Auto)
36         .value("Heap", MemoryType::Heap)
37         .value("Stack", MemoryType::Stack)
38         .value("Register", MemoryType::Register)
39         .value("GPUShared", MemoryType::GPUShared);
40 
41     py::enum_<NameMangling>(m, "NameMangling")
42         .value("Default", NameMangling::Default)
43         .value("C", NameMangling::C)
44         .value("CPlusPlus", NameMangling::CPlusPlus);
45 
46     py::enum_<PrefetchBoundStrategy>(m, "PrefetchBoundStrategy")
47         .value("Clamp", PrefetchBoundStrategy::Clamp)
48         .value("GuardWithIf", PrefetchBoundStrategy::GuardWithIf)
49         .value("NonFaulting", PrefetchBoundStrategy::NonFaulting);
50 
51     py::enum_<StmtOutputFormat>(m, "StmtOutputFormat")
52         .value("Text", StmtOutputFormat::Text)
53         .value("HTML", StmtOutputFormat::HTML);
54 
55     py::enum_<TailStrategy>(m, "TailStrategy")
56         .value("RoundUp", TailStrategy::RoundUp)
57         .value("GuardWithIf", TailStrategy::GuardWithIf)
58         .value("ShiftInwards", TailStrategy::ShiftInwards)
59         .value("Auto", TailStrategy::Auto);
60 
61     py::enum_<Target::OS>(m, "TargetOS")
62         .value("OSUnknown", Target::OS::OSUnknown)
63         .value("Linux", Target::OS::Linux)
64         .value("Windows", Target::OS::Windows)
65         .value("OSX", Target::OS::OSX)
66         .value("Android", Target::OS::Android)
67         .value("IOS", Target::OS::IOS)
68         .value("QuRT", Target::OS::QuRT)
69         .value("NoOS", Target::OS::NoOS)
70         .value("wasmrt", Target::OS::WebAssemblyRuntime);
71 
72     py::enum_<Target::Arch>(m, "TargetArch")
73         .value("ArchUnknown", Target::Arch::ArchUnknown)
74         .value("X86", Target::Arch::X86)
75         .value("ARM", Target::Arch::ARM)
76         .value("MIPS", Target::Arch::MIPS)
77         .value("Hexagon", Target::Arch::Hexagon)
78         .value("POWERPC", Target::Arch::POWERPC)
79         .value("WebAssembly", Target::Arch::WebAssembly);
80 
81     py::enum_<Target::Feature>(m, "TargetFeature")
82         .value("JIT", Target::Feature::JIT)
83         .value("Debug", Target::Feature::Debug)
84         .value("NoAsserts", Target::Feature::NoAsserts)
85         .value("NoBoundsQuery", Target::Feature::NoBoundsQuery)
86         .value("SSE41", Target::Feature::SSE41)
87         .value("AVX", Target::Feature::AVX)
88         .value("AVX2", Target::Feature::AVX2)
89         .value("FMA", Target::Feature::FMA)
90         .value("FMA4", Target::Feature::FMA4)
91         .value("F16C", Target::Feature::F16C)
92         .value("ARMv7s", Target::Feature::ARMv7s)
93         .value("NoNEON", Target::Feature::NoNEON)
94         .value("VSX", Target::Feature::VSX)
95         .value("POWER_ARCH_2_07", Target::Feature::POWER_ARCH_2_07)
96         .value("CUDA", Target::Feature::CUDA)
97         .value("CUDACapability30", Target::Feature::CUDACapability30)
98         .value("CUDACapability32", Target::Feature::CUDACapability32)
99         .value("CUDACapability35", Target::Feature::CUDACapability35)
100         .value("CUDACapability50", Target::Feature::CUDACapability50)
101         .value("CUDACapability61", Target::Feature::CUDACapability61)
102         .value("OpenCL", Target::Feature::OpenCL)
103         .value("CLDoubles", Target::Feature::CLDoubles)
104         .value("CLHalf", Target::Feature::CLHalf)
105         .value("CLAtomics64", Target::Feature::CLAtomics64)
106         .value("OpenGL", Target::Feature::OpenGL)
107         .value("OpenGLCompute", Target::Feature::OpenGLCompute)
108         .value("EGL", Target::Feature::EGL)
109         .value("UserContext", Target::Feature::UserContext)
110         .value("Matlab", Target::Feature::Matlab)
111         .value("Profile", Target::Feature::Profile)
112         .value("NoRuntime", Target::Feature::NoRuntime)
113         .value("Metal", Target::Feature::Metal)
114         .value("CPlusPlusMangling", Target::Feature::CPlusPlusMangling)
115         .value("LargeBuffers", Target::Feature::LargeBuffers)
116         .value("HVX_64", Target::Feature::HVX_64)
117         .value("HVX_128", Target::Feature::HVX_128)
118         .value("HVX_v62", Target::Feature::HVX_v62)
119         .value("HVX_v65", Target::Feature::HVX_v65)
120         .value("HVX_v66", Target::Feature::HVX_v66)
121         .value("HVX_shared_object", Target::Feature::HVX_shared_object)
122         .value("FuzzFloatStores", Target::Feature::FuzzFloatStores)
123         .value("SoftFloatABI", Target::Feature::SoftFloatABI)
124         .value("MSAN", Target::Feature::MSAN)
125         .value("AVX512", Target::Feature::AVX512)
126         .value("AVX512_KNL", Target::Feature::AVX512_KNL)
127         .value("AVX512_Skylake", Target::Feature::AVX512_Skylake)
128         .value("AVX512_Cannonlake", Target::Feature::AVX512_Cannonlake)
129         .value("TraceLoads", Target::Feature::TraceLoads)
130         .value("TraceStores", Target::Feature::TraceStores)
131         .value("TraceRealizations", Target::Feature::TraceRealizations)
132         .value("D3D12Compute", Target::Feature::D3D12Compute)
133         .value("StrictFloat", Target::Feature::StrictFloat)
134         .value("TSAN", Target::Feature::TSAN)
135         .value("ASAN", Target::Feature::ASAN)
136         .value("CheckUnsafePromises", Target::Feature::CheckUnsafePromises)
137         .value("HexagonDma", Target::Feature::HexagonDma)
138         .value("EmbedBitcode", Target::Feature::EmbedBitcode)
139         .value("EnableLLVMLoopOpt", Target::Feature::EnableLLVMLoopOpt)
140         .value("DisableLLVMLoopOpt", Target::Feature::DisableLLVMLoopOpt)
141         .value("WasmSimd128", Target::Feature::WasmSimd128)
142         .value("WasmSignExt", Target::Feature::WasmSignExt)
143         .value("WasmSatFloatToInt", Target::Feature::WasmSatFloatToInt)
144         .value("SVE", Target::Feature::SVE)
145         .value("SVE2", Target::Feature::SVE2)
146         .value("ARMDotProd", Target::Feature::ARMDotProd)
147         .value("FeatureEnd", Target::Feature::FeatureEnd);
148 
149     py::enum_<halide_type_code_t>(m, "TypeCode")
150         .value("Int", Type::Int)
151         .value("UInt", Type::UInt)
152         .value("Float", Type::Float)
153         .value("Handle", Type::Handle);
154 
155     py::enum_<Output>(m, "Output")
156         .value("assembly", Output::assembly)
157         .value("bitcode", Output::bitcode)
158         .value("c_header", Output::c_header)
159         .value("c_source", Output::c_source)
160         .value("cpp_stub", Output::cpp_stub)
161         .value("featurization", Output::featurization)
162         .value("llvm_assembly", Output::llvm_assembly)
163         .value("object", Output::object)
164         .value("python_extension", Output::python_extension)
165         .value("pytorch_wrapper", Output::pytorch_wrapper)
166         .value("registration", Output::registration)
167         .value("schedule", Output::schedule)
168         .value("static_library", Output::static_library)
169         .value("stmt", Output::stmt)
170         .value("stmt_html", Output::stmt_html)
171         .value("compiler_log", Output::compiler_log);
172 }
173 
174 }  // namespace PythonBindings
175 }  // namespace Halide
176