// Generated by tfcompile, the TensorFlow graph compiler. DO NOT EDIT!
|
//
|
// This header was generated via ahead-of-time compilation of a TensorFlow
|
// graph. An object file corresponding to this header was also generated.
|
// This header gives access to the functionality in that object file.
|
//
|
// clang-format off
|
|
#ifndef TFCOMPILE_GENERATED_entry_point_H_ // NOLINT(build/header_guard)
|
#define TFCOMPILE_GENERATED_entry_point_H_ // NOLINT(build/header_guard)
|
|
#include "tensorflow/compiler/xla/xla_data.pb.h"
|
|
#include "tensorflow/compiler/tf2xla/xla_compiled_cpu_function.h"
|
#include "tensorflow/core/platform/types.h"
|
|
namespace Eigen { struct ThreadPoolDevice; }
|
namespace xla { class ExecutableRunOptions; }
|
|
// (Implementation detail) Entry point to the function in the object file.
|
extern "C" void entry_point(
|
void* result, const xla::ExecutableRunOptions* run_options,
|
const void** args, void** temps, tensorflow::int64* profile_counters);
|
|
extern "C" char __tfcompile_foo_bar_MyClass_ProgramShapeProto_protobuf_array_contents[];
|
|
|
namespace foo {
|
namespace bar {
|
|
// MyClass represents a computation previously specified in a
|
// TensorFlow graph, now compiled into executable code. This extends the generic
|
// XlaCompiledCpuFunction class with statically type-safe arg and result
|
// methods. Usage example:
|
//
|
// MyClass computation;
|
// // ...set args using computation.argN methods
|
// CHECK(computation.Run());
|
// // ...inspect results using computation.resultN methods
|
//
|
// The Run method invokes the actual computation, with inputs read from arg
|
// buffers, and outputs written to result buffers. Each Run call may also use
|
// a set of temporary buffers for the computation.
|
//
|
// By default each instance of this class manages its own arg, result and temp
|
// buffers. The AllocMode constructor parameter may be used to modify the
|
// buffer allocation strategy.
|
//
|
// Under the default allocation strategy, this class is thread-compatible:
|
// o Calls to non-const methods require exclusive access to the object.
|
// o Concurrent calls to const methods are OK, if those calls are made while it
|
// is guaranteed that no thread may call a non-const method.
|
//
|
// The logical function signature is:
|
// ((unknown): f32[1,2], (unknown): s64[3,4], (unknown): f32[1], (unknown): s32[5]) -> (u32[5,6], f32[1], s32[5])
|
//
|
// Memory stats:
|
// arg bytes total: 104
|
// arg bytes aligned: 192
|
// temp bytes total: 126
|
// temp bytes aligned: 320
|
class MyClass final : public tensorflow::XlaCompiledCpuFunction {
|
public:
|
// Number of input arguments for the compiled computation.
|
static constexpr size_t kNumArgs = 2;
|
|
// Byte size of each argument buffer. There are kNumArgs entries.
|
static const ::tensorflow::int64 ArgSize(::tensorflow::int32 index) {
|
return BufferInfos()[ArgIndexToBufferIndex()[index]].size();
|
}
|
|
// Returns static data used to create an XlaCompiledCpuFunction.
|
static const tensorflow::XlaCompiledCpuFunction::StaticData& StaticData() {
|
static XlaCompiledCpuFunction::StaticData* kStaticData = [](){
|
XlaCompiledCpuFunction::StaticData* data =
|
new XlaCompiledCpuFunction::StaticData;
|
set_static_data_raw_function(data, entry_point);
|
set_static_data_buffer_infos(data, BufferInfos());
|
set_static_data_num_buffers(data, kNumBuffers);
|
set_static_data_arg_index_table(data, ArgIndexToBufferIndex());
|
set_static_data_num_args(data, kNumArgs);
|
set_static_data_result_index(data, kResultIndex);
|
set_static_data_arg_names(data, StaticArgNames());
|
set_static_data_result_names(data, StaticResultNames());
|
set_static_data_program_shape(data, StaticProgramShape());
|
set_static_data_hlo_profile_printer_data(
|
data, StaticHloProfilePrinterData());
|
|
return data;
|
}();
|
return *kStaticData;
|
}
|
|
MyClass(AllocMode alloc_mode = AllocMode::ARGS_RESULTS_PROFILES_AND_TEMPS)
|
: XlaCompiledCpuFunction(StaticData(), alloc_mode) {}
|
|
MyClass(const MyClass&) = delete;
|
MyClass& operator=(const MyClass&) = delete;
|
|
// Arg methods for managing input buffers. Buffers are in row-major order.
|
// There is a set of methods for each positional argument, with the following
|
// general form:
|
//
|
// void set_argN_data(void* data)
|
// Sets the buffer of type T for positional argument N. May be called in
|
// any AllocMode. Must be called before Run to have an affect. Must be
|
// called in AllocMode::RESULTS_PROFILES_AND_TEMPS_ONLY for each positional
|
// argument, to set the argument buffers.
|
//
|
// T* argN_data()
|
// Returns the buffer of type T for positional argument N.
|
//
|
// T& argN(...dim indices...)
|
// Returns a reference to the value of type T for positional argument N,
|
// with dim indices specifying which value. No bounds checking is performed
|
// on dim indices.
|
|
void set_arg0_data(const void* data) {
|
set_arg_data(0, data);
|
}
|
float* arg0_data() {
|
return static_cast<float*>(arg_data(0));
|
}
|
float& arg0(size_t dim0, size_t dim1) {
|
return (*static_cast<float(*)[1][2]>(
|
arg_data(0)))[dim0][dim1];
|
}
|
const float* arg0_data() const {
|
return static_cast<const float*>(arg_data(0));
|
}
|
const float& arg0(size_t dim0, size_t dim1) const {
|
return (*static_cast<const float(*)[1][2]>(
|
arg_data(0)))[dim0][dim1];
|
}
|
|
void set_arg_myfeed_data(const void* data) {
|
set_arg_data(0, data);
|
}
|
float* arg_myfeed_data() {
|
return static_cast<float*>(arg_data(0));
|
}
|
float& arg_myfeed(size_t dim0, size_t dim1) {
|
return (*static_cast<float(*)[1][2]>(
|
arg_data(0)))[dim0][dim1];
|
}
|
const float* arg_myfeed_data() const {
|
return static_cast<const float*>(arg_data(0));
|
}
|
const float& arg_myfeed(size_t dim0, size_t dim1) const {
|
return (*static_cast<const float(*)[1][2]>(
|
arg_data(0)))[dim0][dim1];
|
}
|
|
void set_arg1_data(const void* data) {
|
set_arg_data(1, data);
|
}
|
tensorflow::int64* arg1_data() {
|
return static_cast<tensorflow::int64*>(arg_data(1));
|
}
|
tensorflow::int64& arg1(size_t dim0, size_t dim1) {
|
return (*static_cast<tensorflow::int64(*)[3][4]>(
|
arg_data(1)))[dim0][dim1];
|
}
|
const tensorflow::int64* arg1_data() const {
|
return static_cast<const tensorflow::int64*>(arg_data(1));
|
}
|
const tensorflow::int64& arg1(size_t dim0, size_t dim1) const {
|
return (*static_cast<const tensorflow::int64(*)[3][4]>(
|
arg_data(1)))[dim0][dim1];
|
}
|
|
// Result methods for managing output buffers. Buffers are in row-major order.
|
// Must only be called after a successful Run call. There is a set of methods
|
// for each positional result, with the following general form:
|
//
|
// T* resultN_data()
|
// Returns the buffer of type T for positional result N.
|
//
|
// T& resultN(...dim indices...)
|
// Returns a reference to the value of type T for positional result N,
|
// with dim indices specifying which value. No bounds checking is performed
|
// on dim indices.
|
//
|
// Unlike the arg methods, there is no set_resultN_data method. The result
|
// buffers are managed internally, and may change after each call to Run.
|
|
tensorflow::uint32* result0_data() {
|
return static_cast<tensorflow::uint32*>(result_data(0));
|
}
|
tensorflow::uint32& result0(size_t dim0, size_t dim1) {
|
return (*static_cast<tensorflow::uint32(*)[5][6]>(
|
result_data(0)))[dim0][dim1];
|
}
|
const tensorflow::uint32* result0_data() const {
|
return static_cast<const tensorflow::uint32*>(result_data(0));
|
}
|
const tensorflow::uint32& result0(size_t dim0, size_t dim1) const {
|
return (*static_cast<const tensorflow::uint32(*)[5][6]>(
|
result_data(0)))[dim0][dim1];
|
}
|
|
tensorflow::uint32* result_myfetch_data() {
|
return static_cast<tensorflow::uint32*>(result_data(0));
|
}
|
tensorflow::uint32& result_myfetch(size_t dim0, size_t dim1) {
|
return (*static_cast<tensorflow::uint32(*)[5][6]>(
|
result_data(0)))[dim0][dim1];
|
}
|
const tensorflow::uint32* result_myfetch_data() const {
|
return static_cast<const tensorflow::uint32*>(result_data(0));
|
}
|
const tensorflow::uint32& result_myfetch(size_t dim0, size_t dim1) const {
|
return (*static_cast<const tensorflow::uint32(*)[5][6]>(
|
result_data(0)))[dim0][dim1];
|
}
|
|
// Methods for managing variable buffers. Buffers are in row-major order. The
|
// input and output buffers may or may not be identical.
|
//
|
// void set_var_X_data(T* data)
|
// Sets the buffer for variable X.
|
//
|
// T* var_X_data()
|
// Returns the buffer of type T for variable X.
|
//
|
// T& var_X(...dim indices...)
|
// Returns a reference to the value of type T for variable X,
|
// with dim indices specifying which value. No bounds checking is performed
|
// on dim indices.
|
|
void set_var_myvar_data(float* data) {
|
set_arg_data(2, data);
|
}
|
|
void set_var_myvar2_data(tensorflow::int32* data) {
|
set_arg_data(3, data);
|
}
|
|
float* var_myvar_data() {
|
return static_cast<float*>(result_data(1));
|
}
|
float& var_myvar() {
|
return (*static_cast<float(*)[1]>(
|
result_data(1)))[0];
|
}
|
const float* var_myvar_data() const {
|
return static_cast<const float*>(result_data(1));
|
}
|
const float& var_myvar() const {
|
return (*static_cast<const float(*)[1]>(
|
result_data(1)))[0];
|
}
|
|
tensorflow::int32* var_myvar2_data() {
|
return static_cast<tensorflow::int32*>(result_data(2));
|
}
|
tensorflow::int32& var_myvar2(size_t dim0) {
|
return (*static_cast<tensorflow::int32(*)[5]>(
|
result_data(2)))[dim0];
|
}
|
const tensorflow::int32* var_myvar2_data() const {
|
return static_cast<const tensorflow::int32*>(result_data(2));
|
}
|
const tensorflow::int32& var_myvar2(size_t dim0) const {
|
return (*static_cast<const tensorflow::int32(*)[5]>(
|
result_data(2)))[dim0];
|
}
|
|
private:
|
// Number of buffers for the compiled computation.
|
static constexpr size_t kNumBuffers = 6;
|
|
static const ::tensorflow::cpu_function_runtime::BufferInfo* BufferInfos() {
|
static const ::tensorflow::cpu_function_runtime::BufferInfo
|
kBufferInfos[kNumBuffers] = {
|
::tensorflow::cpu_function_runtime::BufferInfo({5ULL, ~0ULL}),
|
::tensorflow::cpu_function_runtime::BufferInfo({34ULL, 0ULL}),
|
::tensorflow::cpu_function_runtime::BufferInfo({9ULL, ~0ULL}),
|
::tensorflow::cpu_function_runtime::BufferInfo({386ULL, 1ULL}),
|
::tensorflow::cpu_function_runtime::BufferInfo({13ULL, ~0ULL}),
|
::tensorflow::cpu_function_runtime::BufferInfo({481ULL, ~0ULL})
|
};
|
return kBufferInfos;
|
}
|
|
static const ::tensorflow::int32* ArgIndexToBufferIndex() {
|
static constexpr ::tensorflow::int32 kArgIndexToBufferIndex[kNumArgs] = {
|
1, 3
|
};
|
return kArgIndexToBufferIndex;
|
}
|
|
// The 0-based index of the result tuple in the temporary buffers.
|
static constexpr size_t kResultIndex = 5;
|
|
// Array of names of each positional argument, terminated by nullptr.
|
static const char** StaticArgNames() {
|
static const char* kNames[] = {"myfeed", nullptr};
|
return kNames;
|
}
|
|
// Array of names of each positional result, terminated by nullptr.
|
static const char** StaticResultNames() {
|
static const char* kNames[] = {"myfetch", nullptr};
|
return kNames;
|
}
|
|
// Shape of the args and results.
|
static const xla::ProgramShapeProto* StaticProgramShape() {
|
static const xla::ProgramShapeProto* kShape = []() {
|
xla::ProgramShapeProto* proto = new xla::ProgramShapeProto;
|
proto->ParseFromArray(&__tfcompile_foo_bar_MyClass_ProgramShapeProto_protobuf_array_contents[0], 132);
|
return proto;
|
}();
|
return kShape;
|
}
|
|
// Metadata that can be used to pretty-print profile counters.
|
static const xla::HloProfilePrinterData* StaticHloProfilePrinterData() {
|
static const xla::HloProfilePrinterData* kHloProfilePrinterData =
|
nullptr;
|
return kHloProfilePrinterData;
|
}
|
};
|
|
} // end namespace bar
|
} // end namespace foo
|
|
#endif // TFCOMPILE_GENERATED_entry_point_H_
|
|
// clang-format on
|