Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

Rebase on numba 0.46 #224

Merged

Conversation

AlexanderKalistratov
Copy link
Collaborator

No description provided.

@AlexanderKalistratov AlexanderKalistratov changed the title rebase on numba 0.46 WIP: rebase on numba 0.46 Oct 14, 2019
@densmirn densmirn self-requested a review October 14, 2019 12:24
@AlexanderKalistratov AlexanderKalistratov requested review from densmirn and removed request for densmirn October 14, 2019 15:07
@@ -47,6 +47,8 @@ def jit(signature_or_function=None, **options):
return numba.jit(signature_or_function, **options)

_locals = options.pop('locals', {})
# print("\nlocals: " + str(_locals))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@@ -93,4 +95,5 @@ def jit(signature_or_function=None, **options):
# this is for previous version of pipeline manipulation (numba hpat_req <0.38)
# from .compiler import add_hpat_stages
# return numba.jit(signature_or_function, user_pipeline_funcs=[add_hpat_stages], **options)
# return numba.jit(signature_or_function, pipeline_class=hpat.compiler.HPATPipeline, **options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@@ -68,6 +68,9 @@ def _init_run(self):
self.second_pass = False
self.in_parallel_parfor = -1

def run_pass(self, state):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove and call run directly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think run_pass(self, state) is interface function. It is better to inline run() here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

@@ -394,6 +396,25 @@ def test_impl(df):
hpat_func = hpat.jit(test_impl)
pd.testing.assert_frame_equal(hpat_func(df), test_impl(df))

def test_df_nonliteral(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip this test for now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@@ -67,9 +68,19 @@ class TestSeries(unittest.TestCase):

def test_create1(self):
def test_impl():
# a = 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@Hardcode84
Copy link
Contributor

I assume we need to update numba version in our public ci as well

@Hardcode84
Copy link
Contributor

Also, disable tests broken by parfor issue as were disscussed

@@ -67,9 +68,19 @@ class TestSeries(unittest.TestCase):

def test_create1(self):
def test_impl():
# a = 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# a = 2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hardcode84
There is code suggestion tool in GitHub (ctrl+g)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@@ -4,6 +4,7 @@
import numpy as np
import pyarrow.parquet as pq
import hpat
import numba
Copy link
Contributor

@PokhodenkoSA PokhodenkoSA Oct 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import numba
import numba

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference?

@@ -8,6 +8,8 @@
count_parfor_OneDs, count_array_OneDs, dist_IR_contains,
get_start_end)

from numba.special import literally
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it used somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. Removed

hpat/compiler.py Outdated
for idx, (x, _) in enumerate(pm.passes):
if x == location:
return idx
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else: is excess and could be removed because we don't have break in the loop. Let's leave only raise.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines +99 to +100
def __init__(self):
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it should work the same way without the stub.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__init__ is marked as an abstract method in the base class

Comment on lines +141 to +142
def __init__(self):
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it should work the same way without the constructor, constructor of the parent class will be invoked anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__init__ is marked as an abstract method in the base class

Comment on lines +1050 to +1052
state = namedtuple('State',
['typingctx', 'targetctx', 'args', 'func_ir', 'typemap', 'return_type',
'calltypes', 'metadata'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case there is another way to define named tuple:

from typing import NamedTuple

class State(NamedTuple):
    typingctx: <type>
    targetctx: <type>
    args: <type>
    func_ir: <type>
    typemap: <type>
    return_type: <type>
    calltypes: <type>
    metadata: <type>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't have strong opinion it should be modified, I'd prefer to left as is

@@ -297,6 +297,7 @@ def test_array_reduce(self):
self.assertEqual(count_array_OneDs(), 0)
self.assertEqual(count_parfor_OneDs(), 1)

@unittest.skipIf(numba.__version__.startswith('0.46.'), "Broken in numba 0.46.x")
Copy link
Contributor

@Hardcode84 Hardcode84 Oct 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add url to issue numba/numba#4690

And IMO better to check exact version, e.g. if it will be still broken on 0.46.1 we will see that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, maybe create some helper function to check numba version to avoid copypaste

def run(self):
blocks = self.func_ir.blocks
def __init__(self, state):
self.state = state
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.func_ir, self.typemap, self.typingctx = self
?
no need to keep new variable in this case


.. only:: developer

The content for **Developer's Guide** should go here
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to have any documentation

Copy link
Contributor

@shssf shssf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this PR should be separated to, at least, two PRs. First PR is preparation work. For example, to rename variables self.typemap to self.state.typemap. It will not depend on Numba version

@AlexanderKalistratov AlexanderKalistratov changed the title WIP: rebase on numba 0.46 Rebase on numba 0.46 Oct 22, 2019
@AlexanderKalistratov
Copy link
Collaborator Author

Split PR into 5 commits:

  • Update globals for generated function
  • Replace numba.compiler with numba.typed_pass
  • Rename self. to self.state.
  • Modify aggregate.py to support state
  • All other changes

Most of commits would not work on numba 0.45 and doesn't work separately from each other, so all commits must be squashed before merge

@@ -531,3 +532,7 @@ def dump_node_list(node_list):

def debug_prints():
return numba.config.DEBUG_ARRAY_OPT == 1

def update_globals(func, glbls):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like this function used nowhere. please delete

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used in distributed, dataframe, high frame typad & untyped passes. It updates globals in generated functions. It was introduced in order to restore functionality of inline_closure_call which doesn't update globals anymore.

You can see details in related commit: 4b828c9

@@ -18,6 +18,7 @@
from hpat.str_ext import string_type, list_string_array_type
from hpat.str_arr_ext import string_array_type, num_total_chars, pre_alloc_string_array
from enum import Enum
import types as pytypes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it used in this module?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used in update_globals function

@@ -53,3 +53,6 @@ def get_start_end(n):
start = hpat.distributed_api.get_start(n, n_pes, rank)
end = hpat.distributed_api.get_end(n, n_pes, rank)
return start, end

def check_numba_version(version):
return numba.__version__ == version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numba.__version__ is shorter than check_numba_version
may be it is better to use this variable from Numba directly inplace?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. For me both versions are fine, though version with function is a little bit better, since it doesn't looks so ugly and encapsulates details

@AlexanderKalistratov
Copy link
Collaborator Author

Rebased & squashed

@shssf shssf merged commit 8e3a220 into IntelPython:master Oct 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants