// 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_ProgramShape_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]) -> (u32[5,6]) // // Memory stats: // arg bytes total: 104 // arg bytes aligned: 192 // temp bytes total: 126 // temp bytes aligned: 320 class MyClass : 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; data->set_raw_function(entry_point); data->set_buffer_infos(BufferInfos()); data->set_num_buffers(kNumBuffers); data->set_arg_index_table(ArgIndexToBufferIndex()); data->set_num_args(kNumArgs); data->set_result_index(kResultIndex); data->set_arg_names(StaticArgNames()); data->set_result_names(StaticResultNames()); data->set_program_shape(StaticProgramShape()); data->set_hlo_profile_printer_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(void* data) { set_arg_data(0, data); } float* arg0_data() { return static_cast(arg_data(0)); } float& arg0(size_t dim0, size_t dim1) { return (*static_cast( arg_data(0)))[dim0][dim1]; } const float* arg0_data() const { return static_cast(arg_data(0)); } const float& arg0(size_t dim0, size_t dim1) const { return (*static_cast( arg_data(0)))[dim0][dim1]; } void set_arg_myfeed_data(void* data) { set_arg_data(0, data); } float* arg_myfeed_data() { return static_cast(arg_data(0)); } float& arg_myfeed(size_t dim0, size_t dim1) { return (*static_cast( arg_data(0)))[dim0][dim1]; } const float* arg_myfeed_data() const { return static_cast(arg_data(0)); } const float& arg_myfeed(size_t dim0, size_t dim1) const { return (*static_cast( arg_data(0)))[dim0][dim1]; } void set_arg1_data(void* data) { set_arg_data(1, data); } tensorflow::int64* arg1_data() { return static_cast(arg_data(1)); } tensorflow::int64& arg1(size_t dim0, size_t dim1) { return (*static_cast( arg_data(1)))[dim0][dim1]; } const tensorflow::int64* arg1_data() const { return static_cast(arg_data(1)); } const tensorflow::int64& arg1(size_t dim0, size_t dim1) const { return (*static_cast( 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(result_data(0)); } tensorflow::uint32& result0(size_t dim0, size_t dim1) { return (*static_cast( result_data(0)))[dim0][dim1]; } const tensorflow::uint32* result0_data() const { return static_cast(result_data(0)); } const tensorflow::uint32& result0(size_t dim0, size_t dim1) const { return (*static_cast( result_data(0)))[dim0][dim1]; } tensorflow::uint32* result_myfetch_data() { return static_cast(result_data(0)); } tensorflow::uint32& result_myfetch(size_t dim0, size_t dim1) { return (*static_cast( result_data(0)))[dim0][dim1]; } const tensorflow::uint32* result_myfetch_data() const { return static_cast(result_data(0)); } const tensorflow::uint32& result_myfetch(size_t dim0, size_t dim1) const { return (*static_cast( result_data(0)))[dim0][dim1]; } 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::ProgramShape* StaticProgramShape() { static const xla::ProgramShape* kShape = []() { xla::ProgramShape* proto = new xla::ProgramShape; proto->ParseFromArray(&__tfcompile_foo_bar_MyClass_ProgramShape_protobuf_array_contents[0], 52); 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