Loading...
Searching...
No Matches
Weights.h
Go to the documentation of this file.
#ifndef _WEIGHTS
#define _WEIGHTS
#include <cstdint>
#include <iostream>
#include <string>
#include "Featurization.h"
#include "HalideBuffer.h"
#include "NetworkSize.h"
namespace Halide {
namespace Internal {
struct Weights {
uint32_t pipeline_features_version = PipelineFeatures::version();
uint32_t schedule_features_version = ScheduleFeatures::version();
Halide::Runtime::Buffer<float> head1_filter{head1_channels, head1_w, head1_h};
Halide::Runtime::Buffer<float> head1_bias{head1_channels};
Halide::Runtime::Buffer<float> head2_filter{head2_channels, head2_w};
Halide::Runtime::Buffer<float> head2_bias{head2_channels};
Halide::Runtime::Buffer<float> conv1_filter{conv1_channels, head1_channels + head2_channels};
Halide::Runtime::Buffer<float> conv1_bias{conv1_channels};
template<typename F>
void for_each_buffer(F f) {
f(head1_filter);
f(head1_bias);
f(head2_filter);
f(head2_bias);
f(conv1_filter);
f(conv1_bias);
}
void randomize(uint32_t seed);
bool load(std::istream &i);
bool save(std::ostream &o) const;
bool load_from_file(const std::string &filename);
bool save_to_file(const std::string &filename) const;
// Load/save from the 'classic' form of six raw data files
bool load_from_dir(const std::string &dir);
bool save_to_dir(const std::string &dir) const;
};
} // namespace Internal
} // namespace Halide
#endif // _WEIGHTS
HalideBuffer.h
Defines a Buffer type that wraps from halide_buffer_t and adds functionality, and methods for more co...
Featurization.h
NetworkSize.h
Halide::Internal
Definition AbstractGenerator.h:24
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition AbstractGenerator.h:19
Halide::head2_w
const int head2_w
Definition NetworkSize.h:8
Halide::head2_channels
const int head2_channels
Definition NetworkSize.h:8
Halide::head1_w
const int head1_w
Definition NetworkSize.h:7
Halide::head1_channels
const int head1_channels
Definition NetworkSize.h:7
Halide::conv1_channels
const int conv1_channels
Definition NetworkSize.h:9
Halide::head1_h
const int head1_h
Definition NetworkSize.h:7
uint32_t
unsigned __INT32_TYPE__ uint32_t
Definition runtime_internal.h:25
Halide::Internal::PipelineFeatures::version
static constexpr uint32_t version()
Definition Featurization.h:18
Halide::Internal::ScheduleFeatures::version
static constexpr uint32_t version()
Definition Featurization.h:165
Halide::Internal::Weights
Definition Weights.h:15
Halide::Internal::Weights::conv1_bias
Halide::Runtime::Buffer< float > conv1_bias
Definition Weights.h:26
Halide::Internal::Weights::conv1_filter
Halide::Runtime::Buffer< float > conv1_filter
Definition Weights.h:25
Halide::Internal::Weights::load_from_dir
bool load_from_dir(const std::string &dir)
Halide::Internal::Weights::save_to_dir
bool save_to_dir(const std::string &dir) const
Halide::Internal::Weights::for_each_buffer
void for_each_buffer(F f)
Definition Weights.h:29
Halide::Internal::Weights::schedule_features_version
uint32_t schedule_features_version
Definition Weights.h:17
Halide::Internal::Weights::randomize
void randomize(uint32_t seed)
Halide::Internal::Weights::save_to_file
bool save_to_file(const std::string &filename) const
Halide::Internal::Weights::load
bool load(std::istream &i)
Halide::Internal::Weights::pipeline_features_version
uint32_t pipeline_features_version
Definition Weights.h:16
Halide::Internal::Weights::head1_bias
Halide::Runtime::Buffer< float > head1_bias
Definition Weights.h:20
Halide::Internal::Weights::load_from_file
bool load_from_file(const std::string &filename)
Halide::Internal::Weights::head1_filter
Halide::Runtime::Buffer< float > head1_filter
Definition Weights.h:19
Halide::Internal::Weights::save
bool save(std::ostream &o) const
Halide::Internal::Weights::head2_filter
Halide::Runtime::Buffer< float > head2_filter
Definition Weights.h:22
Halide::Internal::Weights::head2_bias
Halide::Runtime::Buffer< float > head2_bias
Definition Weights.h:23