class_docstr: Test the basic error handling / validation in pymil.
class_docstr_tok: ["Test","the","basic","error","handling","\/","validation","in","pymil","."]
docstr: The builder should error out early when detecting a rank 6 (or higher) tensor which cannot be eliminated by graph passes
docstr_tok: ["The","builder","should","error","out","early","when","detecting","a","rank","6","(","or","higher",")","tensor","which","can","not","be","eliminated","by","graph","passes"]
code: def test_rank6_tensor_early_error_out():
      """
      The builder should error out early when detecting a rank 6 (or higher) tensor which cannot be eliminated by graph passes
      """
  
      @mb.program(
          input_specs=[mb.TensorSpec(shape=(1,), dtype=types.fp32)]
      )
      def prog(x):
          res = mb.reshape(
              x=x, shape=(1, 1, 1, 1, 1, 1), name="reshape_0"
          )
          return res
  
      expected_err_str = 'Core ML only supports tensors with rank <= 5. Layer "reshape_0", with type "reshape", outputs a rank 6 tensor'
      with pytest.raises(ValueError, match=expected_err_str):
          ct.convert(
              prog,
              source="milinternal",
              convert_to="neuralnetwork",
              compute_units=ct.ComputeUnit.CPU_ONLY,
          )
  
imports: import numpy
  import pytest
  import coremltools
  from coremltools import _logger
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import Function, Program, types
  from coremltools.converters.mil.mil.passes.tests.test_passes import CONSTEXPR_FUNCS
label_desc: Use image node_id 4 for calling the TestMILBasic obj's underlying member method code with example usage: obj.test_rank6_tensor_early_error_out() and returns: res