Internal::GeneratorBase#
-
class GeneratorBase : public Halide::NamesInterface, public Halide::Internal::AbstractGenerator#
Subclassed by Halide::Generator< T >
Public Functions
-
inline int natural_vector_size(Halide::Type t) const#
Given a data type, return an estimate of the “natural” vector size for that data type when compiling for the current target.
-
template<typename data_t>
inline int natural_vector_size() const# Given a data type, return an estimate of the “natural” vector size for that data type when compiling for the current target.
-
template<typename ...Args>
inline void set_inputs(const Args&... args)# set_inputs is a variadic wrapper around set_inputs_vector, which makes usage much simpler in many cases, as it constructs the relevant entries for the vector for you, which is often a bit unintuitive at present.
The arguments are passed in Input<>-declaration-order, and the types must be compatible. Array inputs are passed as std::vector<> of the relevant type.
Note: at present, scalar input types must match exactly, i.e., for Input<uint8_t>, you must pass an argument that is actually uint8_t; an argument that is int-that-will-fit-in-uint8 will assert-fail at Halide compile time.
-
virtual std::string name() override#
Return the name of this Generator.
(This should always be the name used to register it.)
-
virtual GeneratorContext context() const override#
Return the Target and autoscheduler info that this Generator was created with.
Always legal to call on any AbstractGenerator instance, regardless of what other methods have been called. (All AbstractGenerator instances are expected to be created with immutable values for these, which can’t be changed for a given instance after creation. Note that Generator<> based subclasses can customize Target somewhat via init_from_context(); see Generator.h for more info.)
CALL-AFTER: any CALL-BEFORE: any
-
virtual std::vector<ArgInfo> arginfos() override#
Return a list of all the ArgInfos for this generator.
The list will be in the order that the input and outputs are declared (possibly interleaved). Any inputs or outputs added by a configure() method will be in the list, at the end, in the order added. All input and output names will be unique within a given Generator instance.
CALL-AFTER: configure() CALL-BEFORE: any
-
virtual bool allow_out_of_order_inputs_and_outputs() const override#
By default, a Generator must declare all Inputs before all Outputs.
In some unusual situations (e.g. metaprogramming situations), it’s desirable to allow them to be declared out-of-order and put the onus of a non-obvious call order on the coder; a Generator may override this to return ‘true’ to allow this behavior.
-
virtual void set_generatorparam_value(const std::string &name, const std::string &value) override#
Set the value for a specific GeneratorParam for an AbstractGenerator instance.
Names that aren’t known generator names should assert-fail.
Values that can’t be parsed for the specific GeneratorParam (e.g. passing “foo” where an integer is expected) should assert-fail at some point (either immediately, or when build_pipeline() is called)
This can be called multiple times, but only prior to build_pipeline().
CALL-AFTER: none CALL-BEFORE: build_pipeline
-
virtual std::vector<Parameter> input_parameter(const std::string &name) override#
Given the name of an input, return the Parameter(s) for that input.
(Most inputs will have exactly one, but inputs that are declared as arrays will have multiple.)
CALL-AFTER: build_pipeline CALL-BEFORE: none
-
virtual std::vector<Func> output_func(const std::string &name) override#
Given the name of an output, return the Func(s) for that output.
Most outputs will have exactly one, but outputs that are declared as arrays will have multiple.
Note that outputs with Tuple values are still just a single Func, though they do get realized as multiple Buffers.
Must be called after build_pipeline(), since the output Funcs will be undefined prior to that.
CALL-AFTER: build_pipeline() CALL-BEFORE: none
-
virtual void bind_input(const std::string &name, const std::vector<Parameter> &v) override#
Rebind a specified Input to refer to the given piece of IR, replacing the default ImageParam / Param in place for that Input.
Basic type-checking is done to ensure that inputs are still sane (e.g. types, dimensions, etc must match expectations).
CALL-AFTER: set_generatorparam_value CALL-BEFORE: build_pipeline
-
virtual bool emit_cpp_stub(const std::string &stub_file_path) override#
Emit a Generator Stub (.stub.h) file to the given path.
Not all Generators support this.
If you call this method, you should not call any other AbstractGenerator methods on this instance, before or after this call.
If the Generator is capable of emitting a Stub, do so and return true. (Errors during stub emission should assert-fail rather than returning false.)
If the Generator is not capable of emitting a Stub, do nothing and return false.
CALL-AFTER: none CALL-BEFORE: none
-
virtual bool emit_hlpipe(const std::string &hlpipe_file_path) override#
Emit a Serialized Halide Pipeline (.hlpipe) file to the given path.
Not all Generators support this.
If you call this method, you should not call any other AbstractGenerator methods on this instance, before or after this call.
If the Generator is capable of emitting an hlpipe, do so and return true. (Errors during hlpipe emission should assert-fail rather than returning false.)
If the Generator is not capable of emitting an hlpipe, do nothing and return false.
CALL-AFTER: none CALL-BEFORE: none
-
inline int natural_vector_size(Halide::Type t) const#