Git Product home page Git Product logo

Comments (1)

zzzDavid avatar zzzDavid commented on July 17, 2024

The AST branch is merged into hcl-mlir branch, and implementation of hcl.max, hcl.min is added by this commit: afe4471

Test case added here:

def _test_maxpool(in_shape, out_shape, stride, kernel, test_dtype):
def max_pool(data):
h = hcl.reduce_axis(0, kernel)
w = hcl.reduce_axis(0, kernel)
return hcl.compute(
out_shape,
lambda hh, ww: hcl.max(
data[stride * hh + h, stride * ww + w], axis=[h, w], dtype=test_dtype
),
name="max_pool",
dtype=test_dtype,
)
A = hcl.placeholder(in_shape, "A", dtype=test_dtype)
s = hcl.create_schedule([A], max_pool)
f = hcl.build(s)
np_a = np.random.randint(0, 10, size=in_shape)
a = hcl.asarray(np_a, dtype=test_dtype)
b = hcl.asarray(np.zeros(out_shape), dtype=test_dtype)
f(a, b)
np_b = b.asnumpy()
b_golden = np.zeros(out_shape)
for i in range(out_shape[0]):
for j in range(out_shape[1]):
b_golden[i, j] = np.max(
np_a[i * stride : i * stride + kernel, j * stride : j * stride + kernel]
)
assert np.allclose(np_b, b_golden)
def test_maxpool():
in_shape = (2, 8)
out_shape = (1, 4)
stride = 2
kernel = 2
test_dtypes = [hcl.Int(10), hcl.Int(8), hcl.Int(6), hcl.Fixed(12, 6)]
for test_dtype in test_dtypes:
_test_maxpool(in_shape, out_shape, stride, kernel, test_dtype)

from heterocl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.