Skip to content

set_fancy does not work for some arrays with certain Bigarray.kind types. #671

@zoj613

Description

@zoj613

When using Owl.Dense.Ndarray.Generic.set_fancy with arrays of kinds not Float32, Float64, Complex32 or Complex64, the operation fails with error message Exception: Failure "_ndarray_set_fancy: unsupported operation", even though the kind is a valid Bigarray.kind type.

It appears this exception is thrown by the snippet:

let _ndarray_set_fancy
: type a b c.
(a, b) kind
-> (a, b) owl_arr
-> (a, b) owl_arr
-> (int64, c) owl_arr
-> (int64, c) owl_arr
-> unit
= function
| Float32 -> owl_float32_ndarray_set_fancy
| Float64 -> owl_float64_ndarray_set_fancy
| Complex32 -> owl_complex32_ndarray_set_fancy
| Complex64 -> owl_complex64_ndarray_set_fancy
| _ -> failwith "_ndarray_set_fancy: unsupported operation"

I think it is very limiting to only support just 4 kinds when the set operation should work for any of the Bigarray.kind types.

Here is a minimal example to reproduce the error:

module Ndarray = Owl.Dense.Ndarray.Generic
let arr = Ndarray.create Bigarray.Int32 [|3;4;3|] 5l
let slice = Owl_types.[L [1; 2]; R []; I 0]
let x = Ndarray.create Bigarray.Int32 [|2; 4; 1|] 0l
 Ndarray.set_fancy slice arr x

I expected this simple operation to work but it throws a |Exception: Failure "_ndarray_set_fancy: unsupported operation". exception.

I would love for Owl to support more kinds as im using it to write an array library that needs to support more than the 4 basic kinds listed above.

Cc @mseri @jzstark

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions