def test_wrong_shape_values(self): over_shape_values = [[32, 33]] try: iu.infer_shape_tensor( self, 'plan', np.float32, over_shape_values, [[8, 4, 4]], use_system_shared_memory=TEST_SYSTEM_SHARED_MEMORY, batch_size=8) # InferenceServerException will be raised from different namespace, # use dynamic type characteristic to catch both ex except Exception as ex: self.assertTrue( "The shape value at index 2 is expected to be in range from 1 to 32, Got: 33" in ex.message())
def test_wrong_shape_values(self): over_shape_values = [[32, 33]] try: iu.infer_shape_tensor( self, 'plan', 8, np.float32, over_shape_values, [[4, 4]], use_system_shared_memory=TEST_SYSTEM_SHARED_MEMORY, use_cuda_shared_memory=TEST_CUDA_SHARED_MEMORY) except InferenceServerException as ex: self.assertEqual("inference:0", ex.server_id()) self.assertTrue( "The shape value at index 2 is expected to be in range from 1 to 32, Got: 33" in ex.message())
def check_response(self, bs, thresholds, shape_values, dummy_input_shapes, shm_region_names=None, precreated_shm_regions=None, shm_suffix=""): try: # Add batch size to shape as full shape is expected for i in range(len(dummy_input_shapes)): dummy_input_shapes[i] = [ bs, ] + dummy_input_shapes[i] start_ms = int(round(time.time() * 1000)) iu.infer_shape_tensor( self, 'plan', np.float32, shape_values, dummy_input_shapes, use_grpc=False, use_streaming=False, shm_suffix=shm_suffix, use_system_shared_memory=TEST_SYSTEM_SHARED_MEMORY, use_cuda_shared_memory=TEST_CUDA_SHARED_MEMORY, batch_size=bs) end_ms = int(round(time.time() * 1000)) lt_ms = thresholds[0] gt_ms = thresholds[1] if lt_ms is not None: self.assertTrue( (end_ms - start_ms) < lt_ms, "expected less than " + str(lt_ms) + "ms response time, got " + str(end_ms - start_ms) + " ms") if gt_ms is not None: self.assertTrue( (end_ms - start_ms) > gt_ms, "expected greater than " + str(gt_ms) + "ms response time, got " + str(end_ms - start_ms) + " ms") except Exception as ex: self.add_deferred_exception(ex)
def test_nobatch(self): iu.infer_shape_tensor( self, 'plan_nobatch', np.float32, [[32, 32]], [[4, 4]], use_system_shared_memory=TEST_SYSTEM_SHARED_MEMORY) iu.infer_shape_tensor( self, 'plan_nobatch', np.float32, [[4, 4]], [[32, 32]], use_system_shared_memory=TEST_SYSTEM_SHARED_MEMORY) iu.infer_shape_tensor( self, 'plan_nobatch', np.float32, [[4, 4]], [[4, 4]], use_system_shared_memory=TEST_SYSTEM_SHARED_MEMORY)
def test_static_batch(self): iu.infer_shape_tensor( self, 'plan', np.float32, [[32, 32]], [[8, 4, 4]], use_system_shared_memory=TEST_SYSTEM_SHARED_MEMORY, batch_size=8) iu.infer_shape_tensor( self, 'plan', np.float32, [[4, 4]], [[8, 32, 32]], use_system_shared_memory=TEST_SYSTEM_SHARED_MEMORY, batch_size=8) iu.infer_shape_tensor( self, 'plan', np.float32, [[4, 4]], [[8, 4, 4]], use_system_shared_memory=TEST_SYSTEM_SHARED_MEMORY, batch_size=8)
def test_static_batch(self): iu.infer_shape_tensor( self, 'plan', 8, np.float32, [[32, 32]], [[4, 4]], use_system_shared_memory=TEST_SYSTEM_SHARED_MEMORY, use_cuda_shared_memory=TEST_CUDA_SHARED_MEMORY) iu.infer_shape_tensor( self, 'plan', 8, np.float32, [[4, 4]], [[32, 32]], use_system_shared_memory=TEST_SYSTEM_SHARED_MEMORY, use_cuda_shared_memory=TEST_CUDA_SHARED_MEMORY) iu.infer_shape_tensor( self, 'plan', 8, np.float32, [[4, 4]], [[4, 4]], use_system_shared_memory=TEST_SYSTEM_SHARED_MEMORY, use_cuda_shared_memory=TEST_CUDA_SHARED_MEMORY)