@Namespace(value="dnnl") @Properties(inherit=dnnl.class) public class primitive_attr extends dnnl_primitive_attr_handle
Primitive attributes.
dev_guide_attributesPointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter| Constructor and Description |
|---|
primitive_attr() |
primitive_attr(dnnl_primitive_attr t) |
primitive_attr(dnnl_primitive_attr t,
boolean weak) |
primitive_attr(long size)
Native array allocator.
|
primitive_attr(Pointer p)
Pointer cast constructor.
|
primitive_attr(primitive_attr arg0) |
| Modifier and Type | Method and Description |
|---|---|
void |
get_output_scales(int[] mask,
float[] scales) |
void |
get_output_scales(IntBuffer mask,
FloatBuffer scales) |
void |
get_output_scales(IntPointer mask,
FloatPointer scales)
Returns output scaling factors correspondence mask and values.
|
post_ops |
get_post_ops()
Returns post-ops previously set via set_post_ops().
|
void |
get_scales(int arg,
int[] mask,
float[] scales) |
void |
get_scales(int arg,
IntBuffer mask,
FloatBuffer scales) |
void |
get_scales(int arg,
IntPointer mask,
FloatPointer scales)
Returns scaling factors correspondence mask and values for a given
memory argument.
|
dnnl.scratchpad_mode |
get_scratchpad_mode()
Returns the scratchpad mode.
|
void |
get_zero_points(int arg,
int[] mask,
int[] zero_points) |
void |
get_zero_points(int arg,
IntBuffer mask,
IntBuffer zero_points) |
void |
get_zero_points(int arg,
IntPointer mask,
IntPointer zero_points)
Returns zero points correspondence mask and values.
|
primitive_attr |
getPointer(long i) |
primitive_attr |
position(long position) |
void |
set_output_scales(int mask,
float[] scales) |
void |
set_output_scales(int mask,
FloatBuffer scales) |
void |
set_output_scales(int mask,
FloatPointer scales)
Sets output scaling factors correspondence mask and values.
|
void |
set_post_ops(post_ops ops)
Sets post-ops.
|
void |
set_rnn_data_qparams(float scale,
float shift)
Sets quantization scale and shift parameters for RNN data tensors.
|
void |
set_rnn_weights_qparams(int mask,
float[] scales) |
void |
set_rnn_weights_qparams(int mask,
FloatBuffer scales) |
void |
set_rnn_weights_qparams(int mask,
FloatPointer scales)
Sets quantization scaling factors for RNN weights tensors.
|
void |
set_scales(int arg,
int mask,
float[] scales) |
void |
set_scales(int arg,
int mask,
FloatBuffer scales) |
void |
set_scales(int arg,
int mask,
FloatPointer scales)
Sets scaling factors for primitive operations for a given memory
argument.
|
void |
set_scratchpad_mode(dnnl.scratchpad_mode mode)
Sets scratchpad mode.
|
void |
set_scratchpad_mode(int mode) |
void |
set_zero_points(int arg,
int mask,
int[] zero_points) |
void |
set_zero_points(int arg,
int mask,
IntBuffer zero_points) |
void |
set_zero_points(int arg,
int mask,
IntPointer zero_points)
Sets zero points for primitive operations for a given memory argument.
|
asBoolean, asDnnl_primitive_attr, equals, get, get, notEquals, put, reset, resetaddress, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getPointer, getPointer, getPointer, hashCode, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, offsetof, parseBytes, physicalBytes, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zeropublic primitive_attr()
public primitive_attr(@Const @ByRef primitive_attr arg0)
public primitive_attr(dnnl_primitive_attr t, @Cast(value="bool") boolean weak)
public primitive_attr(dnnl_primitive_attr t)
public primitive_attr(Pointer p)
Pointer.Pointer(Pointer).public primitive_attr(long size)
Pointer.position(long).public primitive_attr position(long position)
position in class dnnl_primitive_attr_handlepublic primitive_attr getPointer(long i)
getPointer in class dnnl_primitive_attr_handlepublic dnnl.scratchpad_mode get_scratchpad_mode()
public void set_scratchpad_mode(dnnl.scratchpad_mode mode)
mode - Specified scratchpad mode.public void get_output_scales(@ByRef IntPointer mask, @StdVector FloatPointer scales)
mask - Scaling factors correspondence mask that defines the
correspondence between the output tensor dimensions and the \p
scales vector. The set i-th bit indicates that a dedicated output
scaling factor is used for each index along that dimension. The
mask value of 0 implies a common output scaling factor for the
whole output tensor.scales - Vector of output scaling factors.public void get_output_scales(@ByRef IntBuffer mask, @StdVector FloatBuffer scales)
public void get_output_scales(@ByRef int[] mask, @StdVector float[] scales)
public void set_output_scales(int mask,
@StdVector
FloatPointer scales)
int mb = 32, oc = 32,
oh = 14, ow = 14; // convolution output params
// unique output scales per output channel
vector<float> scales = { ... };
int oc_dim = 1; // mb_dim = 0, channel_dim = 1, height_dim = 2, ...
// construct a convolution descriptor
dnnl::convolution::desc conv_d;
dnnl::primitive_attr attr;
attr.set_output_scales(attr, oc, 1 << oc_dim, scales);
dnnl::primitive_desc conv_pd(conv_d, attr, engine);
\note
The order of dimensions does not depend on how elements are laid
out in memory. For example:
- for a 2D CNN activations tensor the order is always (n, c)
- for a 4D CNN activations tensor the order is always (n, c, h, w)
- for a 5D CNN weights tensor the order is always
(g, oc, ic, kh, kw)mask - Defines the correspondence between the output tensor
dimensions and the \p scales vector. The set i-th bit indicates
that a dedicated scaling factor is used for each index along that
dimension. Set the mask to 0 to use a common output scaling factor
for the whole output tensor.scales - Constant vector of output scaling factors. If the
scaling factors are known at the time of this call, the following
equality must hold:
scales.size() = \prod\limits_{d \in mask} output.dims[d].
Violations can only be detected when the attributes
are used to create a primitive descriptor.
If the scaling factors are not known at the time of the call,
this vector must contain a single #DNNL_RUNTIME_F32_VAL value and
the output scaling factors must be passed at execution time as an
argument with index #DNNL_ARG_ATTR_OUTPUT_SCALES.public void set_output_scales(int mask,
@StdVector
FloatBuffer scales)
public void set_output_scales(int mask,
@StdVector
float[] scales)
public void get_scales(int arg,
@ByRef
IntPointer mask,
@StdVector
FloatPointer scales)
arg - Parameter argument index as passed to the
primitive::execute() call.mask - Scaling factors correspondence mask that defines the
correspondence between the output tensor dimensions and the \p
scales vector. The set i-th bit indicates that a dedicated scaling
factor is used for each index along that dimension. Set the mask to
0 to use a common scaling factor for the whole output tensor.scales - Output vector of scaling factors.public void get_scales(int arg,
@ByRef
IntBuffer mask,
@StdVector
FloatBuffer scales)
public void get_scales(int arg,
@ByRef
int[] mask,
@StdVector
float[] scales)
public void set_scales(int arg,
int mask,
@StdVector
FloatPointer scales)
arg - Parameter argument index as passed to the
primitive::execute() call.mask - Scaling factors correspondence mask that defines the
correspondence between the tensor dimensions and the \p scales
vector. The set i-th bit indicates that a dedicated scaling factor
is used for each index along that dimension. Set the mask to 0 to
use a common scaling factor for the whole output tensor.scales - Constant vector of scaling factors. The following equality
must hold:
scales.size() = \prod\limits_{d \in mask} argument.dims[d].dnnl_primitive_attr_set_scales,
dnnl::primitive_attr::set_output_scalespublic void set_scales(int arg,
int mask,
@StdVector
FloatBuffer scales)
public void set_scales(int arg,
int mask,
@StdVector
float[] scales)
public void get_zero_points(int arg,
@ByRef
IntPointer mask,
@StdVector
IntPointer zero_points)
arg - Parameter argument index as passed to the
primitive::execute() call.mask - Zero points correspondence mask that defines the
correspondence between the output tensor dimensions and the \p
zero_points vector. The set i-th bit indicates that a dedicated
zero point is used for each index along that dimension. Set the
mask to 0 to use a common zero point for the whole output tensor.zero_points - Output vector of zero points.public void get_zero_points(int arg,
@ByRef
IntBuffer mask,
@StdVector
IntBuffer zero_points)
public void get_zero_points(int arg,
@ByRef
int[] mask,
@StdVector
int[] zero_points)
public void set_zero_points(int arg,
int mask,
@StdVector
IntPointer zero_points)
arg - Parameter argument index as passed to the
primitive::execute() call.mask - Zero point correspondence mask that defines the
correspondence between the tensor dimensions and the \p
zero_points vector. The set i-th bit indicates that a dedicated
zero point is used for each index along that dimension. Set the
mask to 0 to use a common zero point for the whole output tensor.zero_points - Constant vector of zero points. If the zero points
are known at the time of this call, the following equality must
hold: zero\_points.size() = \prod\limits_{d \in mask}
argument.dims[d]. If the zero points are not known at the time
of the call, this vector must contain a single
#DNNL_RUNTIME_F32_VAL value and the zero points must be passed at
execution time as an argument with index
#DNNL_ARG_ATTR_ZERO_POINTS.dnnl_primitive_attr_set_zero_points,
dnnl::primitive_attr::set_output_scalespublic void set_zero_points(int arg,
int mask,
@StdVector
IntBuffer zero_points)
public void set_zero_points(int arg,
int mask,
@StdVector
int[] zero_points)
@Const @ByVal public post_ops get_post_ops()
public void set_post_ops(@Const @ByVal post_ops ops)
ops - Post-ops object to copy post-ops from.public void set_rnn_data_qparams(float scale,
float shift)
scale * (data + shift).
\note
Quantization scale and shift are common for src_layer, src_iter,
dst_iter, and dst_layer.
Example usage:
// RNN parameters
int l = 2, t = 2, mb = 32, sic = 32, slc = 32, dic = 32, dlc = 32;
// Activations quantization parameters
float scale = 2.0f, shift = 0.5f;
primitive_attr attr;
// Set scale and shift for int8 quantization of activation
attr.set_rnn_data_qparams(scale, shift);
// Create and configure rnn op_desc
vanilla_rnn_forward::desc rnn_d(/* arguments * /);
vanilla_rnn_forward::primitive_desc rnn_d(rnn_d, attr, engine);
scale - The value to scale the data by.shift - The value to shift the data by.public void set_rnn_weights_qparams(int mask,
@StdVector
FloatPointer scales)
mask - Scaling factors correspondence mask that defines the
correspondence between the output tensor dimensions and the \p
scales vector. The set i-th bit indicates that a dedicated scaling
factor should be used each index along that dimension. Set the
mask to 0 to use a common scaling factor for the whole output
tensor.scales - Constant vector of output scaling factors. The following
equality must hold:
scales.size() = \prod\limits_{d \in mask} weights.dims[d].
Violations can only be detected when the attributes are used to
create a primitive descriptor.public void set_rnn_weights_qparams(int mask,
@StdVector
FloatBuffer scales)
public void set_rnn_weights_qparams(int mask,
@StdVector
float[] scales)
Copyright © 2020. All rights reserved.