Skip to content

Commit

Permalink
Make raw_buffer(), scalar_address(), and scalar_raw_value() methods
Browse files Browse the repository at this point in the history
protected.

Make Pipeline and Serializer protected friend classes.
  • Loading branch information
Derek Gerstmann committed Sep 8, 2023
1 parent fc2e03a commit a0053b1
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/Parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ struct BufferConstraint {
};

namespace Internal {

#ifdef WITH_SERIALIZATION
class Serializer;
#endif
struct ParameterContents;

} // namespace Internal
Expand All @@ -42,6 +44,23 @@ class Parameter {
protected:
Internal::IntrusivePtr<Internal::ParameterContents> contents;

#ifdef WITH_SERIALIZATION
friend class Internal::Serializer; //< for scalar_raw_value()
#endif
friend class Pipeline; //< for scalar_address()

/** Get the raw currently-bound buffer. null if unbound */
const halide_buffer_t *raw_buffer() const;

/** Get the pointer to the current value of the scalar
* parameter. For a given parameter, this address will never
* change. Only relevant when jitting. */
void *scalar_address() const;

/** Get the raw data of the current value of the scalar
* parameter. Only relevant when serializing. */
uint64_t scalar_raw_value() const;

public:
/** Construct a new undefined handle */
Parameter() = default;
Expand Down Expand Up @@ -119,22 +138,10 @@ class Parameter {
* bound buffer. Only relevant when jitting */
Buffer<void> buffer() const;

/** Get the raw currently-bound buffer. null if unbound */
const halide_buffer_t *raw_buffer() const;

/** If the parameter is a buffer parameter, set its current
* value. Only relevant when jitting */
void set_buffer(const Buffer<void> &b);

/** Get the pointer to the current value of the scalar
* parameter. For a given parameter, this address will never
* change. Only relevant when jitting. */
void *scalar_address() const;

/** Get the raw data of the current value of the scalar
* parameter. Only relevant when serializing. */
uint64_t scalar_raw_value() const;

/** Tests if this handle is the same as another handle */
bool same_as(const Parameter &other) const;

Expand Down

0 comments on commit a0053b1

Please sign in to comment.