Skip to content

Commit

Permalink
add flops counting to python interface (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuchenpang committed Feb 1, 2020
1 parent 507f565 commit fc9c4d9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src_python/ctf/core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ cdef extern from "ctf.hpp" namespace "CTF":
cdef extern from "ctf.hpp" namespace "CTF":
cdef void TTTP_ "CTF::TTTP"[dtype](Tensor[dtype] * T, int num_ops, int * modes, Tensor[dtype] ** mat_list, bool aux_mode_first)
cdef void MTTKRP_ "CTF::MTTKRP"[dtype](Tensor[dtype] * T, Tensor[dtype] ** mat_list, int mode, bool aux_mode_first)
cdef void initialize_flops_counter_ "CTF::initialize_flops_counter"()
cdef int64_t get_estimated_flops_ "CTF::get_estimated_flops"()


#from enum import Enum
Expand Down Expand Up @@ -6377,4 +6379,22 @@ def arange(start, stop, step=1, dtype=None):
raise ValueError('CTF PYTHON ERROR: unsupported starting value type for numpy arange')
return t

def initialize_flops_counter():
"""
Set the flops counter to 0.
"""
initialize_flops_counter_()

def get_estimated_flops():
"""
Get analytically estimated flops, which are effectual flops in dense case,
but estimates based on aggregate nonzero density for sparse case.
Returns
-------
out: int
The number of estimated flops
"""
return get_estimated_flops_()


0 comments on commit fc9c4d9

Please sign in to comment.