A vAccel resource
vAccel resources are not exposed as concrete data structures from the vAccel runtime for the end-programmer to use. Instead, they are embedded in concrete resources, e.g. a TensorFlow model, hence this is an abstract class with common methods for all exposed methods of vAccel resources
Source code in vaccel/resource.py
| def __init__(self, session, obj, rtype):
self.path = obj
# self.filename_len = len(obj)
# self.file = self.__create_vaccel_file__()
# self.vaccel_files = self.__create_vaccel_file_table__(1)
self.session = session
self._inner = self.create_resource(rtype)
self.register = self.register_resource()
|
create_resource
Creates a resource from a file and returns a pointer to it
Parameters:
Name | Type | Description | Default |
rtype | | | required |
Returns:
Type | Description |
| A pointer to the resource |
Source code in vaccel/resource.py
| def create_resource(self, rtype):
"""Creates a resource from a file and returns a pointer to it
Args:
rtype: The resource type
Returns:
A pointer to the resource
"""
sharedobj = bytes(self.path, encoding="utf-8")
resource = ffi.new("struct vaccel_resource *")
lib.vaccel_resource_init(resource, sharedobj, rtype)
return resource
|
id abstractmethod
The id of a vAccel resource
Source code in vaccel/resource.py
| @abstractmethod
def id(self):
"""The id of a vAccel resource"""
pass
|
is_registered abstractmethod
Checks if the resource is registered with the session
Parameters:
Name | Type | Description | Default |
session | | A vaccel.Session instance | required |
Returns:
Type | Description |
| True if the resource is registered with the session |
Source code in vaccel/resource.py
| @abstractmethod
def is_registered(self, session):
"""Checks if the resource is registered with the session
Args:
session: A vaccel.Session instance
Returns:
True if the resource is registered with the session"""
pass
|