Repository: ignite Updated Branches: refs/heads/master 0772a96f3 -> 9dccb3db5
http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SparseDistributedVectorTest.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SparseDistributedVectorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SparseDistributedVectorTest.java deleted file mode 100644 index b5c348f..0000000 --- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SparseDistributedVectorTest.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.ml.math.impls.vector; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import org.apache.ignite.Ignite; -import org.apache.ignite.internal.util.IgniteUtils; -import org.apache.ignite.ml.math.StorageConstants; -import org.apache.ignite.ml.math.Vector; -import org.apache.ignite.ml.math.impls.MathTestConstants; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.apache.ignite.testframework.junits.common.GridCommonTest; - -import static org.apache.ignite.ml.math.impls.MathTestConstants.UNEXPECTED_VAL; - -/** - * Tests for {@link SparseDistributedVector}. - */ -@GridCommonTest(group = "Distributed Models") -public class SparseDistributedVectorTest extends GridCommonAbstractTest { - /** Number of nodes in grid */ - private static final int NODE_COUNT = 3; - - /** Precision. */ - private static final double PRECISION = 0.0; - - /** Grid instance. */ - private Ignite ignite; - - /** Vector size */ - private final int size = MathTestConstants.STORAGE_SIZE; - - /** Vector for tests */ - private SparseDistributedVector sparseDistributedVector; - - /** - * Default constructor. - */ - public SparseDistributedVectorTest() { - super(false); - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - for (int i = 1; i <= NODE_COUNT; i++) - startGrid(i); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopAllGrids(); - } - - /** - * {@inheritDoc} - */ - @Override protected void beforeTest() throws Exception { - ignite = grid(NODE_COUNT); - - ignite.configuration().setPeerClassLoadingEnabled(true); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - if (sparseDistributedVector != null) { - sparseDistributedVector.destroy(); - sparseDistributedVector = null; - } - } - - /** */ - public void testGetSet() throws Exception { - IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName()); - - sparseDistributedVector = new SparseDistributedVector(size, StorageConstants.RANDOM_ACCESS_MODE); - - for (int i = 0; i < size; i++) { - double v = Math.random(); - sparseDistributedVector.set(i, v); - assertEquals("Unexpected value for vector element[" + i + "]", v, sparseDistributedVector.get(i), PRECISION); - } - } - - /** */ - public void testExternalize() throws IOException, ClassNotFoundException { - IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName()); - - sparseDistributedVector = new SparseDistributedVector(size, StorageConstants.RANDOM_ACCESS_MODE); - - sparseDistributedVector.set(1, 1.0); - - ByteArrayOutputStream byteArrOutputStream = new ByteArrayOutputStream(); - ObjectOutputStream objOutputStream = new ObjectOutputStream(byteArrOutputStream); - - objOutputStream.writeObject(sparseDistributedVector); - - ByteArrayInputStream byteArrInputStream = new ByteArrayInputStream(byteArrOutputStream.toByteArray()); - ObjectInputStream objInputStream = new ObjectInputStream(byteArrInputStream); - - SparseDistributedVector objRestored = (SparseDistributedVector)objInputStream.readObject(); - - assertTrue(MathTestConstants.VAL_NOT_EQUALS, sparseDistributedVector.equals(objRestored)); - assertEquals(MathTestConstants.VAL_NOT_EQUALS, objRestored.get(1), 1.0, PRECISION); - } - - /** Test simple math. */ - public void testMath() { - IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName()); - - sparseDistributedVector = new SparseDistributedVector(size, StorageConstants.RANDOM_ACCESS_MODE); - initVector(sparseDistributedVector); - - sparseDistributedVector.assign(2.0); - for (int i = 0; i < sparseDistributedVector.size(); i++) - assertEquals(UNEXPECTED_VAL, 2.0, sparseDistributedVector.get(i), PRECISION); - - sparseDistributedVector.plus(3.0); - for (int i = 0; i < sparseDistributedVector.size(); i++) - assertEquals(UNEXPECTED_VAL, 5.0, sparseDistributedVector.get(i), PRECISION); - - sparseDistributedVector.times(2.0); - for (int i = 0; i < sparseDistributedVector.size(); i++) - assertEquals(UNEXPECTED_VAL, 10.0, sparseDistributedVector.get(i), PRECISION); - - sparseDistributedVector.divide(10.0); - for (int i = 0; i < sparseDistributedVector.size(); i++) - assertEquals(UNEXPECTED_VAL, 1.0, sparseDistributedVector.get(i), PRECISION); - - // assertEquals(UNEXPECTED_VAL, sparseDistributedVector.rowSize() * sparseDistributedVector.columnSize(), sparseDistributedVector.sum(), PRECISION); - } - - /** */ - public void testMap() { - IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName()); - - sparseDistributedVector = new SparseDistributedVector(size, StorageConstants.RANDOM_ACCESS_MODE); - initVector(sparseDistributedVector); - - sparseDistributedVector.map(i -> 100.0); - for (int i = 0; i < sparseDistributedVector.size(); i++) - assertEquals(UNEXPECTED_VAL, 100.0, sparseDistributedVector.get(i), PRECISION); - } - - /** */ - public void testCopy() { - IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName()); - - sparseDistributedVector = new SparseDistributedVector(size, StorageConstants.RANDOM_ACCESS_MODE); - - Vector cp = sparseDistributedVector.copy(); - - assertNotNull(cp); - - for (int i = 0; i < size; i++) - assertEquals(UNEXPECTED_VAL, cp.get(i), sparseDistributedVector.get(i), PRECISION); - } - - /** */ - public void testLike() { - IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName()); - - sparseDistributedVector = new SparseDistributedVector(size, StorageConstants.RANDOM_ACCESS_MODE); - - assertNotNull(sparseDistributedVector.like(1)); - } - - /** */ - private void initVector(Vector v) { - for (int i = 0; i < v.size(); i++) - v.set(i, 1.0); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorAttributesTest.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorAttributesTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorAttributesTest.java index 52232ca..60d8d43 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorAttributesTest.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorAttributesTest.java @@ -32,17 +32,14 @@ public class VectorAttributesTest { /** */ private final List<AttrCfg> attrCfgs = Arrays.asList( new AttrCfg("isDense", Vector::isDense, - DenseLocalOnHeapVector.class, DenseLocalOffHeapVector.class, RandomVector.class, ConstantVector.class, - SingleElementVector.class), + DenseLocalOnHeapVector.class, DenseLocalOffHeapVector.class), new AttrCfg("isArrayBased", Vector::isArrayBased, DenseLocalOnHeapVector.class), new AttrCfg("isSequentialAccess", Vector::isSequentialAccess, - DenseLocalOnHeapVector.class, DenseLocalOffHeapVector.class, SparseLocalVectorSequentialAccess.class, - RandomVector.class, ConstantVector.class, SingleElementVector.class), + DenseLocalOnHeapVector.class, DenseLocalOffHeapVector.class, SparseLocalVectorSequentialAccess.class), new AttrCfg("guidNotNull", v -> v.guid() == null), // IMPL NOTE this is somewhat artificial new AttrCfg("isRandomAccess", Vector::isRandomAccess, - DenseLocalOnHeapVector.class, DenseLocalOffHeapVector.class, RandomVector.class, ConstantVector.class, - SingleElementVector.class, SparseLocalVectorSequentialAccess.class, SparseLocalVectorRandomAccess.class), + DenseLocalOnHeapVector.class, DenseLocalOffHeapVector.class, SparseLocalVectorSequentialAccess.class, SparseLocalVectorRandomAccess.class), new AttrCfg("isDistributed", Vector::isDistributed)); /** */ @@ -57,22 +54,6 @@ public class VectorAttributesTest { "isRandomAccess", "isDistributed"), new Specification(new SparseLocalVectorSequentialAccess(1)), new Specification(new SparseLocalVectorRandomAccess(1)), - new Specification(new RandomVector(1)), - new Specification(new ConstantVector(1, 1.0)), - new Specification(new FunctionVector(1, idx -> (double)idx)), - new Specification(new SingleElementVector(1, 0, 1.0)), - new Specification(new PivotedVectorView(new DenseLocalOnHeapVector(1), new int[] {0}), - DenseLocalOnHeapVector.class, "isDense", "isArrayBased", "isSequentialAccess", - "isRandomAccess", "isDistributed"), - new Specification(new PivotedVectorView(new DenseLocalOffHeapVector(1), new int[] {0}), - DenseLocalOffHeapVector.class, "isDense", "isArrayBased", "isSequentialAccess", - "isRandomAccess", "isDistributed"), - new Specification(new SingleElementVectorView(new DenseLocalOnHeapVector(1), 0), - DenseLocalOnHeapVector.class, "isDense", "isSequentialAccess", - "isRandomAccess", "isDistributed"), - new Specification(new SingleElementVectorView(new DenseLocalOffHeapVector(1), 0), - DenseLocalOffHeapVector.class, "isDense", "isSequentialAccess", - "isRandomAccess", "isDistributed"), new Specification(new MatrixVectorView(new DenseLocalOnHeapMatrix(1, 1), 0, 0, 1, 1), DenseLocalOnHeapVector.class, "isDense", "isRandomAccess", "isDistributed"), // TODO: IGNTIE-5723, find out why "isSequentialAccess" fails here http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsFixtures.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsFixtures.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsFixtures.java index be3bb22..91200db 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsFixtures.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsFixtures.java @@ -17,9 +17,6 @@ package org.apache.ignite.ml.math.impls.vector; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; @@ -36,7 +33,6 @@ import org.apache.ignite.ml.math.Matrix; import org.apache.ignite.ml.math.StorageConstants; import org.apache.ignite.ml.math.Vector; import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix; -import org.apache.ignite.ml.math.impls.storage.vector.FunctionVectorStorage; import org.jetbrains.annotations.NotNull; import static org.junit.Assert.assertEquals; @@ -49,13 +45,7 @@ class VectorImplementationsFixtures { (Supplier<Iterable<Vector>>)DenseLocalOnHeapVectorFixture::new, (Supplier<Iterable<Vector>>)DenseLocalOffHeapVectorFixture::new, (Supplier<Iterable<Vector>>)SparseLocalVectorFixture::new, - (Supplier<Iterable<Vector>>)RandomVectorFixture::new, - (Supplier<Iterable<Vector>>)ConstantVectorFixture::new, (Supplier<Iterable<Vector>>)DelegatingVectorFixture::new, - (Supplier<Iterable<Vector>>)FunctionVectorFixture::new, - (Supplier<Iterable<Vector>>)SingleElementVectorFixture::new, - (Supplier<Iterable<Vector>>)PivotedVectorViewFixture::new, - (Supplier<Iterable<Vector>>)SingleElementVectorViewFixture::new, (Supplier<Iterable<Vector>>)MatrixVectorViewFixture::new, (Supplier<Iterable<Vector>>)SparseLocalOffHeapVectorFixture::new ); @@ -110,134 +100,7 @@ class VectorImplementationsFixtures { } } - /** */ - private static class RandomVectorFixture extends VectorSizesFixture { - /** */ - RandomVectorFixture() { - super("RandomVector", RandomVector::new); - } - } - - /** */ - private static class ConstantVectorFixture extends VectorSizesExtraFixture<Double> { - /** */ - ConstantVectorFixture() { - super("ConstantVector", ConstantVector::new, - "value", new Double[] {-1.0, 0.0, 0.5, 1.0, 2.0, null}); - } - } - /** */ - private static class FunctionVectorFixture extends VectorSizesExtraFixture<Double> { - /** */ - FunctionVectorFixture() { - super("FunctionVector", - (size, scale) -> new FunctionVectorForTest(new double[size], scale), - "scale", new Double[] {0.5, 1.0, 2.0, null}); - } - } - - /** */ - private static class SingleElementVectorFixture implements Iterable<Vector> { - /** */ - private final Supplier<TwoParamsIterator<Integer, Double>> iter; - - /** */ - private final AtomicReference<String> ctxDescrHolder = new AtomicReference<>("Iterator not started."); - - /** */ - SingleElementVectorFixture() { - iter = () -> new TwoParamsIterator<Integer, Double>("SingleElementVector", - null, ctxDescrHolder::set, - "size", new Integer[] {1, null}, - "value", new Double[] {-1.0, 0.0, 0.5, 1.0, 2.0, null}) { - - /** {@inheritDoc} */ - @Override BiFunction<Integer, Double, Vector> ctor() { - return (size, value) -> new SingleElementVector(size, 0, value); - } - }; - } - - /** {@inheritDoc} */ - @NotNull - @Override public Iterator<Vector> iterator() { - return iter.get();//( - } - - /** {@inheritDoc} */ - @Override public String toString() { - // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class - return ctxDescrHolder.get(); - } - } - - /** */ - private static class PivotedVectorViewFixture extends VectorSizesFixture { - /** */ - PivotedVectorViewFixture() { - super("PivotedVectorView", PivotedVectorViewFixture::pivotedVectorView); - } - - /** */ - private static PivotedVectorView pivotedVectorView(int size) { - final DenseLocalOnHeapVector vec = new DenseLocalOnHeapVector(size); - - final int[] pivot = new int[size]; - - for (int idx = 0; idx < size; idx++) - pivot[idx] = size - 1 - idx; - - PivotedVectorView tmp = new PivotedVectorView(vec, pivot); - - final int[] unpivot = new int[size]; - - for (int idx = 0; idx < size; idx++) - unpivot[idx] = tmp.unpivot(idx); - - final int[] idxRecovery = new int[size]; - - for (int idx = 0; idx < size; idx++) - idxRecovery[idx] = idx; - - return new PivotedVectorView(new PivotedVectorView(tmp, unpivot), idxRecovery); - } - } - - /** */ - private static class SingleElementVectorViewFixture implements Iterable<Vector> { - /** */ - private final Supplier<TwoParamsIterator<Integer, Double>> iter; - - /** */ - private final AtomicReference<String> ctxDescrHolder = new AtomicReference<>("Iterator not started."); - - /** */ - SingleElementVectorViewFixture() { - iter = () -> new TwoParamsIterator<Integer, Double>("SingleElementVectorView", - null, ctxDescrHolder::set, - "size", new Integer[] {1, null}, - "value", new Double[] {-1.0, 0.0, 0.5, 1.0, 2.0, null}) { - - /** {@inheritDoc} */ - @Override BiFunction<Integer, Double, Vector> ctor() { - return (size, value) -> new SingleElementVectorView(new SingleElementVector(size, 0, value), 0); - } - }; - } - - /** {@inheritDoc} */ - @NotNull - @Override public Iterator<Vector> iterator() { - return iter.get(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class - return ctxDescrHolder.get(); - } - } /** */ private static class MatrixVectorViewFixture extends VectorSizesExtraFixture<Integer> { @@ -577,72 +440,6 @@ class VectorImplementationsFixtures { } } - /** Subclass tweaked for serialization */ - private static class FunctionVectorForTest extends FunctionVector { - /** */ - double[] arr; - - /** */ - double scale; - - /** */ - public FunctionVectorForTest() { - // No-op. - } - - /** */ - FunctionVectorForTest(double[] arr, double scale) { - super(arr.length, idx -> arr[idx] * scale, (idx, value) -> arr[idx] = value / scale); - - this.arr = arr; - - this.scale = scale; - } - - /** {@inheritDoc} */ - @Override public void writeExternal(ObjectOutput out) throws IOException { - super.writeExternal(out); - - out.writeObject(arr); - - out.writeDouble(scale); - } - - /** {@inheritDoc} */ - @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - super.readExternal(in); - - arr = (double[])in.readObject(); - - scale = in.readDouble(); - - setStorage(new FunctionVectorStorage(arr.length, idx -> arr[idx] * scale, (idx, value) -> arr[idx] = value / scale)); - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - int res = 1; - - res = res * 37 + Double.hashCode(scale); - res = res * 37 + Integer.hashCode(getStorage().size()); - - return res; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (o == null || getClass() != o.getClass()) - return false; - - FunctionVectorForTest that = (FunctionVectorForTest)o; - - return new Double(scale).equals(that.scale) - && (arr != null ? Arrays.equals(arr, that.arr) : that.arr == null); - } - } /** */ private static class SparseLocalOffHeapVectorFixture extends VectorSizesFixture { http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsTest.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsTest.java index 8075b29..da67a05 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsTest.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsTest.java @@ -304,7 +304,7 @@ public class VectorImplementationsTest { // TODO: IGNTIE-5723, split this to sma @Test public void sortTest() { consumeSampleVectors((v, desc) -> { - if (readOnly(v) || !v.isArrayBased()) { + if (readOnly() || !v.isArrayBased()) { boolean expECaught = false; try { @@ -350,7 +350,7 @@ public class VectorImplementationsTest { // TODO: IGNTIE-5723, split this to sma @Test public void assignDoubleTest() { consumeSampleVectors((v, desc) -> { - if (readOnly(v)) + if (readOnly()) return; for (double val : new double[] {0, -1, 0, 1}) { @@ -370,7 +370,7 @@ public class VectorImplementationsTest { // TODO: IGNTIE-5723, split this to sma @Test public void assignDoubleArrTest() { consumeSampleVectors((v, desc) -> { - if (readOnly(v)) + if (readOnly()) return; final int size = v.size(); @@ -393,7 +393,7 @@ public class VectorImplementationsTest { // TODO: IGNTIE-5723, split this to sma @Test public void assignVectorTest() { consumeSampleVectors((v, desc) -> { - if (readOnly(v)) + if (readOnly()) return; final int size = v.size(); @@ -416,7 +416,7 @@ public class VectorImplementationsTest { // TODO: IGNTIE-5723, split this to sma @Test public void assignFunctionTest() { consumeSampleVectors((v, desc) -> { - if (readOnly(v)) + if (readOnly()) return; final int size = v.size(); @@ -502,13 +502,12 @@ public class VectorImplementationsTest { // TODO: IGNTIE-5723, split this to sma /** */ private boolean getXOutOfBoundsOK(Vector v) { // TODO: IGNTIE-5723, find out if this is indeed OK - return v instanceof RandomVector || v instanceof ConstantVector - || v instanceof SingleElementVector || v instanceof SingleElementVectorView; + return false; } /** */ private void mutateAtIdxTest(Vector v, String desc, MutateAtIdx operation) { - if (readOnly(v)) { + if (readOnly()) { if (v.size() < 1) return; @@ -541,9 +540,6 @@ public class VectorImplementationsTest { // TODO: IGNTIE-5723, split this to sma private Class<? extends Vector> expLikeType(Vector v) { Class<? extends Vector> clazz = v.getClass(); - if (clazz.isAssignableFrom(PivotedVectorView.class) || clazz.isAssignableFrom(SingleElementVectorView.class)) - return null; - if (clazz.isAssignableFrom(MatrixVectorView.class) || clazz.isAssignableFrom(DelegatingVector.class)) return DenseLocalOnHeapVector.class; // IMPL NOTE per fixture @@ -698,8 +694,8 @@ public class VectorImplementationsTest { // TODO: IGNTIE-5723, split this to sma } /** */ - private static boolean readOnly(Vector v) { - return v instanceof RandomVector || v instanceof ConstantVector; + private static boolean readOnly() { + return false; } /** */ @@ -725,7 +721,7 @@ public class VectorImplementationsTest { // TODO: IGNTIE-5723, split this to sma this.nonNegative = nonNegative; - refReadOnly = readOnly(v) && ref == null ? new double[v.size()] : null; + refReadOnly = readOnly() && ref == null ? new double[v.size()] : null; init(v, ref); } @@ -765,7 +761,7 @@ public class VectorImplementationsTest { // TODO: IGNTIE-5723, split this to sma /** */ void assertNewMinElement(Vector v) { - if (readOnly(v)) + if (readOnly()) return; int exp = v.size() / 2; @@ -777,7 +773,7 @@ public class VectorImplementationsTest { // TODO: IGNTIE-5723, split this to sma /** */ void assertNewMaxElement(Vector v) { - if (readOnly(v)) + if (readOnly()) return; int exp = v.size() / 2; @@ -789,7 +785,7 @@ public class VectorImplementationsTest { // TODO: IGNTIE-5723, split this to sma /** */ private void init(Vector v, double[] ref) { - if (readOnly(v)) { + if (readOnly()) { initReadonly(v, ref); return; http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorIterableTest.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorIterableTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorIterableTest.java deleted file mode 100644 index 6400c80..0000000 --- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorIterableTest.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.ml.math.impls.vector; - -import java.util.Arrays; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.Spliterator; -import java.util.function.BiConsumer; -import org.apache.ignite.ml.math.Vector; -import org.apache.ignite.ml.math.impls.MathTestConstants; -import org.junit.Test; - -import static java.util.Spliterator.ORDERED; -import static java.util.Spliterator.SIZED; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** */ -public class VectorIterableTest { - /** */ - @Test - public void allTest() { - consumeSampleVectors( - (v, desc) -> { - int expIdx = 0; - - for (Vector.Element e : v.all()) { - int actualIdx = e.index(); - - assertEquals("Unexpected index for " + desc, - expIdx, actualIdx); - - expIdx++; - } - - assertEquals("Unexpected amount of elements for " + desc, - expIdx, v.size()); - } - ); - } - - /** */ - @Test - public void allTestBound() { - consumeSampleVectors( - (v, desc) -> iteratorTestBound(v.all().iterator(), desc) - ); - } - - /** */ - @Test - public void nonZeroesTestBasic() { - final int size = 5; - - final double[] nonZeroesOddData = new double[size], nonZeroesEvenData = new double[size]; - - for (int idx = 0; idx < size; idx++) { - final boolean odd = (idx & 1) == 1; - - nonZeroesOddData[idx] = odd ? 1 : 0; - - nonZeroesEvenData[idx] = odd ? 0 : 1; - } - - assertTrue("Arrays failed to initialize.", - !isZero(nonZeroesEvenData[0]) - && isZero(nonZeroesEvenData[1]) - && isZero(nonZeroesOddData[0]) - && !isZero(nonZeroesOddData[1])); - - final Vector nonZeroesEvenVec = new DenseLocalOnHeapVector(nonZeroesEvenData), - nonZeroesOddVec = new DenseLocalOnHeapVector(nonZeroesOddData); - - assertTrue("Vectors failed to initialize.", - !isZero(nonZeroesEvenVec.getElement(0).get()) - && isZero(nonZeroesEvenVec.getElement(1).get()) - && isZero(nonZeroesOddVec.getElement(0).get()) - && !isZero(nonZeroesOddVec.getElement(1).get())); - - assertTrue("Iterator(s) failed to start.", - nonZeroesEvenVec.nonZeroes().iterator().next() != null - && nonZeroesOddVec.nonZeroes().iterator().next() != null); - - int nonZeroesActual = 0; - - for (Vector.Element e : nonZeroesEvenVec.nonZeroes()) { - final int idx = e.index(); - - final boolean odd = (idx & 1) == 1; - - final double val = e.get(); - - assertTrue("Not an even index " + idx + ", for value " + val, !odd); - - assertTrue("Zero value " + val + " at even index " + idx, !isZero(val)); - - nonZeroesActual++; - } - - final int nonZeroesOddExp = (size + 1) / 2; - - assertEquals("Unexpected num of iterated odd non-zeroes.", nonZeroesOddExp, nonZeroesActual); - - assertEquals("Unexpected nonZeroElements of odd.", nonZeroesOddExp, nonZeroesEvenVec.nonZeroElements()); - - nonZeroesActual = 0; - - for (Vector.Element e : nonZeroesOddVec.nonZeroes()) { - final int idx = e.index(); - - final boolean odd = (idx & 1) == 1; - - final double val = e.get(); - - assertTrue("Not an odd index " + idx + ", for value " + val, odd); - - assertTrue("Zero value " + val + " at even index " + idx, !isZero(val)); - - nonZeroesActual++; - } - - final int nonZeroesEvenExp = size / 2; - - assertEquals("Unexpected num of iterated even non-zeroes", nonZeroesEvenExp, nonZeroesActual); - - assertEquals("Unexpected nonZeroElements of even", nonZeroesEvenExp, nonZeroesOddVec.nonZeroElements()); - } - - /** */ - @Test - public void nonZeroesTest() { - // TODO: IGNTIE-5723, make RandomVector constructor that accepts a function and use it here. - // in order to *reliably* test non-zeroes in there - consumeSampleVectors( - (v, desc) -> consumeSampleVectorsWithZeroes(v, (vec, numZeroes) - -> { - int numZeroesActual = vec.size(); - - for (Vector.Element e : vec.nonZeroes()) { - numZeroesActual--; - - assertTrue("Unexpected zero at " + desc + ", index " + e.index(), !isZero(e.get())); - } - - assertEquals("Unexpected num zeroes at " + desc, (int)numZeroes, numZeroesActual); - })); - } - - /** */ - @Test - public void nonZeroesTestBound() { - consumeSampleVectors( - (v, desc) -> consumeSampleVectorsWithZeroes(v, (vec, numZeroes) - -> iteratorTestBound(vec.nonZeroes().iterator(), desc))); - } - - /** */ - @Test - public void nonZeroElementsTest() { - consumeSampleVectors( - (v, desc) -> consumeSampleVectorsWithZeroes(v, (vec, numZeroes) - -> assertEquals("Unexpected num zeroes at " + desc, - (int)numZeroes, vec.size() - vec.nonZeroElements()))); - } - - /** */ - @Test - public void allSpliteratorTest() { - consumeSampleVectors( - (v, desc) -> { - final String desc1 = " " + desc; - - Spliterator<Double> spliterator = v.allSpliterator(); - - assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator); - - assertNull(MathTestConstants.NOT_NULL_VAL + desc1, spliterator.trySplit()); - - assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED)); - - if (!readOnly(v)) - fillWithNonZeroes(v); - - spliterator = v.allSpliterator(); - - assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator); - - assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.estimateSize(), v.size()); - - assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.getExactSizeIfKnown(), v.size()); - - assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED)); - - Spliterator<Double> secondHalf = spliterator.trySplit(); - - assertNull(MathTestConstants.NOT_NULL_VAL + desc1, secondHalf); - - spliterator.tryAdvance(x -> { - }); - } - ); - } - - /** */ - @Test - public void nonZeroSpliteratorTest() { - consumeSampleVectors( - (v, desc) -> consumeSampleVectorsWithZeroes(v, (vec, numZeroes) - -> { - final String desc1 = " Num zeroes " + numZeroes + " " + desc; - - Spliterator<Double> spliterator = vec.nonZeroSpliterator(); - - assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator); - - assertNull(MathTestConstants.NOT_NULL_VAL + desc1, spliterator.trySplit()); - - assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED)); - - spliterator = vec.nonZeroSpliterator(); - - assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator); - - assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.estimateSize(), vec.size() - numZeroes); - - assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.getExactSizeIfKnown(), vec.size() - numZeroes); - - assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED)); - - Spliterator<Double> secondHalf = spliterator.trySplit(); - - assertNull(MathTestConstants.NOT_NULL_VAL + desc1, secondHalf); - - double[] data = new double[vec.size()]; - - for (Vector.Element e : vec.all()) - data[e.index()] = e.get(); - - spliterator = vec.nonZeroSpliterator(); - - assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator); - - assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.estimateSize(), - Arrays.stream(data).filter(x -> x != 0d).count()); - - assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.getExactSizeIfKnown(), - Arrays.stream(data).filter(x -> x != 0d).count()); - - assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED)); - - secondHalf = spliterator.trySplit(); - - assertNull(MathTestConstants.NOT_NULL_VAL + desc1, secondHalf); - - if (!spliterator.tryAdvance(x -> { - })) - fail(MathTestConstants.NO_NEXT_ELEMENT + desc1); - })); - } - - /** */ - private void iteratorTestBound(Iterator<Vector.Element> it, String desc) { - while (it.hasNext()) - assertNotNull(it.next()); - - boolean expECaught = false; - - try { - it.next(); - } - catch (NoSuchElementException e) { - expECaught = true; - } - - assertTrue("Expected exception missed for " + desc, - expECaught); - } - - /** */ - private void consumeSampleVectorsWithZeroes(Vector sample, - BiConsumer<Vector, Integer> consumer) { - if (readOnly(sample)) { - int numZeroes = 0; - - for (Vector.Element e : sample.all()) - if (isZero(e.get())) - numZeroes++; - - consumer.accept(sample, numZeroes); - - return; - } - - fillWithNonZeroes(sample); - - consumer.accept(sample, 0); - - final int sampleSize = sample.size(); - - if (sampleSize == 0) - return; - - for (Vector.Element e : sample.all()) - e.set(0); - - consumer.accept(sample, sampleSize); - - fillWithNonZeroes(sample); - - for (int testIdx : new int[] {0, sampleSize / 2, sampleSize - 1}) { - final Vector.Element e = sample.getElement(testIdx); - - final double backup = e.get(); - - e.set(0); - - consumer.accept(sample, 1); - - e.set(backup); - } - - if (sampleSize < 3) - return; - - sample.getElement(sampleSize / 3).set(0); - - sample.getElement((2 * sampleSize) / 3).set(0); - - consumer.accept(sample, 2); - } - - /** */ - private void fillWithNonZeroes(Vector sample) { - int idx = 0; - - for (Vector.Element e : sample.all()) - e.set(1 + idx++); - - assertEquals("Not all filled with non-zeroes", idx, sample.size()); - } - - /** */ - private void consumeSampleVectors(BiConsumer<Vector, String> consumer) { - new VectorImplementationsFixtures().consumeSampleVectors(null, consumer); - } - - /** */ - private boolean isZero(double val) { - return val == 0.0; - } - - /** */ - private boolean readOnly(Vector v) { - return v instanceof RandomVector || v instanceof ConstantVector; - } -} - http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorToMatrixTest.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorToMatrixTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorToMatrixTest.java index a003dcf..7a39d02 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorToMatrixTest.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorToMatrixTest.java @@ -27,7 +27,6 @@ import org.apache.ignite.ml.math.Vector; import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException; import org.apache.ignite.ml.math.impls.matrix.DenseLocalOffHeapMatrix; import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix; -import org.apache.ignite.ml.math.impls.matrix.RandomMatrix; import org.apache.ignite.ml.math.impls.matrix.SparseLocalOnHeapMatrix; import org.junit.Test; @@ -42,42 +41,18 @@ public class VectorToMatrixTest { private static final Map<Class<? extends Vector>, Class<? extends Matrix>> typesMap = typesMap(); /** */ - private static final List<Class<? extends Vector>> likeMatrixUnsupported = Arrays.asList(FunctionVector.class, - SingleElementVector.class, SingleElementVectorView.class, ConstantVector.class); - - /** */ @Test - public void testHaveLikeMatrix() throws InstantiationException, IllegalAccessException { + public void testHaveLikeMatrix() { for (Class<? extends Vector> key : typesMap.keySet()) { Class<? extends Matrix> val = typesMap.get(key); - if (val == null && likeMatrixSupported(key)) + if (val == null) System.out.println("Missing test for implementation of likeMatrix for " + key.getSimpleName()); } } /** */ @Test - public void testLikeMatrixUnsupported() throws Exception { - consumeSampleVectors((v, desc) -> { - if (likeMatrixSupported(v.getClass())) - return; - - boolean expECaught = false; - - try { - assertNull("Null view instead of exception in " + desc, v.likeMatrix(1, 1)); - } - catch (UnsupportedOperationException uoe) { - expECaught = true; - } - - assertTrue("Expected exception was not caught in " + desc, expECaught); - }); - } - - /** */ - @Test public void testLikeMatrix() { consumeSampleVectors((v, desc) -> { if (!availableForTesting(v)) @@ -223,9 +198,6 @@ public class VectorToMatrixTest { /** */ private void fillWithNonZeroes(Vector sample) { - if (sample instanceof RandomVector) - return; - for (Vector.Element e : sample.all()) e.set(1 + e.index()); } @@ -234,9 +206,6 @@ public class VectorToMatrixTest { private boolean availableForTesting(Vector v) { assertNotNull("Error in test: vector is null", v); - if (!likeMatrixSupported(v.getClass())) - return false; - final boolean availableForTesting = typesMap.get(v.getClass()) != null; final Matrix actualLikeMatrix = v.likeMatrix(1, 1); @@ -247,15 +216,6 @@ public class VectorToMatrixTest { return availableForTesting; } - /** Ignore test for given vector type. */ - private boolean likeMatrixSupported(Class<? extends Vector> clazz) { - for (Class<? extends Vector> ignoredClass : likeMatrixUnsupported) - if (ignoredClass.isAssignableFrom(clazz)) - return false; - - return true; - } - /** */ private void consumeSampleVectors(BiConsumer<Vector, String> consumer) { new VectorImplementationsFixtures().consumeSampleVectors(null, consumer); @@ -266,13 +226,7 @@ public class VectorToMatrixTest { return new LinkedHashMap<Class<? extends Vector>, Class<? extends Matrix>>() {{ put(DenseLocalOnHeapVector.class, DenseLocalOnHeapMatrix.class); put(DenseLocalOffHeapVector.class, DenseLocalOffHeapMatrix.class); - put(RandomVector.class, RandomMatrix.class); put(SparseLocalVector.class, SparseLocalOnHeapMatrix.class); - put(SingleElementVector.class, null); // TODO: IGNTIE-5723, find out if we need SingleElementMatrix to match, or skip it. - put(ConstantVector.class, null); - put(FunctionVector.class, null); - put(PivotedVectorView.class, DenseLocalOnHeapMatrix.class); // IMPL NOTE per fixture - put(SingleElementVectorView.class, null); put(MatrixVectorView.class, DenseLocalOnHeapMatrix.class); // IMPL NOTE per fixture put(DelegatingVector.class, DenseLocalOnHeapMatrix.class); // IMPL NOTE per fixture // IMPL NOTE check for presence of all implementations here will be done in testHaveLikeMatrix via Fixture http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/DataChanger.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/DataChanger.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/DataChanger.java deleted file mode 100644 index 600113b..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/DataChanger.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.yardstick.ml; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; -import org.apache.ignite.yardstick.IgniteAbstractBenchmark; - -/** - * Helps to ensure use of meaningfully different data in repeated invocations of benchmarked code in - * {@link IgniteAbstractBenchmark#test(Map)} method. - */ -public class DataChanger { - /** */ - private static final AtomicInteger changer = new AtomicInteger(0); - - /** - * @return Positive "seed" to mutate data. - */ - public static double next() { - return (changer.incrementAndGet() % 17) + 1; - } - - /** */ - public static class Scale { - /** */ - private final double scale; - - /** */ - public Scale() { - this.scale = DataChanger.next(); - } - - /** */ - public double[][] mutate(double[][] orig) { - for (int i = 0; i < orig.length; i++) - orig[i] = mutate(orig[i]); - - return orig; - } - - /** */ - public double[] mutate(double[] orig) { - for (int i = 0; i < orig.length; i++) - orig[i] *= scale; - - return orig; - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.java deleted file mode 100644 index 6997180..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.yardstick.ml.decomposition; - -import java.util.Map; -import org.apache.ignite.ml.math.Matrix; -import org.apache.ignite.ml.math.Vector; -import org.apache.ignite.ml.math.decompositions.CholeskyDecomposition; -import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix; -import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector; -import org.apache.ignite.yardstick.IgniteAbstractBenchmark; -import org.apache.ignite.yardstick.ml.DataChanger; - -/** - * Ignite benchmark that performs ML Grid operations. - */ -@SuppressWarnings("unused") -public class IgniteCholeskyDecompositionBenchmark extends IgniteAbstractBenchmark { - /** {@inheritDoc} */ - @Override public boolean test(Map<Object, Object> ctx) throws Exception { - runCholeskyDecomposition(); - - return true; - } - - /** - * Based on CholeskyDecompositionTest. - */ - private void runCholeskyDecomposition() { - final DataChanger.Scale scale = new DataChanger.Scale(); - - Matrix m = new DenseLocalOnHeapMatrix(scale.mutate(new double[][] { - {2.0d, -1.0d, 0.0d}, - {-1.0d, 2.0d, -1.0d}, - {0.0d, -1.0d, 2.0d} - })); - - CholeskyDecomposition dec = new CholeskyDecomposition(m); - - dec.getL(); - dec.getLT(); - - Matrix bs = new DenseLocalOnHeapMatrix(scale.mutate(new double[][] { - {4.0, -6.0, 7.0}, - {1.0, 1.0, 1.0} - })).transpose(); - dec.solve(bs); - - Vector b = new DenseLocalOnHeapVector(scale.mutate(new double[] {4.0, -6.0, 7.0})); - dec.solve(b); - - dec.destroy(); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.java deleted file mode 100644 index e61c40c..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.yardstick.ml.decomposition; - -import java.util.Map; -import org.apache.ignite.ml.math.decompositions.EigenDecomposition; -import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix; -import org.apache.ignite.yardstick.IgniteAbstractBenchmark; -import org.apache.ignite.yardstick.ml.DataChanger; - -/** - * Ignite benchmark that performs ML Grid operations. - */ -@SuppressWarnings("unused") -public class IgniteEigenDecompositionBenchmark extends IgniteAbstractBenchmark { - /** {@inheritDoc} */ - @Override public boolean test(Map<Object, Object> ctx) throws Exception { - runEigenDecomposition(); - - return true; - } - - /** - * Based on EigenDecompositionTest. - */ - private void runEigenDecomposition() { - final DataChanger.Scale scale = new DataChanger.Scale(); - - EigenDecomposition decomposition1 = new EigenDecomposition(new DenseLocalOnHeapMatrix( - scale.mutate(new double[][] { - {1.0d, 0.0d, 0.0d, 1.0d}, - {0.0d, 1.0d, 0.0d, 1.0d}, - {0.0d, 0.0d, 2.0d, 0.0d}, - {1.0d, 1.0d, 0.0d, 2.0d}}))); - - decomposition1.getD(); - decomposition1.getV(); - - decomposition1.destroy(); - - EigenDecomposition decomposition2 = new EigenDecomposition(new DenseLocalOnHeapMatrix( - scale.mutate(new double[][] { - {1.0d, 0.0d, 0.0d}, - {0.0d, 1.0d, 0.0d}, - {0.0d, 0.0d, 2.0d}, - {1.0d, 1.0d, 0.0d}}))); - // TODO: IGNITE-5828, find out why decomposition of 3X4 matrix throws row index exception - - decomposition2.getD(); - decomposition2.getV(); - - decomposition2.destroy(); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java deleted file mode 100644 index 1368ef9..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.yardstick.ml.decomposition; - -import java.util.Map; -import org.apache.ignite.ml.math.Matrix; -import org.apache.ignite.ml.math.decompositions.LUDecomposition; -import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix; -import org.apache.ignite.ml.math.impls.matrix.PivotedMatrixView; -import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector; -import org.apache.ignite.yardstick.IgniteAbstractBenchmark; -import org.apache.ignite.yardstick.ml.DataChanger; - -/** - * Ignite benchmark that performs ML Grid operations. - */ -@SuppressWarnings("unused") -public class IgniteLUDecompositionBenchmark extends IgniteAbstractBenchmark { - /** {@inheritDoc} */ - @Override public boolean test(Map<Object, Object> ctx) throws Exception { - runLUDecomposition(); - - return true; - } - - /** - * Based on LUDecompositionTest. - */ - private void runLUDecomposition() { - Matrix testMatrix = new DenseLocalOnHeapMatrix(new DataChanger.Scale().mutate(new double[][] { - {2.0d, 1.0d, 1.0d, 0.0d}, - {4.0d, 3.0d, 3.0d, 1.0d}, - {8.0d, 7.0d, 9.0d, 5.0d}, - {6.0d, 7.0d, 9.0d, 8.0d}})); - - LUDecomposition dec1 = new LUDecomposition(new PivotedMatrixView(testMatrix)); - - dec1.solve(new DenseLocalOnHeapVector(testMatrix.rowSize())); - - dec1.destroy(); - - LUDecomposition dec2 = new LUDecomposition(new PivotedMatrixView(testMatrix)); - - dec2.solve(new DenseLocalOnHeapMatrix(testMatrix.rowSize(), testMatrix.rowSize())); - - dec2.destroy(); - - LUDecomposition dec3 = new LUDecomposition(testMatrix); - - dec3.getL(); - - dec3.getU(); - - dec3.getP(); - - dec3.getPivot(); - - dec3.destroy(); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.java deleted file mode 100644 index 9f02852..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.yardstick.ml.decomposition; - -import java.util.Map; -import org.apache.ignite.ml.math.Matrix; -import org.apache.ignite.ml.math.decompositions.SingularValueDecomposition; -import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix; -import org.apache.ignite.yardstick.IgniteAbstractBenchmark; -import org.apache.ignite.yardstick.ml.DataChanger; - -/** - * Ignite benchmark that performs ML Grid operations. - */ -@SuppressWarnings("unused") -public class IgniteSingularValueDecompositionBenchmark extends IgniteAbstractBenchmark { - /** {@inheritDoc} */ - @Override public boolean test(Map<Object, Object> ctx) throws Exception { - runSingularValueDecomposition(); - - return true; - } - - /** - * Based on SingularValueDecompositionTest#basicTest. - */ - private void runSingularValueDecomposition() { - Matrix m = new DenseLocalOnHeapMatrix(new DataChanger.Scale().mutate(new double[][] { - {2.0d, -1.0d, 0.0d}, - {-1.0d, 2.0d, -1.0d}, - {0.0d, -1.0d, 2.0d} - })); - - SingularValueDecomposition dec = new SingularValueDecomposition(m); - - Matrix s = dec.getS(); - Matrix u = dec.getU(); - Matrix v = dec.getV(); - - u.times(s).times(v.transpose()); - - dec.destroy(); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/package-info.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/package-info.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/package-info.java deleted file mode 100644 index 4aaece3..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * <!-- Package description. --> - * ML Grid decomposition benchmarks. - */ -package org.apache.ignite.yardstick.ml.decomposition; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java deleted file mode 100644 index 6cb2200..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.yardstick.ml.math; - -import java.util.Map; -import org.apache.ignite.Ignite; -import org.apache.ignite.ml.math.Matrix; -import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.thread.IgniteThread; -import org.apache.ignite.yardstick.IgniteAbstractBenchmark; -import org.apache.ignite.yardstick.ml.DataChanger; - -/** - * Ignite benchmark that performs ML Grid operations of matrix multiplication. - */ -abstract class IgniteAbstractMatrixMulBenchmark extends IgniteAbstractBenchmark { - /** */ - private static final int SIZE = 1 << 7; - - /** */ - private double[][] dataSquare = createAndFill(SIZE, SIZE); - - /** */ - private double[][] dataRect1 = createAndFill(SIZE / 2, SIZE); - - /** */ - private double[][] dataRect2 = createAndFill(SIZE, SIZE / 2); - - /** */ - @SuppressWarnings("unused") - @IgniteInstanceResource - private Ignite ignite; - - /** {@inheritDoc} */ - @Override public boolean test(Map<Object, Object> ctx) throws Exception { - final double scale = DataChanger.next(); - - // Create IgniteThread, we may want to work with SparseDistributedMatrix inside IgniteThread - // because we create ignite cache internally. - IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(), - this.getClass().getSimpleName(), new Runnable() { - /** {@inheritDoc} */ - @Override public void run() { - Matrix m1, m2, m3, m4, m5, m6; - - Matrix m7 = times(m1 = createAndFill(dataSquare, scale), m2 = createAndFill(dataSquare, scale)); - Matrix m8 = times(m3 = createAndFill(dataRect1, scale), m4 = createAndFill(dataRect2, scale)); - Matrix m9 = times(m5 = createAndFill(dataRect2, scale), m6 = createAndFill(dataRect1, scale)); - - m1.destroy(); - m2.destroy(); - m3.destroy(); - m4.destroy(); - m5.destroy(); - m6.destroy(); - m7.destroy(); - m8.destroy(); - m9.destroy(); - } - }); - - igniteThread.start(); - - igniteThread.join(); - - return true; - } - - /** - * Override in subclasses with specific type Matrix. Note that size of result matrix may be smaller than requested. - * - * @param rowSize Requested row size. - * @param colSize Requested column size. - * @return Matrix of desired type of size that doesn't exceed requested. - */ - abstract Matrix newMatrix(int rowSize, int colSize); - - /** Override in subclasses if needed. */ - Matrix times(Matrix m1, Matrix m2) { - return m1.times(m2); - } - - /** Override in subclasses if needed to account for smaller matrix size. */ - Matrix createAndFill(double[][] data, double scale) { - // IMPL NOTE yardstick 0.8.3 fails to discover benchmark if we try to account for smaller size - // matrix by using method with lambda parameter here: assign((row, col) -> data[row][col]). - Matrix res = newMatrix(data.length, data[0].length).assign(data); - - for (int i = 0; i < data.length && i < data[0].length; i++) - res.set(i, i, data[i][i] * scale); - - return res; - } - - /** */ - private double[][] createAndFill(int rowSize, int colSize) { - double[][] data = new double[rowSize][colSize]; - - for (int i = 0; i < rowSize; i++) - for (int j = 0; j < colSize; j++) - data[i][j] = -0.5d + Math.random(); - - return data; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java deleted file mode 100644 index 027b515..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.yardstick.ml.math; - -import org.apache.ignite.ml.math.Matrix; -import org.apache.ignite.ml.math.impls.matrix.DenseLocalOffHeapMatrix; - -/** - * Ignite benchmark that performs ML Grid operations. - */ -@SuppressWarnings("unused") -public class IgniteDenseLocalOffHeapMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark { - /** {@inheritDoc} */ - @Override Matrix newMatrix(int rowSize, int colSize) { - return new DenseLocalOffHeapMatrix(rowSize, colSize); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java deleted file mode 100644 index 6830130..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.yardstick.ml.math; - -import org.apache.ignite.ml.math.Matrix; -import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix; - -/** - * Ignite benchmark that performs ML Grid operations. - */ -@SuppressWarnings("unused") -public class IgniteDenseLocalOnHeapMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark { - /** {@inheritDoc} */ - @Override Matrix newMatrix(int rowSize, int colSize) { - return new DenseLocalOnHeapMatrix(rowSize, colSize); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java deleted file mode 100644 index 8762620..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.yardstick.ml.math; - -import org.apache.ignite.ml.math.Matrix; -import org.apache.ignite.ml.math.impls.matrix.SparseBlockDistributedMatrix; - -/** - * Ignite benchmark that performs ML Grid operations. - */ -@SuppressWarnings("unused") -public class IgniteSparseBlockDistributedMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark { - /** {@inheritDoc} */ - @Override Matrix newMatrix(int rowSize, int colSize) { - return new SparseBlockDistributedMatrix(rowSize, colSize); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMul2Benchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMul2Benchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMul2Benchmark.java deleted file mode 100644 index e1afc34..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMul2Benchmark.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.yardstick.ml.math; - -import org.apache.ignite.ml.math.Matrix; -import org.apache.ignite.ml.math.StorageConstants; -import org.apache.ignite.ml.math.impls.matrix.SparseBlockDistributedMatrix; -import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix; - -/** - * Ignite benchmark that performs trivially optimized matrix multiplication of {@link SparseDistributedMatrix} that - * uses delegating to {@link SparseBlockDistributedMatrix}. For unoptimized benchmark refer - * {@link IgniteSparseDistributedMatrixMulBenchmark}. - */ -@SuppressWarnings("unused") -public class IgniteSparseDistributedMatrixMul2Benchmark extends IgniteAbstractMatrixMulBenchmark { - /** {@inheritDoc} */ - @Override Matrix newMatrix(int rowSize, int colSize) { - return new SparseDistributedMatrix(rowSize, colSize, - StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE); - } - - /** {@inheritDoc} */ - @Override public Matrix times(Matrix m1, Matrix m2) { - return new OptimisedTimes(m1, m2).times(); - } - - /** */ - private static class OptimisedTimes { - /** */ - private final Matrix m1; - - /** */ - private final Matrix m2; - - /** */ - OptimisedTimes(Matrix m1, Matrix m2) { - this.m1 = m1; - this.m2 = m2; - } - - /** */ - Matrix times() { - Matrix m1Block = new SparseBlockDistributedMatrix(m1.rowSize(), m1.columnSize()).assign(m1); - Matrix m2Block = new SparseBlockDistributedMatrix(m2.rowSize(), m2.columnSize()).assign(m2); - - Matrix m3Block = m1Block.times(m2Block); - - Matrix res = new SparseDistributedMatrix(m3Block.rowSize(), m3Block.columnSize(), - StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE).assign(m3Block); - - m1Block.destroy(); - m2Block.destroy(); - m3Block.destroy(); - - return res; - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java deleted file mode 100644 index 0f9d288..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.yardstick.ml.math; - -import org.apache.ignite.ml.math.Matrix; -import org.apache.ignite.ml.math.StorageConstants; -import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix; - -/** - * Ignite benchmark that performs unoptimized matrix multiplication of {@link SparseDistributedMatrix}. - * For optimized benchmark refer {@link IgniteSparseBlockDistributedMatrixMulBenchmark}. - */ -@SuppressWarnings("unused") -public class IgniteSparseDistributedMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark { - /** This benchmark is unacceptably slow without scaling down, see IGNITE-7097. */ - private static final int SCALE_DOWN = 2; - - /** {@inheritDoc} */ - @Override Matrix newMatrix(int rowSize, int colSize) { - return new SparseDistributedMatrix(rowSize >> SCALE_DOWN, colSize >> SCALE_DOWN, - StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE); - } - - /** {@inheritDoc} */ - @Override Matrix createAndFill(double[][] data, double scale) { - Matrix res = newMatrix(data.length, data[0].length); - - for (int row = 0; row < res.rowSize(); row++) - for (int col = 0; col < res.columnSize(); col++) - res.set(row, col, row == col ? data[row][col] * scale : data[row][col]); - - return res; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java deleted file mode 100644 index de2c99b..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.yardstick.ml.math; - -import org.apache.ignite.ml.math.Matrix; -import org.apache.ignite.ml.math.impls.matrix.SparseLocalOnHeapMatrix; - -/** - * Ignite benchmark that performs ML Grid operations. - */ -@SuppressWarnings("unused") -public class IgniteSparseLocalMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark { - /** {@inheritDoc} */ - @Override Matrix newMatrix(int rowSize, int colSize) { - return new SparseLocalOnHeapMatrix(rowSize, colSize); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/package-info.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/package-info.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/package-info.java deleted file mode 100644 index d37e967..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * <!-- Package description. --> - * ML Grid math benchmarks. - */ -package org.apache.ignite.yardstick.ml.math; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/9dccb3db/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/package-info.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/package-info.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/package-info.java deleted file mode 100644 index 4751f35..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * <!-- Package description. --> - * ML Grid benchmarks. - */ -package org.apache.ignite.yardstick.ml; \ No newline at end of file
