MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / prepare

Method prepare

src/gpu/cl/operators/ClFullyConnected.cpp:634–691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

632}
633
634void ClFullyConnected::prepare(ITensorPack &tensors)
635{
636 // Note : Running prepare() each run when _use_matmul is true is unnecessary unless weights conversion is needed.
637 if (!_is_prepared || _dynamic_gemm)
638 {
639#ifdef ARM_COMPUTE_ASSERTS_ENABLED
640 ++_asrt_prepare_count;
641 ARM_COMPUTE_ERROR_ON(!_dynamic_gemm && !_use_matmul && _asrt_prepare_count > 1);
642#endif // ARM_COMPUTE_ASSERTS_ENABLED
643
644 auto weights = tensors.get_const_tensor(ACL_SRC_1);
645
646 CLAuxTensorHandler reshaped_weights(offset_int_vec(TransposedWeights), _reshaped_weights, tensors, false);
647 CLAuxTensorHandler converted_weights(offset_int_vec(ConvertedWeights), _converted_weights, tensors, false);
648
649 // Pointer to current weights
650 const ITensor *cur_weights = weights;
651
652 // Reshape weights if needed. Disabled when matmul kernels are enabled as matmul fuses transpose.
653 if (_transpose_weights && !_use_matmul)
654 {
655 // Run reshape weights kernel and mark weights as unused
656 ITensorPack transpose_pack{{ACL_SRC, weights}, {ACL_DST, reshaped_weights.get()}};
657 _reshape_weights->run(transpose_pack);
658
659 cur_weights->mark_as_unused();
660 cur_weights = reshaped_weights.get();
661 }
662
663 // Convert weights if needed
664 if (_run_convert_weights)
665 {
666 ITensorPack convert_pack{{ACL_SRC, cur_weights}, {ACL_DST, converted_weights.get()}};
667 _convert_weights->run(convert_pack);
668
669 cur_weights->mark_as_unused();
670 cur_weights = converted_weights.get();
671 }
672
673 ITensorPack gemm_pack = tensors;
674 gemm_pack.add_const_tensor(ACL_SRC_1, cur_weights);
675
676 // Prepare GEMM prepare and release unused weights
677 if (_dynamic_gemm || !_use_matmul)
678 {
679 if (!_is_quantized)
680 {
681 _mm_gemm->prepare(gemm_pack);
682 }
683 else
684 {
685 _mm_gemmlowp->prepare(gemm_pack);
686 }
687 }
688
689 _is_prepared = true;
690 }
691}

Callers

nothing calls this directly

Calls 6

offset_int_vecFunction · 0.85
get_const_tensorMethod · 0.80
mark_as_unusedMethod · 0.80
add_const_tensorMethod · 0.80
getMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected