목록 분류 전체보기 (281)
///"tensorflow/core/framework/op_kernel.cc" typedef std::unordered_multimap KernelRegistry; void* GlobalKernelRegistry() { static KernelRegistry* global_kernel_registry = new KernelRegistry; return global_kernel_registry; } static KernelRegistry* GlobalKernelRegistryTyped() { return reinterpret_cast(GlobalKernelRegistry()); } /// Conclusion KernelRegistry : Unordered multi_map , includes key, ke..
typedef OpKernel* (*Factory)(OpKernelConstruction*); - tensorflow source를 분석하다가 위의 typedef로 Factory가 정의되있는 것을 보고 공부하게 되었다. function pointer - 함수를 호출한다는 것은 함수가 정의된 메모리의 시작 주소로 pc를 이동시키는 것을 의미한다. 다른 상수 타입의 포인터와 마찬가지로 함수 포인터 단순히 이런 주소를 담는 변수이다. returnType (*fpName) (parmeters) - 위처럼 가리킬 함수의 리턴 타입, 파라미터와 함께 함수 포인터를 선언하고 같은 형태를 갖는 함수를 대입하여 주소를 저장하고, 이를 호출한다. void foo() { cout
///"tensorflow/core/framework/op_kernel.cc" // TODO(mrry): Convert to std::make_unique when available. OpKernel::OpKernel(OpKernelConstruction* context) : OpKernel(context, std::unique_ptr(new NodeDef(context->def()))) {} OpKernel::OpKernel(OpKernelConstruction* context, std::unique_ptr node_def) : def_(std::move(node_def)), input_types_(context->input_types().begin(), context->input_types().end..
///"tensorflow/core/framework/op_kernel.h" class OpKernelConstruction { public: OpKernelConstruction(DeviceType device_type, DeviceBase* device, Allocator* allocator, const NodeDef* node_def,const OpDef* op_def, FunctionLibraryRuntime* flib, const DataTypeSlice& input_types, const MemoryTypeSlice& input_memory_types, const DataTypeSlice& output_types, const MemoryTypeSlice& output_memory_types, ..
object factory - Design pattern to instance variety type's object. - 사용 이유 자료형에 대한 정보는 있지만, C++ 에서 표현 가능한 형태가 아닌 경우 - 파일을 읽고, 객체를 생성하는 경우 - 인터넷 패킷을 받고, 객체를 생성하는 경우 객체 생성시 의무적으로 해야할 일이 있을 경우 simple example human* human_factory(char sex) { human* h = 0; switch (sex) { case 'M': h = new Man(); break; case 2: h = new Woman(); break; } return h; }
"CODE" ///"tensorflow/core/platform/file_system.h" class FileSystemRegistry { public: typedef std::function Factory; virtual ~FileSystemRegistry(); virtual Status Register(const string& scheme, Factory factory) = 0; virtual FileSystem* Lookup(const string& scheme) = 0; virtual Status GetRegisteredFileSystemSchemes( std::vector* schemes) = 0; }; /// tensorflow/core/framework/op_kernel.h namespace..
"CODE" ///op_kernel.cc :: Kernel registration struct KernelRegistration { KernelRegistration(const KernelDef& d, StringPiece c, kernel_factory::OpKernelRegistrar::Factory f) : def(d), kernel_class_name(std::string(c)), factory(f) {} const KernelDef def; const string kernel_class_name; const kernel_factory::OpKernelRegistrar::Factory factory; }; // This maps from 'op_type' + DeviceType to the set..
"CODE" ///// tensorflow/core/kernels/training_ops.cc #define REGISTER_KERNELS(T, Tindices) \ REGISTER_KERNEL_BUILDER(Name("SparseApplyProximalAdagrad") \ .Device(DEVICE_CPU) \ .TypeConstraint("T") \ .TypeConstraint("Tindices"), \ SparseApplyProximalAdagradOp); \ REGISTER_KERNEL_BUILDER(Name("ResourceSparseApplyProximalAdagrad") \ .Device(DEVICE_CPU) \ .TypeConstraint("T") \ .TypeConstraint("Tind..
