Comments (8)
Thanks for the comment, work on this is in progress!
In the meanwhile, you can find some rudimentary examples documentation-and-tutorials section of the readme.
from easytensor.
Just wanted to say I'm learning a lot reading through the implementation of easytensor. And slowly going crazy... :P
from easytensor.
Ha-ha, sorry :)
While I don't have time for a full tutorial at this moment, you may ask here about specific parts in the project and I will quickly haddock more elaborate descriptions.
from easytensor.
Documentation of functions / datatypes is not the problem for me. What I need is one or two simple examples for each project of how it's intended to be used.
from easytensor.
One thing I'm unclear on is why you would ever use XN n
for any n > 0. What do you get out of statically knowing that that dimension has at least n elements?
For instance, in this snippet, the data frame will have 7 vertices; why specify that it's statically unknown but at least 3? Why not 0, or 7?
from easytensor.
@joelburget yes, I understand that. I will add the tutorial as soon as finish writing my thesis (likely in September , sorry for that)
@Rotaerk In general, XN n
is meant for data import. Imagine something like this:
importCsv :: FilePath -> IO (Either String (DataFrame Vertex '[XN 1]))
The function above reads a non-empty data frame or fails. We cannot index DataFrame using Nat
here, because we don't know dimensionality in advance. On the other hand, we may want to reject the imported file if it has too few lines.
In vulkan-triangles
, the constraint comes not from the data, but from the program logic: shader pipeline requires at least 3 vertices to draw at least one triangle primitive. I decided, that would be handy to declare explicitly. Added a comment to the code.
from easytensor.
Well, I was going to write up something about having issues with getting XFrame matching to work, but it turns out it was resolved by adding more type annotations to unrelated functions in my code... However, the type errors were rather troublesome to make sense of, and I only accidentally got it working.
In the commit Rotaerk/vulkanTest@033701b, I wanted to move the XFrame matching outside of the createVertexBuffer
and fillVertexbufferMemory
functions. So I moved it up into the beginning of main, and indented the entire runResourceT
block to be inside of it.
Problems I encountered while working on this change:
-
It took me some work to figure out what type to give the revised
fillVertexBufferMemory
function. I initially triedDataFrame Vertex (ns :: [Nat])
, but that gave me this error:src/Main.hs:723:70: error: • Overlapping instances for PrimBytes (Numeric.DataFrame.Internal.Array.Family.Array Vertex ns) arising from a use of ‘bSizeOf’ Matching instances: instance [overlappable] (VulkanMarshalPrim a, Storable a) => PrimBytes a -- Defined in ‘Graphics.Vulkan.Marshal.Create.DataFrame’ instance (PrimBytes a, PrimBytes b) => PrimBytes (Either a b) -- Defined in ‘Numeric.PrimBytes’ instance PrimBytes Int16 -- Defined in ‘Numeric.PrimBytes’ ...plus 15 others ...plus 13 instances involving out-of-scope types (use -fprint-potential-instances to see them all) (The choice depends on the instantiation of ‘ns’ To pick the first instance above, use IncoherentInstances when compiling the other instance declarations) • In the second argument of ‘($)’, namely ‘bSizeOf vertices’ In the fourth argument of ‘mappedMemory’, namely ‘(fromIntegral $ bSizeOf vertices)’ In the first argument of ‘with’, namely ‘(mappedMemory device vertexBufferMemory 0 (fromIntegral $ bSizeOf vertices))’ | 723 | with (mappedMemory device vertexBufferMemory 0 (fromIntegral $ bSizeOf vertices)) $ \ptr -> | ^^^^^^^^^^^^^^^^
I'm still not really sure how I would give it a DataFrame type, but I was able to get it to work with the more generic type that it has now.
-
In addition to making the obvious code changes, I also had to add type annotations to
maxFramesInFlight
and toevalStateTWith
. Without them, I got some pretty strange type errors. It seems odd that this would be suddenly required just because these things are used inside of the XFrame case.
from easytensor.
Looks like I messed up with instances of PrimBytes
. I have created an issue #9 to improve the situation with that.
In general, whenever you encounter Overlapping instances
error, you should first check if there is any instance in scope that satisfies the class constraint.
In your case, GHC does not know which instance of Array
type family is used inside the DataFrame and, thus, cannot find a suitable type class instance for PrimBytes
. Thus, you need to provide the instances explicitly. The XNat
-indexed DataFrame carries only a few instances for a Nat
-indexed DataFrame behind its existential constructor. If you need any more instance in the scope of pattern match, you can use inference functions, e.g.
case xdf of
XFrame df
| E <- inferPrim df -> do
... -- df has an instance of PrimBytes here
Most commonly required inference functions are given by DataFrameInference
class.
As for the second problem, cannot really say right now, without trying it myself.
from easytensor.
Related Issues (20)
- prop_Comparisons fails every once in a while HOT 1
- Add mechanism for easily getting field offsets HOT 2
- Slicing a DataFrame HOT 2
- Stability of LU factorization HOT 1
- easytensor-vulkan doesn't build HOT 1
- cabal files missing HOT 4
- slice and ewfoldr usage HOT 13
- packDF usage? HOT 3
- PrimBytes instances for Foreign.C.Types HOT 3
- Need simpler way to get a PrimBytes field from a Ptr
- Need PrimBytes instance for `FunPtr a`
- Projection matrices need variants for Vulkan and have wrong docs HOT 9
- Missing pattern synonyms in haddock output
- Hello, Artem Chirkin. I have some question for easytensor. HOT 2
- internal error: ARR_WORDS object entered HOT 1
- instances for ad package missing HOT 1
- `dimensions` package is missing a CHANGELOG
- `dimensions-1.0.1.1` fails to build with GHC 8.10 and up HOT 1
- HomTransform4 not implemented HOT 4
- Need a better error message for absence PrimBytes (DataFrame t ds) instance HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easytensor.