Class: TensorStream::OpenCLUtil
- Inherits:
-
Object
- Object
- TensorStream::OpenCLUtil
- Defined in:
- lib/tensor_stream/opencl/utils.rb
Instance Method Summary collapse
-
#get_memory_usage ⇒ Object
Retrieves OpenCL memory usage.
-
#initialize(session) ⇒ OpenCLUtil
constructor
initializes a OpenCL helper class based on a session.
Constructor Details
#initialize(session) ⇒ OpenCLUtil
initializes a OpenCL helper class based on a session
5 6 7 |
# File 'lib/tensor_stream/opencl/utils.rb', line 5 def initialize(session) @session = session end |
Instance Method Details
#get_memory_usage ⇒ Object
Retrieves OpenCL memory usage
11 12 13 14 15 16 |
# File 'lib/tensor_stream/opencl/utils.rb', line 11 def get_memory_usage cl_buffer_uniq_set = Set.new @session.last_session_context[:_cache][:_cl_buffers].inject(0) do |sum, elem| cl_buffer_uniq_set.add?(elem[1].cl_buffer.object_id) ? sum + elem[1].cl_buffer.size : sum end end |