Currently, the extent is not exposed in access_ptr api of Buffer. But in this api implement, the total buffer size is used for extent argument of tvm_access_ptr.
As @tqchen mentioned in this discussion https://discuss.tvm.ai/t/what-is-the-precise-meaning-of-tvm-access-ptrs-extent/957 , if the offset is non-zero, then the end of access region offset+ extent will be out of range.
This is illustrated in this code sample.
m = tvm.var('m')
n = tvm.var('n')
Ab = tvm.decl_buffer((m, n), tvm.float32)
aptr = Ab.access_ptr("rw", offset=100)
assert tvm.ir_pass.Equal(aptr.args[3], m * n - 100)