def test_load_existing_but_not_a_library(self): tmp = tempfile.NamedTemporaryFile(delete=False) for _ in range(10): tmp.write(b"0xdeadbeef\n") tmp.close() with self.assertRaises(RuntimeError): plugin_manager.load_library(tmp.name) os.remove(tmp.name)
def main(): plugin_manager.load_library('./cmake-build-debug/libCustomOp.so') pipe = TestPipeline(batch_size=8, num_threads=4, device_id=0) pipe.build() pipe_out = pipe.run() gimage, gmask = pipe_out print(gmask.as_tensor()) print(gmask.layout())
def test_pipeline_including_custom_plugin(self): plugin_manager.load_library(test_bin_dir + "/libcustomdummyplugin.so") pipe = CustomPipeline(batch_size, 1, 0) pipe.build() pipe_out = pipe.run() print(pipe_out) images, output = pipe_out output_cpu = output.asCPU() assert len(images) == batch_size assert len(output_cpu) == batch_size for i in range(len(images)): img = images.at(i) out = output_cpu.at(i) assert img.shape == out.shape np.testing.assert_array_equal(img, out)
def test_load_custom_operator_plugin(self): with self.assertRaises(AttributeError): print(ops.CustomDummy) plugin_manager.load_library(test_bin_dir + "/libcustomdummyplugin.so") print(ops.CustomDummy)
def test_load_existing_but_not_a_library(self): with self.assertRaises(RuntimeError): plugin_manager.load_library(test_bin_dir + "/dali_test.bin")
def test_load_unexisting_library(self): with self.assertRaises(RuntimeError): plugin_manager.load_library("not_a_dali_plugin.so")
def test_python_operator_and_custom_plugin(self): plugin_manager.load_library(test_bin_dir + "/libcustomdummyplugin.so") ops.readers.TFRecord(path="dummy", index_path="dummy", features={})
# subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import nvidia.dali as dali import nvidia.dali.plugin_manager as plugin_manager plugin_manager.load_library('./model_repository/libcustomcopy.so') def parse_args(): import argparse parser = argparse.ArgumentParser( description="Serialize the pipeline and save it to a file") parser.add_argument('file_path', type=str, help='The path where to save the serialized pipeline') return parser.parse_args() @dali.pipeline_def(batch_size=3, num_threads=1, device_id=0) def pipe(): data = dali.fn.external_source(device="cpu", name="DALI_INPUT_0")
types.int64) @cfunc(c_sig, nopython=True) def hello_cfunc(in_ptr, out_ptr, size): in_arr = carray(in_ptr, size) out_arr = carray(out_ptr, size) out_arr[:] = 255 #print(hello_cfunc.address) #print(hello_cfunc.inspect_llvm()) import nvidia.dali.plugin_manager as plugin_manager plugin_manager.load_library( '/home/agartner/dali-numba-plugin/libcustomdummy.so') image_dir = "/home/agartner/DALI/docs/examples/data/images" batch_size = 8 import nvidia.dali.ops as ops import nvidia.dali.types as types from nvidia.dali.pipeline import Pipeline class SimplePipeline(Pipeline): def __init__(self, batch_size, num_threads, device_id): super(SimplePipeline, self).__init__(batch_size, num_threads, device_id, seed=12) self.input = ops.FileReader(file_root=image_dir)