Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ParamMap #7675

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,6 @@ SOURCE_FILES = \
OutputImageParam.cpp \
ParallelRVar.cpp \
Parameter.cpp \
ParamMap.cpp \
PartitionLoops.cpp \
Pipeline.cpp \
Prefetch.cpp \
Expand Down Expand Up @@ -754,7 +753,6 @@ HEADER_FILES = \
ParallelRVar.h \
Param.h \
Parameter.h \
ParamMap.h \
PartitionLoops.h \
Pipeline.h \
Prefetch.h \
Expand Down
7 changes: 0 additions & 7 deletions README_python.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,6 @@ with some differences where the C++ idiom is either inappropriate or impossible:

- `Func::async` becomes `Func.async_` because `async` is a Python keyword.

- `ParamMap` isn't supported as an argument to any `Func` or `Pipeline`
method, and never will be: it exists as a way to support thread-safe
arguments to JIT-compiled functions, which can now be supported more simply
and elegantly via `compile_to_callable()`. (It is likely that `ParamMap`
will be removed from the C++ bindings in a future version of Halide as
well.)

- The `not` keyword cannot be used to negate boolean Halide expressions.
Instead, the `logical_not` function can be used and is equivalent to using
`operator!` in C++.
Expand Down
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ set(HEADER_FILES
ParallelRVar.h
Param.h
Parameter.h
ParamMap.h
PartitionLoops.h
Pipeline.h
Prefetch.h
Expand Down Expand Up @@ -279,7 +278,6 @@ set(SOURCE_FILES
OutputImageParam.cpp
ParallelRVar.cpp
Parameter.cpp
ParamMap.cpp
PartitionLoops.cpp
Pipeline.cpp
Prefetch.cpp
Expand Down
1 change: 1 addition & 0 deletions src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "Deinterleave.h"
#include "EmulateFloat16Math.h"
#include "ExprUsesVar.h"
#include "ExternFuncArgument.h"
#include "FindIntrinsics.h"
#include "IREquality.h"
#include "IROperator.h"
Expand Down
40 changes: 16 additions & 24 deletions src/Func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3174,38 +3174,34 @@ FuncTupleElementRef::operator Expr() const {
return Internal::Call::make(func_ref.function(), args, idx);
}

Realization Func::realize(std::vector<int32_t> sizes, const Target &target,
const ParamMap &param_map) {
Realization Func::realize(std::vector<int32_t> sizes, const Target &target) {
user_assert(defined()) << "Can't realize undefined Func.\n";
return pipeline().realize(std::move(sizes), target, param_map);
return pipeline().realize(std::move(sizes), target);
}

Realization Func::realize(JITUserContext *context,
std::vector<int32_t> sizes,
const Target &target,
const ParamMap &param_map) {
const Target &target) {
user_assert(defined()) << "Can't realize undefined Func.\n";
return pipeline().realize(context, std::move(sizes), target, param_map);
return pipeline().realize(context, std::move(sizes), target);
}

void Func::infer_input_bounds(const std::vector<int32_t> &sizes,
const Target &target,
const ParamMap &param_map) {
infer_input_bounds(nullptr, sizes, target, param_map);
const Target &target) {
infer_input_bounds(nullptr, sizes, target);
}

void Func::infer_input_bounds(JITUserContext *context,
const std::vector<int32_t> &sizes,
const Target &target,
const ParamMap &param_map) {
const Target &target) {
user_assert(defined()) << "Can't infer input bounds on an undefined Func.\n";
vector<Buffer<>> outputs(func.outputs());
for (size_t i = 0; i < outputs.size(); i++) {
Buffer<> im(func.output_types()[i], nullptr, sizes);
outputs[i] = std::move(im);
}
Realization r(std::move(outputs));
infer_input_bounds(context, r, target, param_map);
infer_input_bounds(context, r, target);
}

OutputImageParam Func::output_buffer() const {
Expand Down Expand Up @@ -3372,29 +3368,25 @@ JITHandlers &Func::jit_handlers() {
}

void Func::realize(Pipeline::RealizationArg outputs,
const Target &target,
const ParamMap &param_map) {
pipeline().realize(std::move(outputs), target, param_map);
const Target &target) {
pipeline().realize(std::move(outputs), target);
}

void Func::realize(JITUserContext *context,
Pipeline::RealizationArg outputs,
const Target &target,
const ParamMap &param_map) {
pipeline().realize(context, std::move(outputs), target, param_map);
const Target &target) {
pipeline().realize(context, std::move(outputs), target);
}

void Func::infer_input_bounds(Pipeline::RealizationArg outputs,
const Target &target,
const ParamMap &param_map) {
pipeline().infer_input_bounds(std::move(outputs), target, param_map);
const Target &target) {
pipeline().infer_input_bounds(std::move(outputs), target);
}

void Func::infer_input_bounds(JITUserContext *context,
Pipeline::RealizationArg outputs,
const Target &target,
const ParamMap &param_map) {
pipeline().infer_input_bounds(context, std::move(outputs), target, param_map);
const Target &target) {
pipeline().infer_input_bounds(context, std::move(outputs), target);
}

void Func::compile_jit(const Target &target) {
Expand Down
63 changes: 12 additions & 51 deletions src/Func.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
namespace Halide {

class OutputImageParam;
class ParamMap;

/** A class that can represent Vars or RVars. Used for reorder calls
* which can accept a mix of either. */
Expand Down Expand Up @@ -775,19 +774,9 @@ class Func {
*
* In Halide formal arguments of a computation are specified using
* Param<T> and ImageParam objects in the expressions defining the
* computation. The param_map argument to realize allows
* specifying a set of per-call parameters to be used for a
* specific computation. This method is thread-safe where the
* globals used by Param<T> and ImageParam are not. Any parameters
* that are not in the param_map are taken from the global values,
* so those can continue to be used if they are not changing
* per-thread.
*
* One can explicitly construct a ParamMap and
* use its set method to insert Parameter to scalar or Buffer
* value mappings. (NOTE: ParamMap is deprecated in Halide 16 and
* will be removed in Halide 17. Callers requiring threadsafe JIT
* calls should migrate to use compile_to_callable() instead.)
* computation. Note that this method is not thread-safe, in that
* Param<T> and ImageParam are globals shared by all threads; to call
* jitted code in a thread-safe manner, use compile_to_callable() instead.
*
\code
Param<int32> p(42);
Expand All @@ -796,12 +785,9 @@ class Func {

Buffer<int32_t) arg_img(10, 10);
<fill in arg_img...>
ParamMap params;
params.set(p, 17);
params.set(img, arg_img);

Target t = get_jit_target_from_environment();
Buffer<int32_t> result = f.realize({10, 10}, t, params);
Buffer<int32_t> result = f.realize({10, 10}, t);
\endcode
*
* Alternatively, an initializer list can be used
Expand Down Expand Up @@ -830,8 +816,7 @@ class Func {
* instead.
*
*/
Realization realize(std::vector<int32_t> sizes = {}, const Target &target = Target(),
const ParamMap &param_map = ParamMap::empty_map());
Realization realize(std::vector<int32_t> sizes = {}, const Target &target = Target());

/** Same as above, but takes a custom user-provided context to be
* passed to runtime functions. This can be used to pass state to
Expand All @@ -840,17 +825,15 @@ class Func {
* that does not take a context. */
Realization realize(JITUserContext *context,
std::vector<int32_t> sizes = {},
const Target &target = Target(),
const ParamMap &param_map = ParamMap::empty_map());
const Target &target = Target());

/** Evaluate this function into an existing allocated buffer or
* buffers. If the buffer is also one of the arguments to the
* function, strange things may happen, as the pipeline isn't
* necessarily safe to run in-place. If you pass multiple buffers,
* they must have matching sizes. This form of realize does *not*
* automatically copy data back from the GPU. */
void realize(Pipeline::RealizationArg outputs, const Target &target = Target(),
const ParamMap &param_map = ParamMap::empty_map());
void realize(Pipeline::RealizationArg outputs, const Target &target = Target());

/** Same as above, but takes a custom user-provided context to be
* passed to runtime functions. This can be used to pass state to
Expand All @@ -859,52 +842,30 @@ class Func {
* that does not take a context. */
void realize(JITUserContext *context,
Pipeline::RealizationArg outputs,
const Target &target = Target(),
const ParamMap &param_map = ParamMap::empty_map());
const Target &target = Target());

/** For a given size of output, or a given output buffer,
* determine the bounds required of all unbound ImageParams
* referenced. Communicates the result by allocating new buffers
* of the appropriate size and binding them to the unbound
* ImageParams.
*
* Set the documentation for Func::realize regarding the
* ParamMap. There is one difference in that input Buffer<>
* arguments that are being inferred are specified as a pointer to
* the Buffer<> in the ParamMap. E.g.
*
\code
Param<int32> p(42);
ImageParam img(Int(32), 1);
f(x) = img(x) + p;

Target t = get_jit_target_from_environment();
Buffer<> in;
f.infer_input_bounds({10, 10}, t, { { img, &in } });
\endcode
* On return, in will be an allocated buffer of the correct size
* to evaulate f over a 10x10 region.
*/
// @{
void infer_input_bounds(const std::vector<int32_t> &sizes,
const Target &target = get_jit_target_from_environment(),
const ParamMap &param_map = ParamMap::empty_map());
const Target &target = get_jit_target_from_environment());
void infer_input_bounds(Pipeline::RealizationArg outputs,
const Target &target = get_jit_target_from_environment(),
const ParamMap &param_map = ParamMap::empty_map());
const Target &target = get_jit_target_from_environment());
// @}

/** Versions of infer_input_bounds that take a custom user context
* to pass to runtime functions. */
// @{
void infer_input_bounds(JITUserContext *context,
const std::vector<int32_t> &sizes,
const Target &target = get_jit_target_from_environment(),
const ParamMap &param_map = ParamMap::empty_map());
const Target &target = get_jit_target_from_environment());
void infer_input_bounds(JITUserContext *context,
Pipeline::RealizationArg outputs,
const Target &target = get_jit_target_from_environment(),
const ParamMap &param_map = ParamMap::empty_map());
const Target &target = get_jit_target_from_environment());
// @}
/** Statically compile this function to llvm bitcode, with the
* given filename (which should probably end in .bc), type
Expand Down
51 changes: 0 additions & 51 deletions src/ParamMap.cpp

This file was deleted.

Loading