Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ refactoring: getting Numba to work for v2 arrays #1240

Merged
merged 28 commits into from
Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0fe2148
Uncommenting and updating Numba-handling code (step 1).
jpivarski Jan 20, 2022
ea33885
Do 'tolookup' with just the 'positions' list, but make the same 'arra…
jpivarski Jan 20, 2022
50c23c2
Figured out how to fill 'positions' without extra cruft.
jpivarski Jan 21, 2022
714a19e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 21, 2022
4959a2b
Merge branch 'main' into jpivarski/v2-implementation-of-numba-1
jpivarski Jan 21, 2022
de1c8d9
Typed out all 'tolookup' and 'from_form' classmethods.
jpivarski Jan 21, 2022
8ce7cc3
Merge branch 'main' into jpivarski/v2-implementation-of-numba-1
jpivarski Jan 25, 2022
42f294c
All layout types have a constructor and 'tolayout'.
jpivarski Jan 26, 2022
a5ba0a4
All layout code uncommented.
jpivarski Jan 26, 2022
2abe584
Working through layout <--> lookup roundtrips.
jpivarski Jan 26, 2022
9300eb9
Tested all layout <--> lookup roundtrips. v1 had some bugs.
jpivarski Jan 27, 2022
e460eec
Merge branch 'main' into jpivarski/v2-implementation-of-numba-1
jpivarski Jan 27, 2022
74fe685
Merge branch 'main' into jpivarski/v2-implementation-of-numba-1
jpivarski Jan 28, 2022
8a2a14a
Adding memoryleak checks (not done).
jpivarski Jan 28, 2022
0903073
Merge branch 'main' into jpivarski/v2-implementation-of-numba-1
jpivarski Feb 4, 2022
70aa232
Get up to date to start working on this again.
jpivarski Feb 4, 2022
5f27721
Finished all the memoryleak checks.
jpivarski Feb 4, 2022
cef0fca
Updated ArrayBuilder, too, and 0118-numba-cpointers passes.
jpivarski Feb 4, 2022
0e2d5ca
0397-arrays-as-constants-in-numba passes.
jpivarski Feb 4, 2022
62c4690
0903-ArrayView-expects-contiguous-NumpyArrays passes.
jpivarski Feb 4, 2022
75f3a87
0124-strings-in-numba passes.
jpivarski Feb 5, 2022
c88e36a
0290-bug-fixes-for-hats passes.
jpivarski Feb 5, 2022
9a12c88
0395-fix-numba-indexedarray passes.
jpivarski Feb 5, 2022
0a544c9
0494-numba-array-contains passes.
jpivarski Feb 5, 2022
2f0bf18
0559-fix-booleans-in-numba passes.
jpivarski Feb 5, 2022
303be2e
0572-numba-array-ndim passes.
jpivarski Feb 5, 2022
0cdbdd4
0549-numba-array-asarray passes.
jpivarski Feb 5, 2022
06b933e
0127b-tomask-operation-numba passes.
jpivarski Feb 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/awkward/_v2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE


# layout classes; functionality that used to be in C++ (in Awkward 1.x)
import awkward._v2.index # noqa: F401
import awkward._v2.identifier # noqa: F401
Expand All @@ -17,23 +16,26 @@

# third-party connectors
import awkward._v2._connect.numpy
import awkward._v2._connect.numba
import awkward._v2._connect.numexpr # noqa: F401
import awkward._v2.numba # noqa: F401

# high-level interface
from awkward._v2.highlevel import Array # noqa: F401
from awkward._v2.highlevel import Record # noqa: F401
from awkward._v2.highlevel import ArrayBuilder # noqa: F401

# behaviors
behavior = {}
from awkward._v2.behaviors.categorical import * # noqa: E402, F401, F403
from awkward._v2.behaviors.mixins import * # noqa: E402, F401, F403
from awkward._v2.behaviors.string import * # noqa: E402, F401, F403
import awkward._v2.behaviors.categorical # noqa: F401
import awkward._v2.behaviors.mixins # noqa: F401
import awkward._v2.behaviors.string # noqa: F401

# operations
from awkward._v2.operations.io import * # noqa: E402, F401, F403
from awkward._v2.operations.convert import * # noqa: E402, F401, F403
from awkward._v2.operations.describe import * # noqa: E402, F401, F403
from awkward._v2.operations.structure import * # noqa: E402, F401, F403
from awkward._v2.operations.reducers import * # noqa: E402, F401, F403
from awkward._v2.operations.io import * # noqa: F401, F403
from awkward._v2.operations.convert import * # noqa: F401, F403
from awkward._v2.operations.describe import * # noqa: F401, F403
from awkward._v2.operations.structure import * # noqa: F401, F403
from awkward._v2.operations.reducers import * # noqa: F401, F403


behavior = {}
behaviors.string.register(behavior) # noqa: F405
113 changes: 0 additions & 113 deletions src/awkward/_v2/_connect/numba/__init__.py
Original file line number Diff line number Diff line change
@@ -1,114 +1 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE

# from __future__ import absolute_import

# import types

# import awkward as ak

# checked_version = False


# def register_and_check():
# global checked_version
# try:
# import numba
# except ImportError:
# raise ImportError(
# """install the 'numba' package with:

# pip install numba --upgrade

# or

# conda install numba"""
# )
# else:
# if not checked_version and ak._v2._util.parse_version(
# numba.__version__
# ) < ak._v2._util.parse_version("0.50"):
# raise ImportError(
# "Awkward Array can only work with numba 0.50 or later "
# "(you have version {0})".format(numba.__version__)
# )
# checked_version = True
# register()


# def register():
# import numba
# import awkward._v2._connect.numba.arrayview
# import awkward._v2._connect.numba.layout
# import awkward._v2._connect.numba.builder

# if hasattr(ak.numba, "ArrayViewType"):
# return

# n = ak.numba
# n.ArrayViewType = awkward._v2._connect.numba.arrayview.ArrayViewType
# n.ArrayViewModel = awkward._v2._connect.numba.arrayview.ArrayViewModel
# n.RecordViewType = awkward._v2._connect.numba.arrayview.RecordViewType
# n.RecordViewModel = awkward._v2._connect.numba.arrayview.RecordViewModel
# n.ContentType = awkward._v2._connect.numba.layout.ContentType
# n.NumpyArrayType = awkward._v2._connect.numba.layout.NumpyArrayType
# n.RegularArrayType = awkward._v2._connect.numba.layout.RegularArrayType
# n.ListArrayType = awkward._v2._connect.numba.layout.ListArrayType
# n.IndexedArrayType = awkward._v2._connect.numba.layout.IndexedArrayType
# n.IndexedOptionArrayType = awkward._v2._connect.numba.layout.IndexedOptionArrayType
# n.ByteMaskedArrayType = awkward._v2._connect.numba.layout.ByteMaskedArrayType
# n.BitMaskedArrayType = awkward._v2._connect.numba.layout.BitMaskedArrayType
# n.UnmaskedArrayType = awkward._v2._connect.numba.layout.UnmaskedArrayType
# n.RecordArrayType = awkward._v2._connect.numba.layout.RecordArrayType
# n.UnionArrayType = awkward._v2._connect.numba.layout.UnionArrayType
# n.ArrayBuilderType = awkward._v2._connect.numba.builder.ArrayBuilderType
# n.ArrayBuilderModel = awkward._v2._connect.numba.builder.ArrayBuilderModel

# @numba.extending.typeof_impl.register(ak._v2.highlevel.Array)
# def typeof_Array(obj, c):
# return obj.numba_type

# @numba.extending.typeof_impl.register(ak._v2.highlevel.Record)
# def typeof_Record(obj, c):
# return obj.numba_type

# @numba.extending.typeof_impl.register(ak._v2.highlevel.ArrayBuilder)
# def typeof_ArrayBuilder(obj, c):
# return obj.numba_type


# def repr_behavior(behavior):
# return repr(behavior)


# def castint(context, builder, fromtype, totype, val):
# import numba
# import llvmlite.ir.types

# if isinstance(fromtype, llvmlite.ir.types.IntType):
# if fromtype.width == 8:
# fromtype = numba.int8
# elif fromtype.width == 16:
# fromtype = numba.int16
# elif fromtype.width == 32:
# fromtype = numba.int32
# elif fromtype.width == 64:
# fromtype = numba.int64
# if not isinstance(fromtype, numba.types.Integer):
# raise AssertionError(
# "unrecognized integer type: {0}".format(repr(fromtype))
#
# )

# if fromtype.bitwidth < totype.bitwidth:
# if fromtype.signed:
# return builder.sext(val, context.get_value_type(totype))
# else:
# return builder.zext(val, context.get_value_type(totype))
# elif fromtype.bitwidth > totype.bitwidth:
# return builder.trunc(val, context.get_value_type(totype))
# else:
# return val


# ak.numba = types.ModuleType("numba")
# ak.numba.register = register
Loading