<commit_before>package org.nd4j.linalg.api.blas.params;

import lombok.Data;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.factory.NDArrayFactory;

/**
 * Used for setting the gemm parameters
 * Separates blas logic from
 * the run time itself.
 *
 * @author <NAME>
 */
public @Data class GemmParams {
    private int lda,ldb,ldc,m,n,k;
    private INDArray a,b,c;

    public GemmParams(INDArray a,INDArray b,INDArray c) {
        if(b.columns() != c.columns())
            throw new IllegalArgumentException("B columns must match c columns");
        if(a.rows() != c.rows())
            throw new IllegalArgumentException("A rows must equal c rows");
        this.a = a;
        this.b = b;
        this.c = c;
        this.m = a.rows();
        this.n = b.columns();
        this.k = a.columns();
        this.lda = k;
        this.ldb = n;
        this.ldc = n;
        if(a.ordering() == NDArrayFactory.C) {
            //  #define DGEMM_ROWMAJOR(A,B,C,m,n,k,alpha,beta,transf_A,transf_B, lda, ldb, ldc) \
            //  DGEMM(transf_B, transf_A, n, m, k, alpha, B, ldb, A, lda, beta, C, ldc)
            int oldN = n;
            int oldM = m;
            this.m = oldN;
            this.n = oldM;
            this.lda = n;
            this.ldb = k;

        }

        validate();
    }


    private void validate() {

        if(m < 0)
            throw new IllegalStateException("M must be >= 0");<commit_msg>fix lda in gemm<commit_after>package org.nd4j.linalg.api.blas.params;

import lombok.Data;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.factory.NDArrayFactory;

/**
 * Used for setting the gemm parameters
 * Separates blas logic from
 * the run time itself.
 *
 * @author <NAME>
 */
public @Data class GemmParams {
    private int lda,ldb,ldc,m,n,k;
    private INDArray a,b,c;

    public GemmParams(INDArray a,INDArray b,INDArray c) {
        if(b.columns() != c.columns())
            throw new IllegalArgumentException("B columns must match c columns");
        if(a.rows() != c.rows())
            throw new IllegalArgumentException("A rows must equal c rows");
        this.a = a;
        this.b = b;
        this.c = c;
        this.m = a.rows();
        this.n = b.columns();
        this.k = a.columns();
        this.lda = a.size(0);
        this.ldb = b.size(0);
        this.ldc = c.size(0);
        if(a.ordering() == NDArrayFactory.C) {
            int oldN = n;
            int oldM = m;
            this.m = oldN;
            this.n = oldM;
            this.lda = n;
            this.ldb = k;

        }

        validate();
    }


    private void validate() {

        if(m < 0)
            throw new IllegalStateException("M must be >= 0");
{'fraction_non_alphanumeric': 0.1338958180484226, 'fraction_numerical': 0.004768892149669846, 'mean_word_length': 1.9103521878335112, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4231426', 'n_tokens_mistral': 960, 'n_tokens_neox': 936, 'n_words': 230}