@Test public void buildModelIfBackendNotFound() throws Exception { final String path = getResourceFilePath("models/and_op.onnx"); final int batchSize = 4; final int inputDim = 2; final String backendName = "__non_existent_backend__"; final String backendConfig = ""; try ( ModelData modelData = ModelData.fromOnnxFile(path); VariableProfileTableBuilder vptBuilder = VariableProfileTable.builder() .addInputProfile("input", DType.FLOAT, new int[] {batchSize, inputDim}) .addOutputProfile("output", DType.FLOAT); VariableProfileTable vpt = vptBuilder.build(modelData); ModelBuilder modelBuilder = Model.builder(vpt) ) { modelBuilder.attachExternalBuffer("input", new float[] {0f, 0f, 0f, 1f, 1f, 0f, 1f, 1f}); MenohException e = assertThrows( MenohException.class, () -> modelBuilder.build(modelData, backendName, backendConfig)); assertAll("backendName is invalid", () -> assertEquals(ErrorCode.INVALID_BACKEND_NAME, e.getErrorCode()), () -> assertEquals( String.format("menoh invalid backend name error: %s (invalid_backend_name)", backendName), e.getMessage()) ); } }
public static ModelBuilder builder(VariableProfileTable vpt) throws MenohException { final PointerByReference ref = new PointerByReference(); checkError(MenohNative.INSTANCE.menoh_make_model_builder(vpt.nativeHandle(), ref)); return new ModelBuilder(ref.getValue()); }
Model implements AutoCloseable { public static ModelBuilder builder(VariableProfileTable vpt) throws MenohException { final PointerByReference ref = new PointerByReference(); checkError(MenohNative.INSTANCE.menoh_make_model_builder(vpt.nativeHandle(), ref)); return new ModelBuilder(ref.getValue()); } }
Model implements AutoCloseable { public static ModelBuilder builder(VariableProfileTable vpt) throws MenohException { final PointerByReference ref = new PointerByReference(); checkError(MenohNative.INSTANCE.menoh_make_model_builder(vpt.nativeHandle(), ref)); return new ModelBuilder(ref.getValue()); } Model(Pointer handle, List<Pointer> externalBuffers); }
Model implements AutoCloseable { public static ModelBuilder builder(VariableProfileTable vpt) throws MenohException { final PointerByReference ref = new PointerByReference(); checkError(MenohNative.INSTANCE.menoh_make_model_builder(vpt.nativeHandle(), ref)); return new ModelBuilder(ref.getValue()); } Model(Pointer handle, List<Pointer> externalBuffers); @Override void close(); static ModelBuilder builder(VariableProfileTable vpt); Variable variable(String variableName); void run(); }
Model implements AutoCloseable { public static ModelBuilder builder(VariableProfileTable vpt) throws MenohException { final PointerByReference ref = new PointerByReference(); checkError(MenohNative.INSTANCE.menoh_make_model_builder(vpt.nativeHandle(), ref)); return new ModelBuilder(ref.getValue()); } Model(Pointer handle, List<Pointer> externalBuffers); @Override void close(); static ModelBuilder builder(VariableProfileTable vpt); Variable variable(String variableName); void run();  }