Giter Site home page Giter Site logo

tensora's People

Contributors

amirmolavi avatar drhagen avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

amirmolavi

tensora's Issues

Make Tensors picklable

CFFI CData objects are not picklable. In order to pickle a Tensor object, it will have to be converted to something that can be pickled, probably by putting dimensions, modes, indices, and vals into a dictionary as the pickle state.

Make output format optional in evaluate

The output_format parameter should be optional in evaluate and default to all dense. This is a common enough choice and we default to all dense other places.

Centralize validation of formats against assignment

Currently, all the logic for checking that the formats match the variables in the assignment is done in tensora.function.PureTensorMethod. This code is not run by the CLI. This logic should be centralized into a class tensora.desugar.Problem that encapsulates the desugared assignment and validated format dictionary. Then this logic should be used upstream of code generation for both evaluate and the CLI.

Error on broadcasting to output

It is legal to have an index in the target that is not mentioned in right-hand side of the assignment. For example, A(i,j) = b(i). This is interpreted as a broadcast along that dimension. Unfortunately, there is no way to determine the size of this dimension when using evaluate or TensorMethod. The sizes are normally determined from the sizes of the inputs, which is not possible when broadcasting to output dimension because the output tensor is not an input to those porcelain functions. These should error in TensorMethod, while continuing to be valid kernels to generate.

Purge scalar support

With #33 closed, full scalar support is deferred indefinitely. The existing code that partially supports scalars should be removed for now.

Use a scalar pointer when emitting IR for a scalar bucket

Right now, a point-like bucket, looks like this:

double* restrict bucket_y_0 = y_vals + p_y_0_0;
int32_t i_bucket_y_0 = 0;
while (i_bucket_y_0 < 1) {
  bucket_y_0[i_bucket_y_0] = 0;
  i_bucket_y_0++;
}

// *** Computation of expression ***
bucket_y_0[0] += A_vals[p_A_1_1] * x_vals[p_x_2_0];

This is not wrong, and it is probably all optimized down by LLVM, but it would be fairly simple to emit this instead, which looks a lot nicer:

double* restrict bucket_y_0 = y_vals + p_y_0_0
*bucket_y_0 = 0

// *** Computation of expression ***
*bucket_y_0 += A_vals[p_A_1_1] * x_vals[p_x_2_0];

Add ability to take ownership of `taco_tensor_t*`

There is already the taco_structure_to_cffi function in compile that takes ownership of the data in indices and vals. If a taco_tensor_t is created in some C code outside Tensora, it would be nice to be able to take ownership of all the data in the structure. This will involve taking ownership of the struct pointer itself, then taking ownership of the dimensions, mode_ordering, and mode_types pointers, and finally calling taco_structure_to_cffi to take ownership of the rest.

Validate expression inputs

We should validate the inputs to the leaves of tensor expressions so that various errors occur earlier rather than later:

  1. Validate that the input to Integer is non-negative. Alternatively, we could modify the parser to allow negative numbers.
  2. Validate that the input to Float is non-negative finite. Alternatively, we could modify the parser to allow inf and nan and negative numbers.
  3. Validate that the name and index names of Tensor follow this regex [A-Za-z][A-Za-z0-9]*

Support scalars appropriately

Scalars in tensor expressions should be interpreted as floats. The Tensora compiler could generate code that accepts doubles, but TACO will not. We could shim the TACO code so that evaluate_taco still accepts floats, but that sounds like a source of ambiguity.

Here are the steps needed to implement this:

  1. Make generate_c_code_tensora generate C code that takes doubles
  2. Make generate_c_code_taco fail on any scalar format
  3. Make PureTensorMethod.__call__ handle inputs and outputs that are scalar arguments. Should allow int and float as inputs. Should return a Python float as an output.

Add Tensor.to_numpy

A naive implementation could loop over Tensor.items() and assign the entries to an array of zeros. There cannot be duplicate items.

Write sparse input to dense output all at once

Right now, if in a given iteration and the input is sparse while the output is dense, the iteration loop is dense and the loop writes each zero in between the sparse values. This is particularly inefficient when doing compute on an already assembled output. It also complicates the code having to always write to the output even when the input is sparse.

When the output is dense and the input is sparse, Tensora should preallocate the output and the iteration should be sparse. Care needs to be taken when subsequent layers are sparse. This might be less efficient when doing evaluate, but perhaps not depending on how optimized the processor is for writing blocks of zeros to memory. This preallocation only needs to be done during assembly and not during compute.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.